babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059
  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 mesh or 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. /** @hidden */
  11402. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11403. /** Launch a ray to try to pick sprites in the scene
  11404. * @param x position on screen
  11405. * @param y position on screen
  11406. * @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
  11407. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11408. * @returns a PickingInfo array
  11409. */
  11410. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11411. /** Use the given ray to pick sprites in the scene
  11412. * @param ray The ray (in world space) to use to pick meshes
  11413. * @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
  11414. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11415. * @returns a PickingInfo array
  11416. */
  11417. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11418. /**
  11419. * Force the sprite under the pointer
  11420. * @param sprite defines the sprite to use
  11421. */
  11422. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11423. /**
  11424. * Gets the sprite under the pointer
  11425. * @returns a Sprite or null if no sprite is under the pointer
  11426. */
  11427. getPointerOverSprite(): Nullable<Sprite>;
  11428. }
  11429. }
  11430. /**
  11431. * Defines the sprite scene component responsible to manage sprites
  11432. * in a given scene.
  11433. */
  11434. export class SpriteSceneComponent implements ISceneComponent {
  11435. /**
  11436. * The component name helpfull to identify the component in the list of scene components.
  11437. */
  11438. readonly name: string;
  11439. /**
  11440. * The scene the component belongs to.
  11441. */
  11442. scene: Scene;
  11443. /** @hidden */
  11444. private _spritePredicate;
  11445. /**
  11446. * Creates a new instance of the component for the given scene
  11447. * @param scene Defines the scene to register the component in
  11448. */
  11449. constructor(scene: Scene);
  11450. /**
  11451. * Registers the component in a given scene
  11452. */
  11453. register(): void;
  11454. /**
  11455. * Rebuilds the elements related to this component in case of
  11456. * context lost for instance.
  11457. */
  11458. rebuild(): void;
  11459. /**
  11460. * Disposes the component and the associated ressources.
  11461. */
  11462. dispose(): void;
  11463. private _pickSpriteButKeepRay;
  11464. private _pointerMove;
  11465. private _pointerDown;
  11466. private _pointerUp;
  11467. }
  11468. }
  11469. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11470. /** @hidden */
  11471. export var fogFragmentDeclaration: {
  11472. name: string;
  11473. shader: string;
  11474. };
  11475. }
  11476. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11477. /** @hidden */
  11478. export var fogFragment: {
  11479. name: string;
  11480. shader: string;
  11481. };
  11482. }
  11483. declare module "babylonjs/Shaders/sprites.fragment" {
  11484. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11485. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11486. /** @hidden */
  11487. export var spritesPixelShader: {
  11488. name: string;
  11489. shader: string;
  11490. };
  11491. }
  11492. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11493. /** @hidden */
  11494. export var fogVertexDeclaration: {
  11495. name: string;
  11496. shader: string;
  11497. };
  11498. }
  11499. declare module "babylonjs/Shaders/sprites.vertex" {
  11500. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11501. /** @hidden */
  11502. export var spritesVertexShader: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module "babylonjs/Sprites/spriteManager" {
  11508. import { IDisposable, Scene } from "babylonjs/scene";
  11509. import { Nullable } from "babylonjs/types";
  11510. import { Observable } from "babylonjs/Misc/observable";
  11511. import { Sprite } from "babylonjs/Sprites/sprite";
  11512. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11513. import { Camera } from "babylonjs/Cameras/camera";
  11514. import { Texture } from "babylonjs/Materials/Textures/texture";
  11515. import "babylonjs/Shaders/sprites.fragment";
  11516. import "babylonjs/Shaders/sprites.vertex";
  11517. import { Ray } from "babylonjs/Culling/ray";
  11518. /**
  11519. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11520. */
  11521. export interface ISpriteManager extends IDisposable {
  11522. /**
  11523. * Restricts the camera to viewing objects with the same layerMask.
  11524. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11525. */
  11526. layerMask: number;
  11527. /**
  11528. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11529. */
  11530. isPickable: boolean;
  11531. /**
  11532. * Specifies the rendering group id for this mesh (0 by default)
  11533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11534. */
  11535. renderingGroupId: number;
  11536. /**
  11537. * Defines the list of sprites managed by the manager.
  11538. */
  11539. sprites: Array<Sprite>;
  11540. /**
  11541. * Tests the intersection of a sprite with a specific ray.
  11542. * @param ray The ray we are sending to test the collision
  11543. * @param camera The camera space we are sending rays in
  11544. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11545. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11546. * @returns picking info or null.
  11547. */
  11548. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11549. /**
  11550. * Intersects the sprites with a ray
  11551. * @param ray defines the ray to intersect with
  11552. * @param camera defines the current active camera
  11553. * @param predicate defines a predicate used to select candidate sprites
  11554. * @returns null if no hit or a PickingInfo array
  11555. */
  11556. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11557. /**
  11558. * Renders the list of sprites on screen.
  11559. */
  11560. render(): void;
  11561. }
  11562. /**
  11563. * Class used to manage multiple sprites on the same spritesheet
  11564. * @see http://doc.babylonjs.com/babylon101/sprites
  11565. */
  11566. export class SpriteManager implements ISpriteManager {
  11567. /** defines the manager's name */
  11568. name: string;
  11569. /** Gets the list of sprites */
  11570. sprites: Sprite[];
  11571. /** Gets or sets the rendering group id (0 by default) */
  11572. renderingGroupId: number;
  11573. /** Gets or sets camera layer mask */
  11574. layerMask: number;
  11575. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11576. fogEnabled: boolean;
  11577. /** Gets or sets a boolean indicating if the sprites are pickable */
  11578. isPickable: boolean;
  11579. /** Defines the default width of a cell in the spritesheet */
  11580. cellWidth: number;
  11581. /** Defines the default height of a cell in the spritesheet */
  11582. cellHeight: number;
  11583. /** Associative array from JSON sprite data file */
  11584. private _cellData;
  11585. /** Array of sprite names from JSON sprite data file */
  11586. private _spriteMap;
  11587. /** True when packed cell data from JSON file is ready*/
  11588. private _packedAndReady;
  11589. /**
  11590. * An event triggered when the manager is disposed.
  11591. */
  11592. onDisposeObservable: Observable<SpriteManager>;
  11593. private _onDisposeObserver;
  11594. /**
  11595. * Callback called when the manager is disposed
  11596. */
  11597. onDispose: () => void;
  11598. private _capacity;
  11599. private _fromPacked;
  11600. private _spriteTexture;
  11601. private _epsilon;
  11602. private _scene;
  11603. private _vertexData;
  11604. private _buffer;
  11605. private _vertexBuffers;
  11606. private _indexBuffer;
  11607. private _effectBase;
  11608. private _effectFog;
  11609. /**
  11610. * Gets or sets the spritesheet texture
  11611. */
  11612. texture: Texture;
  11613. /**
  11614. * Creates a new sprite manager
  11615. * @param name defines the manager's name
  11616. * @param imgUrl defines the sprite sheet url
  11617. * @param capacity defines the maximum allowed number of sprites
  11618. * @param cellSize defines the size of a sprite cell
  11619. * @param scene defines the hosting scene
  11620. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11621. * @param samplingMode defines the smapling mode to use with spritesheet
  11622. * @param fromPacked set to false; do not alter
  11623. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11624. */
  11625. constructor(
  11626. /** defines the manager's name */
  11627. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11628. private _makePacked;
  11629. private _appendSpriteVertex;
  11630. /**
  11631. * Intersects the sprites with a ray
  11632. * @param ray defines the ray to intersect with
  11633. * @param camera defines the current active camera
  11634. * @param predicate defines a predicate used to select candidate sprites
  11635. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11636. * @returns null if no hit or a PickingInfo
  11637. */
  11638. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11639. /**
  11640. * Intersects the sprites with a ray
  11641. * @param ray defines the ray to intersect with
  11642. * @param camera defines the current active camera
  11643. * @param predicate defines a predicate used to select candidate sprites
  11644. * @returns null if no hit or a PickingInfo array
  11645. */
  11646. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11647. /**
  11648. * Render all child sprites
  11649. */
  11650. render(): void;
  11651. /**
  11652. * Release associated resources
  11653. */
  11654. dispose(): void;
  11655. }
  11656. }
  11657. declare module "babylonjs/Sprites/sprite" {
  11658. import { Vector3 } from "babylonjs/Maths/math.vector";
  11659. import { Nullable } from "babylonjs/types";
  11660. import { ActionManager } from "babylonjs/Actions/actionManager";
  11661. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11662. import { Color4 } from "babylonjs/Maths/math.color";
  11663. /**
  11664. * Class used to represent a sprite
  11665. * @see http://doc.babylonjs.com/babylon101/sprites
  11666. */
  11667. export class Sprite {
  11668. /** defines the name */
  11669. name: string;
  11670. /** Gets or sets the current world position */
  11671. position: Vector3;
  11672. /** Gets or sets the main color */
  11673. color: Color4;
  11674. /** Gets or sets the width */
  11675. width: number;
  11676. /** Gets or sets the height */
  11677. height: number;
  11678. /** Gets or sets rotation angle */
  11679. angle: number;
  11680. /** Gets or sets the cell index in the sprite sheet */
  11681. cellIndex: number;
  11682. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11683. cellRef: string;
  11684. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11685. invertU: number;
  11686. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11687. invertV: number;
  11688. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11689. disposeWhenFinishedAnimating: boolean;
  11690. /** Gets the list of attached animations */
  11691. animations: Animation[];
  11692. /** Gets or sets a boolean indicating if the sprite can be picked */
  11693. isPickable: boolean;
  11694. /**
  11695. * Gets or sets the associated action manager
  11696. */
  11697. actionManager: Nullable<ActionManager>;
  11698. private _animationStarted;
  11699. private _loopAnimation;
  11700. private _fromIndex;
  11701. private _toIndex;
  11702. private _delay;
  11703. private _direction;
  11704. private _manager;
  11705. private _time;
  11706. private _onAnimationEnd;
  11707. /**
  11708. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11709. */
  11710. isVisible: boolean;
  11711. /**
  11712. * Gets or sets the sprite size
  11713. */
  11714. size: number;
  11715. /**
  11716. * Creates a new Sprite
  11717. * @param name defines the name
  11718. * @param manager defines the manager
  11719. */
  11720. constructor(
  11721. /** defines the name */
  11722. name: string, manager: ISpriteManager);
  11723. /**
  11724. * Starts an animation
  11725. * @param from defines the initial key
  11726. * @param to defines the end key
  11727. * @param loop defines if the animation must loop
  11728. * @param delay defines the start delay (in ms)
  11729. * @param onAnimationEnd defines a callback to call when animation ends
  11730. */
  11731. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11732. /** Stops current animation (if any) */
  11733. stopAnimation(): void;
  11734. /** @hidden */
  11735. _animate(deltaTime: number): void;
  11736. /** Release associated resources */
  11737. dispose(): void;
  11738. }
  11739. }
  11740. declare module "babylonjs/Collisions/pickingInfo" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11744. import { Sprite } from "babylonjs/Sprites/sprite";
  11745. import { Ray } from "babylonjs/Culling/ray";
  11746. /**
  11747. * Information about the result of picking within a scene
  11748. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11749. */
  11750. export class PickingInfo {
  11751. /** @hidden */
  11752. _pickingUnavailable: boolean;
  11753. /**
  11754. * If the pick collided with an object
  11755. */
  11756. hit: boolean;
  11757. /**
  11758. * Distance away where the pick collided
  11759. */
  11760. distance: number;
  11761. /**
  11762. * The location of pick collision
  11763. */
  11764. pickedPoint: Nullable<Vector3>;
  11765. /**
  11766. * The mesh corresponding the the pick collision
  11767. */
  11768. pickedMesh: Nullable<AbstractMesh>;
  11769. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11770. bu: number;
  11771. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11772. bv: number;
  11773. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11774. faceId: number;
  11775. /** Id of the the submesh that was picked */
  11776. subMeshId: number;
  11777. /** If a sprite was picked, this will be the sprite the pick collided with */
  11778. pickedSprite: Nullable<Sprite>;
  11779. /**
  11780. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11781. */
  11782. originMesh: Nullable<AbstractMesh>;
  11783. /**
  11784. * The ray that was used to perform the picking.
  11785. */
  11786. ray: Nullable<Ray>;
  11787. /**
  11788. * Gets the normal correspodning to the face the pick collided with
  11789. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11790. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11791. * @returns The normal correspodning to the face the pick collided with
  11792. */
  11793. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11794. /**
  11795. * Gets the texture coordinates of where the pick occured
  11796. * @returns the vector containing the coordnates of the texture
  11797. */
  11798. getTextureCoordinates(): Nullable<Vector2>;
  11799. }
  11800. }
  11801. declare module "babylonjs/Events/pointerEvents" {
  11802. import { Nullable } from "babylonjs/types";
  11803. import { Vector2 } from "babylonjs/Maths/math.vector";
  11804. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11805. import { Ray } from "babylonjs/Culling/ray";
  11806. /**
  11807. * Gather the list of pointer event types as constants.
  11808. */
  11809. export class PointerEventTypes {
  11810. /**
  11811. * 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.
  11812. */
  11813. static readonly POINTERDOWN: number;
  11814. /**
  11815. * The pointerup event is fired when a pointer is no longer active.
  11816. */
  11817. static readonly POINTERUP: number;
  11818. /**
  11819. * The pointermove event is fired when a pointer changes coordinates.
  11820. */
  11821. static readonly POINTERMOVE: number;
  11822. /**
  11823. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11824. */
  11825. static readonly POINTERWHEEL: number;
  11826. /**
  11827. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11828. */
  11829. static readonly POINTERPICK: number;
  11830. /**
  11831. * The pointertap event is fired when a the object has been touched and released without drag.
  11832. */
  11833. static readonly POINTERTAP: number;
  11834. /**
  11835. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11836. */
  11837. static readonly POINTERDOUBLETAP: number;
  11838. }
  11839. /**
  11840. * Base class of pointer info types.
  11841. */
  11842. export class PointerInfoBase {
  11843. /**
  11844. * Defines the type of event (PointerEventTypes)
  11845. */
  11846. type: number;
  11847. /**
  11848. * Defines the related dom event
  11849. */
  11850. event: PointerEvent | MouseWheelEvent;
  11851. /**
  11852. * Instantiates the base class of pointers info.
  11853. * @param type Defines the type of event (PointerEventTypes)
  11854. * @param event Defines the related dom event
  11855. */
  11856. constructor(
  11857. /**
  11858. * Defines the type of event (PointerEventTypes)
  11859. */
  11860. type: number,
  11861. /**
  11862. * Defines the related dom event
  11863. */
  11864. event: PointerEvent | MouseWheelEvent);
  11865. }
  11866. /**
  11867. * This class is used to store pointer related info for the onPrePointerObservable event.
  11868. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11869. */
  11870. export class PointerInfoPre extends PointerInfoBase {
  11871. /**
  11872. * Ray from a pointer if availible (eg. 6dof controller)
  11873. */
  11874. ray: Nullable<Ray>;
  11875. /**
  11876. * Defines the local position of the pointer on the canvas.
  11877. */
  11878. localPosition: Vector2;
  11879. /**
  11880. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11881. */
  11882. skipOnPointerObservable: boolean;
  11883. /**
  11884. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11885. * @param type Defines the type of event (PointerEventTypes)
  11886. * @param event Defines the related dom event
  11887. * @param localX Defines the local x coordinates of the pointer when the event occured
  11888. * @param localY Defines the local y coordinates of the pointer when the event occured
  11889. */
  11890. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11891. }
  11892. /**
  11893. * This type contains all the data related to a pointer event in Babylon.js.
  11894. * 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.
  11895. */
  11896. export class PointerInfo extends PointerInfoBase {
  11897. /**
  11898. * Defines the picking info associated to the info (if any)\
  11899. */
  11900. pickInfo: Nullable<PickingInfo>;
  11901. /**
  11902. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11903. * @param type Defines the type of event (PointerEventTypes)
  11904. * @param event Defines the related dom event
  11905. * @param pickInfo Defines the picking info associated to the info (if any)\
  11906. */
  11907. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11908. /**
  11909. * Defines the picking info associated to the info (if any)\
  11910. */
  11911. pickInfo: Nullable<PickingInfo>);
  11912. }
  11913. /**
  11914. * Data relating to a touch event on the screen.
  11915. */
  11916. export interface PointerTouch {
  11917. /**
  11918. * X coordinate of touch.
  11919. */
  11920. x: number;
  11921. /**
  11922. * Y coordinate of touch.
  11923. */
  11924. y: number;
  11925. /**
  11926. * Id of touch. Unique for each finger.
  11927. */
  11928. pointerId: number;
  11929. /**
  11930. * Event type passed from DOM.
  11931. */
  11932. type: any;
  11933. }
  11934. }
  11935. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11936. import { Observable } from "babylonjs/Misc/observable";
  11937. import { Nullable } from "babylonjs/types";
  11938. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11939. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11940. /**
  11941. * Manage the mouse inputs to control the movement of a free camera.
  11942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11943. */
  11944. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11945. /**
  11946. * Define if touch is enabled in the mouse input
  11947. */
  11948. touchEnabled: boolean;
  11949. /**
  11950. * Defines the camera the input is attached to.
  11951. */
  11952. camera: FreeCamera;
  11953. /**
  11954. * Defines the buttons associated with the input to handle camera move.
  11955. */
  11956. buttons: number[];
  11957. /**
  11958. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11959. */
  11960. angularSensibility: number;
  11961. private _pointerInput;
  11962. private _onMouseMove;
  11963. private _observer;
  11964. private previousPosition;
  11965. /**
  11966. * Observable for when a pointer move event occurs containing the move offset
  11967. */
  11968. onPointerMovedObservable: Observable<{
  11969. offsetX: number;
  11970. offsetY: number;
  11971. }>;
  11972. /**
  11973. * @hidden
  11974. * If the camera should be rotated automatically based on pointer movement
  11975. */
  11976. _allowCameraRotation: boolean;
  11977. /**
  11978. * Manage the mouse inputs to control the movement of a free camera.
  11979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11980. * @param touchEnabled Defines if touch is enabled or not
  11981. */
  11982. constructor(
  11983. /**
  11984. * Define if touch is enabled in the mouse input
  11985. */
  11986. touchEnabled?: boolean);
  11987. /**
  11988. * Attach the input controls to a specific dom element to get the input from.
  11989. * @param element Defines the element the controls should be listened from
  11990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11991. */
  11992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11993. /**
  11994. * Called on JS contextmenu event.
  11995. * Override this method to provide functionality.
  11996. */
  11997. protected onContextMenu(evt: PointerEvent): void;
  11998. /**
  11999. * Detach the current controls from the specified dom element.
  12000. * @param element Defines the element to stop listening the inputs from
  12001. */
  12002. detachControl(element: Nullable<HTMLElement>): void;
  12003. /**
  12004. * Gets the class name of the current intput.
  12005. * @returns the class name
  12006. */
  12007. getClassName(): string;
  12008. /**
  12009. * Get the friendly name associated with the input class.
  12010. * @returns the input friendly name
  12011. */
  12012. getSimpleName(): string;
  12013. }
  12014. }
  12015. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12016. import { Nullable } from "babylonjs/types";
  12017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12018. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12019. /**
  12020. * Manage the touch inputs to control the movement of a free camera.
  12021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12022. */
  12023. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12024. /**
  12025. * Defines the camera the input is attached to.
  12026. */
  12027. camera: FreeCamera;
  12028. /**
  12029. * Defines the touch sensibility for rotation.
  12030. * The higher the faster.
  12031. */
  12032. touchAngularSensibility: number;
  12033. /**
  12034. * Defines the touch sensibility for move.
  12035. * The higher the faster.
  12036. */
  12037. touchMoveSensibility: number;
  12038. private _offsetX;
  12039. private _offsetY;
  12040. private _pointerPressed;
  12041. private _pointerInput;
  12042. private _observer;
  12043. private _onLostFocus;
  12044. /**
  12045. * Attach the input controls to a specific dom element to get the input from.
  12046. * @param element Defines the element the controls should be listened from
  12047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12048. */
  12049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12050. /**
  12051. * Detach the current controls from the specified dom element.
  12052. * @param element Defines the element to stop listening the inputs from
  12053. */
  12054. detachControl(element: Nullable<HTMLElement>): void;
  12055. /**
  12056. * Update the current camera state depending on the inputs that have been used this frame.
  12057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12058. */
  12059. checkInputs(): void;
  12060. /**
  12061. * Gets the class name of the current intput.
  12062. * @returns the class name
  12063. */
  12064. getClassName(): string;
  12065. /**
  12066. * Get the friendly name associated with the input class.
  12067. * @returns the input friendly name
  12068. */
  12069. getSimpleName(): string;
  12070. }
  12071. }
  12072. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12074. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12075. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12076. import { Nullable } from "babylonjs/types";
  12077. /**
  12078. * Default Inputs manager for the FreeCamera.
  12079. * It groups all the default supported inputs for ease of use.
  12080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12081. */
  12082. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12083. /**
  12084. * @hidden
  12085. */
  12086. _mouseInput: Nullable<FreeCameraMouseInput>;
  12087. /**
  12088. * Instantiates a new FreeCameraInputsManager.
  12089. * @param camera Defines the camera the inputs belong to
  12090. */
  12091. constructor(camera: FreeCamera);
  12092. /**
  12093. * Add keyboard input support to the input manager.
  12094. * @returns the current input manager
  12095. */
  12096. addKeyboard(): FreeCameraInputsManager;
  12097. /**
  12098. * Add mouse input support to the input manager.
  12099. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12100. * @returns the current input manager
  12101. */
  12102. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12103. /**
  12104. * Removes the mouse input support from the manager
  12105. * @returns the current input manager
  12106. */
  12107. removeMouse(): FreeCameraInputsManager;
  12108. /**
  12109. * Add touch input support to the input manager.
  12110. * @returns the current input manager
  12111. */
  12112. addTouch(): FreeCameraInputsManager;
  12113. /**
  12114. * Remove all attached input methods from a camera
  12115. */
  12116. clear(): void;
  12117. }
  12118. }
  12119. declare module "babylonjs/Cameras/freeCamera" {
  12120. import { Vector3 } from "babylonjs/Maths/math.vector";
  12121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12122. import { Scene } from "babylonjs/scene";
  12123. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12124. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12125. /**
  12126. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12127. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12129. */
  12130. export class FreeCamera extends TargetCamera {
  12131. /**
  12132. * Define the collision ellipsoid of the camera.
  12133. * This is helpful to simulate a camera body like the player body around the camera
  12134. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12135. */
  12136. ellipsoid: Vector3;
  12137. /**
  12138. * Define an offset for the position of the ellipsoid around the camera.
  12139. * This can be helpful to determine the center of the body near the gravity center of the body
  12140. * instead of its head.
  12141. */
  12142. ellipsoidOffset: Vector3;
  12143. /**
  12144. * Enable or disable collisions of the camera with the rest of the scene objects.
  12145. */
  12146. checkCollisions: boolean;
  12147. /**
  12148. * Enable or disable gravity on the camera.
  12149. */
  12150. applyGravity: boolean;
  12151. /**
  12152. * Define the input manager associated to the camera.
  12153. */
  12154. inputs: FreeCameraInputsManager;
  12155. /**
  12156. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12157. * Higher values reduce sensitivity.
  12158. */
  12159. /**
  12160. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12161. * Higher values reduce sensitivity.
  12162. */
  12163. angularSensibility: number;
  12164. /**
  12165. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12166. */
  12167. keysUp: number[];
  12168. /**
  12169. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12170. */
  12171. keysDown: number[];
  12172. /**
  12173. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12174. */
  12175. keysLeft: number[];
  12176. /**
  12177. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12178. */
  12179. keysRight: number[];
  12180. /**
  12181. * Event raised when the camera collide with a mesh in the scene.
  12182. */
  12183. onCollide: (collidedMesh: AbstractMesh) => void;
  12184. private _collider;
  12185. private _needMoveForGravity;
  12186. private _oldPosition;
  12187. private _diffPosition;
  12188. private _newPosition;
  12189. /** @hidden */
  12190. _localDirection: Vector3;
  12191. /** @hidden */
  12192. _transformedDirection: Vector3;
  12193. /**
  12194. * Instantiates a Free Camera.
  12195. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12196. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12197. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12198. * @param name Define the name of the camera in the scene
  12199. * @param position Define the start position of the camera in the scene
  12200. * @param scene Define the scene the camera belongs to
  12201. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12202. */
  12203. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12204. /**
  12205. * Attached controls to the current camera.
  12206. * @param element Defines the element the controls should be listened from
  12207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12208. */
  12209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12210. /**
  12211. * Detach the current controls from the camera.
  12212. * The camera will stop reacting to inputs.
  12213. * @param element Defines the element to stop listening the inputs from
  12214. */
  12215. detachControl(element: HTMLElement): void;
  12216. private _collisionMask;
  12217. /**
  12218. * Define a collision mask to limit the list of object the camera can collide with
  12219. */
  12220. collisionMask: number;
  12221. /** @hidden */
  12222. _collideWithWorld(displacement: Vector3): void;
  12223. private _onCollisionPositionChange;
  12224. /** @hidden */
  12225. _checkInputs(): void;
  12226. /** @hidden */
  12227. _decideIfNeedsToMove(): boolean;
  12228. /** @hidden */
  12229. _updatePosition(): void;
  12230. /**
  12231. * Destroy the camera and release the current resources hold by it.
  12232. */
  12233. dispose(): void;
  12234. /**
  12235. * Gets the current object class name.
  12236. * @return the class name
  12237. */
  12238. getClassName(): string;
  12239. }
  12240. }
  12241. declare module "babylonjs/Gamepads/gamepad" {
  12242. import { Observable } from "babylonjs/Misc/observable";
  12243. /**
  12244. * Represents a gamepad control stick position
  12245. */
  12246. export class StickValues {
  12247. /**
  12248. * The x component of the control stick
  12249. */
  12250. x: number;
  12251. /**
  12252. * The y component of the control stick
  12253. */
  12254. y: number;
  12255. /**
  12256. * Initializes the gamepad x and y control stick values
  12257. * @param x The x component of the gamepad control stick value
  12258. * @param y The y component of the gamepad control stick value
  12259. */
  12260. constructor(
  12261. /**
  12262. * The x component of the control stick
  12263. */
  12264. x: number,
  12265. /**
  12266. * The y component of the control stick
  12267. */
  12268. y: number);
  12269. }
  12270. /**
  12271. * An interface which manages callbacks for gamepad button changes
  12272. */
  12273. export interface GamepadButtonChanges {
  12274. /**
  12275. * Called when a gamepad has been changed
  12276. */
  12277. changed: boolean;
  12278. /**
  12279. * Called when a gamepad press event has been triggered
  12280. */
  12281. pressChanged: boolean;
  12282. /**
  12283. * Called when a touch event has been triggered
  12284. */
  12285. touchChanged: boolean;
  12286. /**
  12287. * Called when a value has changed
  12288. */
  12289. valueChanged: boolean;
  12290. }
  12291. /**
  12292. * Represents a gamepad
  12293. */
  12294. export class Gamepad {
  12295. /**
  12296. * The id of the gamepad
  12297. */
  12298. id: string;
  12299. /**
  12300. * The index of the gamepad
  12301. */
  12302. index: number;
  12303. /**
  12304. * The browser gamepad
  12305. */
  12306. browserGamepad: any;
  12307. /**
  12308. * Specifies what type of gamepad this represents
  12309. */
  12310. type: number;
  12311. private _leftStick;
  12312. private _rightStick;
  12313. /** @hidden */
  12314. _isConnected: boolean;
  12315. private _leftStickAxisX;
  12316. private _leftStickAxisY;
  12317. private _rightStickAxisX;
  12318. private _rightStickAxisY;
  12319. /**
  12320. * Triggered when the left control stick has been changed
  12321. */
  12322. private _onleftstickchanged;
  12323. /**
  12324. * Triggered when the right control stick has been changed
  12325. */
  12326. private _onrightstickchanged;
  12327. /**
  12328. * Represents a gamepad controller
  12329. */
  12330. static GAMEPAD: number;
  12331. /**
  12332. * Represents a generic controller
  12333. */
  12334. static GENERIC: number;
  12335. /**
  12336. * Represents an XBox controller
  12337. */
  12338. static XBOX: number;
  12339. /**
  12340. * Represents a pose-enabled controller
  12341. */
  12342. static POSE_ENABLED: number;
  12343. /**
  12344. * Represents an Dual Shock controller
  12345. */
  12346. static DUALSHOCK: number;
  12347. /**
  12348. * Specifies whether the left control stick should be Y-inverted
  12349. */
  12350. protected _invertLeftStickY: boolean;
  12351. /**
  12352. * Specifies if the gamepad has been connected
  12353. */
  12354. readonly isConnected: boolean;
  12355. /**
  12356. * Initializes the gamepad
  12357. * @param id The id of the gamepad
  12358. * @param index The index of the gamepad
  12359. * @param browserGamepad The browser gamepad
  12360. * @param leftStickX The x component of the left joystick
  12361. * @param leftStickY The y component of the left joystick
  12362. * @param rightStickX The x component of the right joystick
  12363. * @param rightStickY The y component of the right joystick
  12364. */
  12365. constructor(
  12366. /**
  12367. * The id of the gamepad
  12368. */
  12369. id: string,
  12370. /**
  12371. * The index of the gamepad
  12372. */
  12373. index: number,
  12374. /**
  12375. * The browser gamepad
  12376. */
  12377. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12378. /**
  12379. * Callback triggered when the left joystick has changed
  12380. * @param callback
  12381. */
  12382. onleftstickchanged(callback: (values: StickValues) => void): void;
  12383. /**
  12384. * Callback triggered when the right joystick has changed
  12385. * @param callback
  12386. */
  12387. onrightstickchanged(callback: (values: StickValues) => void): void;
  12388. /**
  12389. * Gets the left joystick
  12390. */
  12391. /**
  12392. * Sets the left joystick values
  12393. */
  12394. leftStick: StickValues;
  12395. /**
  12396. * Gets the right joystick
  12397. */
  12398. /**
  12399. * Sets the right joystick value
  12400. */
  12401. rightStick: StickValues;
  12402. /**
  12403. * Updates the gamepad joystick positions
  12404. */
  12405. update(): void;
  12406. /**
  12407. * Disposes the gamepad
  12408. */
  12409. dispose(): void;
  12410. }
  12411. /**
  12412. * Represents a generic gamepad
  12413. */
  12414. export class GenericPad extends Gamepad {
  12415. private _buttons;
  12416. private _onbuttondown;
  12417. private _onbuttonup;
  12418. /**
  12419. * Observable triggered when a button has been pressed
  12420. */
  12421. onButtonDownObservable: Observable<number>;
  12422. /**
  12423. * Observable triggered when a button has been released
  12424. */
  12425. onButtonUpObservable: Observable<number>;
  12426. /**
  12427. * Callback triggered when a button has been pressed
  12428. * @param callback Called when a button has been pressed
  12429. */
  12430. onbuttondown(callback: (buttonPressed: number) => void): void;
  12431. /**
  12432. * Callback triggered when a button has been released
  12433. * @param callback Called when a button has been released
  12434. */
  12435. onbuttonup(callback: (buttonReleased: number) => void): void;
  12436. /**
  12437. * Initializes the generic gamepad
  12438. * @param id The id of the generic gamepad
  12439. * @param index The index of the generic gamepad
  12440. * @param browserGamepad The browser gamepad
  12441. */
  12442. constructor(id: string, index: number, browserGamepad: any);
  12443. private _setButtonValue;
  12444. /**
  12445. * Updates the generic gamepad
  12446. */
  12447. update(): void;
  12448. /**
  12449. * Disposes the generic gamepad
  12450. */
  12451. dispose(): void;
  12452. }
  12453. }
  12454. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12455. import { Nullable } from "babylonjs/types";
  12456. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12457. import { Scene } from "babylonjs/scene";
  12458. module "babylonjs/Engines/engine" {
  12459. interface Engine {
  12460. /**
  12461. * Creates a raw texture
  12462. * @param data defines the data to store in the texture
  12463. * @param width defines the width of the texture
  12464. * @param height defines the height of the texture
  12465. * @param format defines the format of the data
  12466. * @param generateMipMaps defines if the engine should generate the mip levels
  12467. * @param invertY defines if data must be stored with Y axis inverted
  12468. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12469. * @param compression defines the compression used (null by default)
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @returns the raw texture inside an InternalTexture
  12472. */
  12473. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12474. /**
  12475. * Update a raw texture
  12476. * @param texture defines the texture to update
  12477. * @param data defines the data to store in the texture
  12478. * @param format defines the format of the data
  12479. * @param invertY defines if data must be stored with Y axis inverted
  12480. */
  12481. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12482. /**
  12483. * Update a raw texture
  12484. * @param texture defines the texture to update
  12485. * @param data defines the data to store in the texture
  12486. * @param format defines the format of the data
  12487. * @param invertY defines if data must be stored with Y axis inverted
  12488. * @param compression defines the compression used (null by default)
  12489. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12490. */
  12491. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12492. /**
  12493. * Creates a new raw cube texture
  12494. * @param data defines the array of data to use to create each face
  12495. * @param size defines the size of the textures
  12496. * @param format defines the format of the data
  12497. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12498. * @param generateMipMaps defines if the engine should generate the mip levels
  12499. * @param invertY defines if data must be stored with Y axis inverted
  12500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12501. * @param compression defines the compression used (null by default)
  12502. * @returns the cube texture as an InternalTexture
  12503. */
  12504. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12505. /**
  12506. * Update a raw cube texture
  12507. * @param texture defines the texture to udpdate
  12508. * @param data defines the data to store
  12509. * @param format defines the data format
  12510. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. */
  12513. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12514. /**
  12515. * Update a raw cube texture
  12516. * @param texture defines the texture to udpdate
  12517. * @param data defines the data to store
  12518. * @param format defines the data format
  12519. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12520. * @param invertY defines if data must be stored with Y axis inverted
  12521. * @param compression defines the compression used (null by default)
  12522. */
  12523. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12524. /**
  12525. * Update a raw cube texture
  12526. * @param texture defines the texture to udpdate
  12527. * @param data defines the data to store
  12528. * @param format defines the data format
  12529. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param compression defines the compression used (null by default)
  12532. * @param level defines which level of the texture to update
  12533. */
  12534. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12535. /**
  12536. * Creates a new raw cube texture from a specified url
  12537. * @param url defines the url where the data is located
  12538. * @param scene defines the current scene
  12539. * @param size defines the size of the textures
  12540. * @param format defines the format of the data
  12541. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12542. * @param noMipmap defines if the engine should avoid generating the mip levels
  12543. * @param callback defines a callback used to extract texture data from loaded data
  12544. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12545. * @param onLoad defines a callback called when texture is loaded
  12546. * @param onError defines a callback called if there is an error
  12547. * @returns the cube texture as an InternalTexture
  12548. */
  12549. 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;
  12550. /**
  12551. * Creates a new raw cube texture from a specified url
  12552. * @param url defines the url where the data is located
  12553. * @param scene defines the current scene
  12554. * @param size defines the size of the textures
  12555. * @param format defines the format of the data
  12556. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12557. * @param noMipmap defines if the engine should avoid generating the mip levels
  12558. * @param callback defines a callback used to extract texture data from loaded data
  12559. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12560. * @param onLoad defines a callback called when texture is loaded
  12561. * @param onError defines a callback called if there is an error
  12562. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12563. * @param invertY defines if data must be stored with Y axis inverted
  12564. * @returns the cube texture as an InternalTexture
  12565. */
  12566. 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;
  12567. /**
  12568. * Creates a new raw 3D texture
  12569. * @param data defines the data used to create the texture
  12570. * @param width defines the width of the texture
  12571. * @param height defines the height of the texture
  12572. * @param depth defines the depth of the texture
  12573. * @param format defines the format of the texture
  12574. * @param generateMipMaps defines if the engine must generate mip levels
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12577. * @param compression defines the compressed used (can be null)
  12578. * @param textureType defines the compressed used (can be null)
  12579. * @returns a new raw 3D texture (stored in an InternalTexture)
  12580. */
  12581. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12582. /**
  12583. * Update a raw 3D texture
  12584. * @param texture defines the texture to update
  12585. * @param data defines the data to store
  12586. * @param format defines the data format
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. */
  12589. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12590. /**
  12591. * Update a raw 3D texture
  12592. * @param texture defines the texture to update
  12593. * @param data defines the data to store
  12594. * @param format defines the data format
  12595. * @param invertY defines if data must be stored with Y axis inverted
  12596. * @param compression defines the used compression (can be null)
  12597. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12598. */
  12599. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12600. }
  12601. }
  12602. }
  12603. declare module "babylonjs/Materials/Textures/rawTexture" {
  12604. import { Scene } from "babylonjs/scene";
  12605. import { Texture } from "babylonjs/Materials/Textures/texture";
  12606. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12607. /**
  12608. * Raw texture can help creating a texture directly from an array of data.
  12609. * This can be super useful if you either get the data from an uncompressed source or
  12610. * if you wish to create your texture pixel by pixel.
  12611. */
  12612. export class RawTexture extends Texture {
  12613. /**
  12614. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12615. */
  12616. format: number;
  12617. private _engine;
  12618. /**
  12619. * Instantiates a new RawTexture.
  12620. * Raw texture can help creating a texture directly from an array of data.
  12621. * This can be super useful if you either get the data from an uncompressed source or
  12622. * if you wish to create your texture pixel by pixel.
  12623. * @param data define the array of data to use to create the texture
  12624. * @param width define the width of the texture
  12625. * @param height define the height of the texture
  12626. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12627. * @param scene define the scene the texture belongs to
  12628. * @param generateMipMaps define whether mip maps should be generated or not
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12632. */
  12633. constructor(data: ArrayBufferView, width: number, height: number,
  12634. /**
  12635. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12636. */
  12637. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12638. /**
  12639. * Updates the texture underlying data.
  12640. * @param data Define the new data of the texture
  12641. */
  12642. update(data: ArrayBufferView): void;
  12643. /**
  12644. * Creates a luminance 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. * @returns the luminance texture
  12653. */
  12654. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12655. /**
  12656. * Creates a luminance alpha texture from some data.
  12657. * @param data Define the texture data
  12658. * @param width Define the width of the texture
  12659. * @param height Define the height of the texture
  12660. * @param scene Define the scene the texture belongs to
  12661. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12662. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12663. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12664. * @returns the luminance alpha texture
  12665. */
  12666. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12667. /**
  12668. * Creates an alpha texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the alpha texture
  12677. */
  12678. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates a RGB texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12689. * @returns the RGB alpha texture
  12690. */
  12691. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12692. /**
  12693. * Creates a RGBA texture from some data.
  12694. * @param data Define the texture data
  12695. * @param width Define the width of the texture
  12696. * @param height Define the height of the texture
  12697. * @param scene Define the scene the texture belongs to
  12698. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12699. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12700. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12701. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12702. * @returns the RGBA texture
  12703. */
  12704. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12705. /**
  12706. * Creates a R texture from some data.
  12707. * @param data Define the texture data
  12708. * @param width Define the width of the texture
  12709. * @param height Define the height of the texture
  12710. * @param scene Define the scene the texture belongs to
  12711. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12714. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12715. * @returns the R texture
  12716. */
  12717. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12718. }
  12719. }
  12720. declare module "babylonjs/Maths/math.size" {
  12721. /**
  12722. * Interface for the size containing width and height
  12723. */
  12724. export interface ISize {
  12725. /**
  12726. * Width
  12727. */
  12728. width: number;
  12729. /**
  12730. * Heighht
  12731. */
  12732. height: number;
  12733. }
  12734. /**
  12735. * Size containing widht and height
  12736. */
  12737. export class Size implements ISize {
  12738. /**
  12739. * Width
  12740. */
  12741. width: number;
  12742. /**
  12743. * Height
  12744. */
  12745. height: number;
  12746. /**
  12747. * Creates a Size object from the given width and height (floats).
  12748. * @param width width of the new size
  12749. * @param height height of the new size
  12750. */
  12751. constructor(width: number, height: number);
  12752. /**
  12753. * Returns a string with the Size width and height
  12754. * @returns a string with the Size width and height
  12755. */
  12756. toString(): string;
  12757. /**
  12758. * "Size"
  12759. * @returns the string "Size"
  12760. */
  12761. getClassName(): string;
  12762. /**
  12763. * Returns the Size hash code.
  12764. * @returns a hash code for a unique width and height
  12765. */
  12766. getHashCode(): number;
  12767. /**
  12768. * Updates the current size from the given one.
  12769. * @param src the given size
  12770. */
  12771. copyFrom(src: Size): void;
  12772. /**
  12773. * Updates in place the current Size from the given floats.
  12774. * @param width width of the new size
  12775. * @param height height of the new size
  12776. * @returns the updated Size.
  12777. */
  12778. copyFromFloats(width: number, height: number): Size;
  12779. /**
  12780. * Updates in place the current Size from the given floats.
  12781. * @param width width to set
  12782. * @param height height to set
  12783. * @returns the updated Size.
  12784. */
  12785. set(width: number, height: number): Size;
  12786. /**
  12787. * Multiplies the width and height by numbers
  12788. * @param w factor to multiple the width by
  12789. * @param h factor to multiple the height by
  12790. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12791. */
  12792. multiplyByFloats(w: number, h: number): Size;
  12793. /**
  12794. * Clones the size
  12795. * @returns a new Size copied from the given one.
  12796. */
  12797. clone(): Size;
  12798. /**
  12799. * True if the current Size and the given one width and height are strictly equal.
  12800. * @param other the other size to compare against
  12801. * @returns True if the current Size and the given one width and height are strictly equal.
  12802. */
  12803. equals(other: Size): boolean;
  12804. /**
  12805. * The surface of the Size : width * height (float).
  12806. */
  12807. readonly surface: number;
  12808. /**
  12809. * Create a new size of zero
  12810. * @returns a new Size set to (0.0, 0.0)
  12811. */
  12812. static Zero(): Size;
  12813. /**
  12814. * Sums the width and height of two sizes
  12815. * @param otherSize size to add to this size
  12816. * @returns a new Size set as the addition result of the current Size and the given one.
  12817. */
  12818. add(otherSize: Size): Size;
  12819. /**
  12820. * Subtracts the width and height of two
  12821. * @param otherSize size to subtract to this size
  12822. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12823. */
  12824. subtract(otherSize: Size): Size;
  12825. /**
  12826. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12827. * @param start starting size to lerp between
  12828. * @param end end size to lerp between
  12829. * @param amount amount to lerp between the start and end values
  12830. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12831. */
  12832. static Lerp(start: Size, end: Size, amount: number): Size;
  12833. }
  12834. }
  12835. declare module "babylonjs/Animations/runtimeAnimation" {
  12836. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12837. import { Animatable } from "babylonjs/Animations/animatable";
  12838. import { Scene } from "babylonjs/scene";
  12839. /**
  12840. * Defines a runtime animation
  12841. */
  12842. export class RuntimeAnimation {
  12843. private _events;
  12844. /**
  12845. * The current frame of the runtime animation
  12846. */
  12847. private _currentFrame;
  12848. /**
  12849. * The animation used by the runtime animation
  12850. */
  12851. private _animation;
  12852. /**
  12853. * The target of the runtime animation
  12854. */
  12855. private _target;
  12856. /**
  12857. * The initiating animatable
  12858. */
  12859. private _host;
  12860. /**
  12861. * The original value of the runtime animation
  12862. */
  12863. private _originalValue;
  12864. /**
  12865. * The original blend value of the runtime animation
  12866. */
  12867. private _originalBlendValue;
  12868. /**
  12869. * The offsets cache of the runtime animation
  12870. */
  12871. private _offsetsCache;
  12872. /**
  12873. * The high limits cache of the runtime animation
  12874. */
  12875. private _highLimitsCache;
  12876. /**
  12877. * Specifies if the runtime animation has been stopped
  12878. */
  12879. private _stopped;
  12880. /**
  12881. * The blending factor of the runtime animation
  12882. */
  12883. private _blendingFactor;
  12884. /**
  12885. * The BabylonJS scene
  12886. */
  12887. private _scene;
  12888. /**
  12889. * The current value of the runtime animation
  12890. */
  12891. private _currentValue;
  12892. /** @hidden */
  12893. _animationState: _IAnimationState;
  12894. /**
  12895. * The active target of the runtime animation
  12896. */
  12897. private _activeTargets;
  12898. private _currentActiveTarget;
  12899. private _directTarget;
  12900. /**
  12901. * The target path of the runtime animation
  12902. */
  12903. private _targetPath;
  12904. /**
  12905. * The weight of the runtime animation
  12906. */
  12907. private _weight;
  12908. /**
  12909. * The ratio offset of the runtime animation
  12910. */
  12911. private _ratioOffset;
  12912. /**
  12913. * The previous delay of the runtime animation
  12914. */
  12915. private _previousDelay;
  12916. /**
  12917. * The previous ratio of the runtime animation
  12918. */
  12919. private _previousRatio;
  12920. private _enableBlending;
  12921. private _keys;
  12922. private _minFrame;
  12923. private _maxFrame;
  12924. private _minValue;
  12925. private _maxValue;
  12926. private _targetIsArray;
  12927. /**
  12928. * Gets the current frame of the runtime animation
  12929. */
  12930. readonly currentFrame: number;
  12931. /**
  12932. * Gets the weight of the runtime animation
  12933. */
  12934. readonly weight: number;
  12935. /**
  12936. * Gets the current value of the runtime animation
  12937. */
  12938. readonly currentValue: any;
  12939. /**
  12940. * Gets the target path of the runtime animation
  12941. */
  12942. readonly targetPath: string;
  12943. /**
  12944. * Gets the actual target of the runtime animation
  12945. */
  12946. readonly target: any;
  12947. /** @hidden */
  12948. _onLoop: () => void;
  12949. /**
  12950. * Create a new RuntimeAnimation object
  12951. * @param target defines the target of the animation
  12952. * @param animation defines the source animation object
  12953. * @param scene defines the hosting scene
  12954. * @param host defines the initiating Animatable
  12955. */
  12956. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12957. private _preparePath;
  12958. /**
  12959. * Gets the animation from the runtime animation
  12960. */
  12961. readonly animation: Animation;
  12962. /**
  12963. * Resets the runtime animation to the beginning
  12964. * @param restoreOriginal defines whether to restore the target property to the original value
  12965. */
  12966. reset(restoreOriginal?: boolean): void;
  12967. /**
  12968. * Specifies if the runtime animation is stopped
  12969. * @returns Boolean specifying if the runtime animation is stopped
  12970. */
  12971. isStopped(): boolean;
  12972. /**
  12973. * Disposes of the runtime animation
  12974. */
  12975. dispose(): void;
  12976. /**
  12977. * Apply the interpolated value to the target
  12978. * @param currentValue defines the value computed by the animation
  12979. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12980. */
  12981. setValue(currentValue: any, weight: number): void;
  12982. private _getOriginalValues;
  12983. private _setValue;
  12984. /**
  12985. * Gets the loop pmode of the runtime animation
  12986. * @returns Loop Mode
  12987. */
  12988. private _getCorrectLoopMode;
  12989. /**
  12990. * Move the current animation to a given frame
  12991. * @param frame defines the frame to move to
  12992. */
  12993. goToFrame(frame: number): void;
  12994. /**
  12995. * @hidden Internal use only
  12996. */
  12997. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12998. /**
  12999. * Execute the current animation
  13000. * @param delay defines the delay to add to the current frame
  13001. * @param from defines the lower bound of the animation range
  13002. * @param to defines the upper bound of the animation range
  13003. * @param loop defines if the current animation must loop
  13004. * @param speedRatio defines the current speed ratio
  13005. * @param weight defines the weight of the animation (default is -1 so no weight)
  13006. * @param onLoop optional callback called when animation loops
  13007. * @returns a boolean indicating if the animation is running
  13008. */
  13009. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13010. }
  13011. }
  13012. declare module "babylonjs/Animations/animatable" {
  13013. import { Animation } from "babylonjs/Animations/animation";
  13014. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13015. import { Nullable } from "babylonjs/types";
  13016. import { Observable } from "babylonjs/Misc/observable";
  13017. import { Scene } from "babylonjs/scene";
  13018. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13019. import { Node } from "babylonjs/node";
  13020. /**
  13021. * Class used to store an actual running animation
  13022. */
  13023. export class Animatable {
  13024. /** defines the target object */
  13025. target: any;
  13026. /** defines the starting frame number (default is 0) */
  13027. fromFrame: number;
  13028. /** defines the ending frame number (default is 100) */
  13029. toFrame: number;
  13030. /** defines if the animation must loop (default is false) */
  13031. loopAnimation: boolean;
  13032. /** defines a callback to call when animation ends if it is not looping */
  13033. onAnimationEnd?: (() => void) | null | undefined;
  13034. /** defines a callback to call when animation loops */
  13035. onAnimationLoop?: (() => void) | null | undefined;
  13036. private _localDelayOffset;
  13037. private _pausedDelay;
  13038. private _runtimeAnimations;
  13039. private _paused;
  13040. private _scene;
  13041. private _speedRatio;
  13042. private _weight;
  13043. private _syncRoot;
  13044. /**
  13045. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13046. * This will only apply for non looping animation (default is true)
  13047. */
  13048. disposeOnEnd: boolean;
  13049. /**
  13050. * Gets a boolean indicating if the animation has started
  13051. */
  13052. animationStarted: boolean;
  13053. /**
  13054. * Observer raised when the animation ends
  13055. */
  13056. onAnimationEndObservable: Observable<Animatable>;
  13057. /**
  13058. * Observer raised when the animation loops
  13059. */
  13060. onAnimationLoopObservable: Observable<Animatable>;
  13061. /**
  13062. * Gets the root Animatable used to synchronize and normalize animations
  13063. */
  13064. readonly syncRoot: Nullable<Animatable>;
  13065. /**
  13066. * Gets the current frame of the first RuntimeAnimation
  13067. * Used to synchronize Animatables
  13068. */
  13069. readonly masterFrame: number;
  13070. /**
  13071. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13072. */
  13073. weight: number;
  13074. /**
  13075. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13076. */
  13077. speedRatio: number;
  13078. /**
  13079. * Creates a new Animatable
  13080. * @param scene defines the hosting scene
  13081. * @param target defines the target object
  13082. * @param fromFrame defines the starting frame number (default is 0)
  13083. * @param toFrame defines the ending frame number (default is 100)
  13084. * @param loopAnimation defines if the animation must loop (default is false)
  13085. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13086. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13087. * @param animations defines a group of animation to add to the new Animatable
  13088. * @param onAnimationLoop defines a callback to call when animation loops
  13089. */
  13090. constructor(scene: Scene,
  13091. /** defines the target object */
  13092. target: any,
  13093. /** defines the starting frame number (default is 0) */
  13094. fromFrame?: number,
  13095. /** defines the ending frame number (default is 100) */
  13096. toFrame?: number,
  13097. /** defines if the animation must loop (default is false) */
  13098. loopAnimation?: boolean, speedRatio?: number,
  13099. /** defines a callback to call when animation ends if it is not looping */
  13100. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13101. /** defines a callback to call when animation loops */
  13102. onAnimationLoop?: (() => void) | null | undefined);
  13103. /**
  13104. * Synchronize and normalize current Animatable with a source Animatable
  13105. * This is useful when using animation weights and when animations are not of the same length
  13106. * @param root defines the root Animatable to synchronize with
  13107. * @returns the current Animatable
  13108. */
  13109. syncWith(root: Animatable): Animatable;
  13110. /**
  13111. * Gets the list of runtime animations
  13112. * @returns an array of RuntimeAnimation
  13113. */
  13114. getAnimations(): RuntimeAnimation[];
  13115. /**
  13116. * Adds more animations to the current animatable
  13117. * @param target defines the target of the animations
  13118. * @param animations defines the new animations to add
  13119. */
  13120. appendAnimations(target: any, animations: Animation[]): void;
  13121. /**
  13122. * Gets the source animation for a specific property
  13123. * @param property defines the propertyu to look for
  13124. * @returns null or the source animation for the given property
  13125. */
  13126. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13127. /**
  13128. * Gets the runtime animation for a specific property
  13129. * @param property defines the propertyu to look for
  13130. * @returns null or the runtime animation for the given property
  13131. */
  13132. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13133. /**
  13134. * Resets the animatable to its original state
  13135. */
  13136. reset(): void;
  13137. /**
  13138. * Allows the animatable to blend with current running animations
  13139. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13140. * @param blendingSpeed defines the blending speed to use
  13141. */
  13142. enableBlending(blendingSpeed: number): void;
  13143. /**
  13144. * Disable animation blending
  13145. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13146. */
  13147. disableBlending(): void;
  13148. /**
  13149. * Jump directly to a given frame
  13150. * @param frame defines the frame to jump to
  13151. */
  13152. goToFrame(frame: number): void;
  13153. /**
  13154. * Pause the animation
  13155. */
  13156. pause(): void;
  13157. /**
  13158. * Restart the animation
  13159. */
  13160. restart(): void;
  13161. private _raiseOnAnimationEnd;
  13162. /**
  13163. * Stop and delete the current animation
  13164. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13165. * @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)
  13166. */
  13167. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13168. /**
  13169. * Wait asynchronously for the animation to end
  13170. * @returns a promise which will be fullfilled when the animation ends
  13171. */
  13172. waitAsync(): Promise<Animatable>;
  13173. /** @hidden */
  13174. _animate(delay: number): boolean;
  13175. }
  13176. module "babylonjs/scene" {
  13177. interface Scene {
  13178. /** @hidden */
  13179. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13180. /** @hidden */
  13181. _processLateAnimationBindingsForMatrices(holder: {
  13182. totalWeight: number;
  13183. animations: RuntimeAnimation[];
  13184. originalValue: Matrix;
  13185. }): any;
  13186. /** @hidden */
  13187. _processLateAnimationBindingsForQuaternions(holder: {
  13188. totalWeight: number;
  13189. animations: RuntimeAnimation[];
  13190. originalValue: Quaternion;
  13191. }, refQuaternion: Quaternion): Quaternion;
  13192. /** @hidden */
  13193. _processLateAnimationBindings(): void;
  13194. /**
  13195. * Will start the animation sequence of a given target
  13196. * @param target defines the target
  13197. * @param from defines from which frame should animation start
  13198. * @param to defines until which frame should animation run.
  13199. * @param weight defines the weight to apply to the animation (1.0 by default)
  13200. * @param loop defines if the animation loops
  13201. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13202. * @param onAnimationEnd defines the function to be executed when the animation ends
  13203. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13204. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13205. * @param onAnimationLoop defines the callback to call when an animation loops
  13206. * @returns the animatable object created for this animation
  13207. */
  13208. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13209. /**
  13210. * Will start the animation sequence of a given target
  13211. * @param target defines the target
  13212. * @param from defines from which frame should animation start
  13213. * @param to defines until which frame should animation run.
  13214. * @param loop defines if the animation loops
  13215. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13216. * @param onAnimationEnd defines the function to be executed when the animation ends
  13217. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13218. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13219. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13220. * @param onAnimationLoop defines the callback to call when an animation loops
  13221. * @returns the animatable object created for this animation
  13222. */
  13223. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13224. /**
  13225. * Will start the animation sequence of a given target and its hierarchy
  13226. * @param target defines the target
  13227. * @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.
  13228. * @param from defines from which frame should animation start
  13229. * @param to defines until which frame should animation run.
  13230. * @param loop defines if the animation loops
  13231. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13232. * @param onAnimationEnd defines the function to be executed when the animation ends
  13233. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13234. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13235. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13236. * @param onAnimationLoop defines the callback to call when an animation loops
  13237. * @returns the list of created animatables
  13238. */
  13239. 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[];
  13240. /**
  13241. * Begin a new animation on a given node
  13242. * @param target defines the target where the animation will take place
  13243. * @param animations defines the list of animations to start
  13244. * @param from defines the initial value
  13245. * @param to defines the final value
  13246. * @param loop defines if you want animation to loop (off by default)
  13247. * @param speedRatio defines the speed ratio to apply to all animations
  13248. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13249. * @param onAnimationLoop defines the callback to call when an animation loops
  13250. * @returns the list of created animatables
  13251. */
  13252. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13253. /**
  13254. * Begin a new animation on a given node and its hierarchy
  13255. * @param target defines the root node where the animation will take place
  13256. * @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.
  13257. * @param animations defines the list of animations to start
  13258. * @param from defines the initial value
  13259. * @param to defines the final value
  13260. * @param loop defines if you want animation to loop (off by default)
  13261. * @param speedRatio defines the speed ratio to apply to all animations
  13262. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13263. * @param onAnimationLoop defines the callback to call when an animation loops
  13264. * @returns the list of animatables created for all nodes
  13265. */
  13266. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13267. /**
  13268. * Gets the animatable associated with a specific target
  13269. * @param target defines the target of the animatable
  13270. * @returns the required animatable if found
  13271. */
  13272. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13273. /**
  13274. * Gets all animatables associated with a given target
  13275. * @param target defines the target to look animatables for
  13276. * @returns an array of Animatables
  13277. */
  13278. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13279. /**
  13280. * Stops and removes all animations that have been applied to the scene
  13281. */
  13282. stopAllAnimations(): void;
  13283. }
  13284. }
  13285. module "babylonjs/Bones/bone" {
  13286. interface Bone {
  13287. /**
  13288. * Copy an animation range from another bone
  13289. * @param source defines the source bone
  13290. * @param rangeName defines the range name to copy
  13291. * @param frameOffset defines the frame offset
  13292. * @param rescaleAsRequired defines if rescaling must be applied if required
  13293. * @param skelDimensionsRatio defines the scaling ratio
  13294. * @returns true if operation was successful
  13295. */
  13296. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13297. }
  13298. }
  13299. }
  13300. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13301. /**
  13302. * Class used to override all child animations of a given target
  13303. */
  13304. export class AnimationPropertiesOverride {
  13305. /**
  13306. * Gets or sets a value indicating if animation blending must be used
  13307. */
  13308. enableBlending: boolean;
  13309. /**
  13310. * Gets or sets the blending speed to use when enableBlending is true
  13311. */
  13312. blendingSpeed: number;
  13313. /**
  13314. * Gets or sets the default loop mode to use
  13315. */
  13316. loopMode: number;
  13317. }
  13318. }
  13319. declare module "babylonjs/Bones/skeleton" {
  13320. import { Bone } from "babylonjs/Bones/bone";
  13321. import { Observable } from "babylonjs/Misc/observable";
  13322. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13323. import { Scene } from "babylonjs/scene";
  13324. import { Nullable } from "babylonjs/types";
  13325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13326. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13327. import { Animatable } from "babylonjs/Animations/animatable";
  13328. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13329. import { Animation } from "babylonjs/Animations/animation";
  13330. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13331. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13332. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13333. /**
  13334. * Class used to handle skinning animations
  13335. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13336. */
  13337. export class Skeleton implements IAnimatable {
  13338. /** defines the skeleton name */
  13339. name: string;
  13340. /** defines the skeleton Id */
  13341. id: string;
  13342. /**
  13343. * Defines the list of child bones
  13344. */
  13345. bones: Bone[];
  13346. /**
  13347. * Defines an estimate of the dimension of the skeleton at rest
  13348. */
  13349. dimensionsAtRest: Vector3;
  13350. /**
  13351. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13352. */
  13353. needInitialSkinMatrix: boolean;
  13354. /**
  13355. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13356. */
  13357. overrideMesh: Nullable<AbstractMesh>;
  13358. /**
  13359. * Gets the list of animations attached to this skeleton
  13360. */
  13361. animations: Array<Animation>;
  13362. private _scene;
  13363. private _isDirty;
  13364. private _transformMatrices;
  13365. private _transformMatrixTexture;
  13366. private _meshesWithPoseMatrix;
  13367. private _animatables;
  13368. private _identity;
  13369. private _synchronizedWithMesh;
  13370. private _ranges;
  13371. private _lastAbsoluteTransformsUpdateId;
  13372. private _canUseTextureForBones;
  13373. private _uniqueId;
  13374. /** @hidden */
  13375. _numBonesWithLinkedTransformNode: number;
  13376. /** @hidden */
  13377. _hasWaitingData: Nullable<boolean>;
  13378. /**
  13379. * Specifies if the skeleton should be serialized
  13380. */
  13381. doNotSerialize: boolean;
  13382. private _useTextureToStoreBoneMatrices;
  13383. /**
  13384. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13385. * Please note that this option is not available if the hardware does not support it
  13386. */
  13387. useTextureToStoreBoneMatrices: boolean;
  13388. private _animationPropertiesOverride;
  13389. /**
  13390. * Gets or sets the animation properties override
  13391. */
  13392. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13393. /**
  13394. * List of inspectable custom properties (used by the Inspector)
  13395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13396. */
  13397. inspectableCustomProperties: IInspectable[];
  13398. /**
  13399. * An observable triggered before computing the skeleton's matrices
  13400. */
  13401. onBeforeComputeObservable: Observable<Skeleton>;
  13402. /**
  13403. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13404. */
  13405. readonly isUsingTextureForMatrices: boolean;
  13406. /**
  13407. * Gets the unique ID of this skeleton
  13408. */
  13409. readonly uniqueId: number;
  13410. /**
  13411. * Creates a new skeleton
  13412. * @param name defines the skeleton name
  13413. * @param id defines the skeleton Id
  13414. * @param scene defines the hosting scene
  13415. */
  13416. constructor(
  13417. /** defines the skeleton name */
  13418. name: string,
  13419. /** defines the skeleton Id */
  13420. id: string, scene: Scene);
  13421. /**
  13422. * Gets the current object class name.
  13423. * @return the class name
  13424. */
  13425. getClassName(): string;
  13426. /**
  13427. * Returns an array containing the root bones
  13428. * @returns an array containing the root bones
  13429. */
  13430. getChildren(): Array<Bone>;
  13431. /**
  13432. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13433. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13434. * @returns a Float32Array containing matrices data
  13435. */
  13436. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13437. /**
  13438. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13439. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13440. * @returns a raw texture containing the data
  13441. */
  13442. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13443. /**
  13444. * Gets the current hosting scene
  13445. * @returns a scene object
  13446. */
  13447. getScene(): Scene;
  13448. /**
  13449. * Gets a string representing the current skeleton data
  13450. * @param fullDetails defines a boolean indicating if we want a verbose version
  13451. * @returns a string representing the current skeleton data
  13452. */
  13453. toString(fullDetails?: boolean): string;
  13454. /**
  13455. * Get bone's index searching by name
  13456. * @param name defines bone's name to search for
  13457. * @return the indice of the bone. Returns -1 if not found
  13458. */
  13459. getBoneIndexByName(name: string): number;
  13460. /**
  13461. * Creater a new animation range
  13462. * @param name defines the name of the range
  13463. * @param from defines the start key
  13464. * @param to defines the end key
  13465. */
  13466. createAnimationRange(name: string, from: number, to: number): void;
  13467. /**
  13468. * Delete a specific animation range
  13469. * @param name defines the name of the range
  13470. * @param deleteFrames defines if frames must be removed as well
  13471. */
  13472. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13473. /**
  13474. * Gets a specific animation range
  13475. * @param name defines the name of the range to look for
  13476. * @returns the requested animation range or null if not found
  13477. */
  13478. getAnimationRange(name: string): Nullable<AnimationRange>;
  13479. /**
  13480. * Gets the list of all animation ranges defined on this skeleton
  13481. * @returns an array
  13482. */
  13483. getAnimationRanges(): Nullable<AnimationRange>[];
  13484. /**
  13485. * Copy animation range from a source skeleton.
  13486. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13487. * @param source defines the source skeleton
  13488. * @param name defines the name of the range to copy
  13489. * @param rescaleAsRequired defines if rescaling must be applied if required
  13490. * @returns true if operation was successful
  13491. */
  13492. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13493. /**
  13494. * Forces the skeleton to go to rest pose
  13495. */
  13496. returnToRest(): void;
  13497. private _getHighestAnimationFrame;
  13498. /**
  13499. * Begin a specific animation range
  13500. * @param name defines the name of the range to start
  13501. * @param loop defines if looping must be turned on (false by default)
  13502. * @param speedRatio defines the speed ratio to apply (1 by default)
  13503. * @param onAnimationEnd defines a callback which will be called when animation will end
  13504. * @returns a new animatable
  13505. */
  13506. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13507. /** @hidden */
  13508. _markAsDirty(): void;
  13509. /** @hidden */
  13510. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13511. /** @hidden */
  13512. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13513. private _computeTransformMatrices;
  13514. /**
  13515. * Build all resources required to render a skeleton
  13516. */
  13517. prepare(): void;
  13518. /**
  13519. * Gets the list of animatables currently running for this skeleton
  13520. * @returns an array of animatables
  13521. */
  13522. getAnimatables(): IAnimatable[];
  13523. /**
  13524. * Clone the current skeleton
  13525. * @param name defines the name of the new skeleton
  13526. * @param id defines the id of the new skeleton
  13527. * @returns the new skeleton
  13528. */
  13529. clone(name: string, id: string): Skeleton;
  13530. /**
  13531. * Enable animation blending for this skeleton
  13532. * @param blendingSpeed defines the blending speed to apply
  13533. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13534. */
  13535. enableBlending(blendingSpeed?: number): void;
  13536. /**
  13537. * Releases all resources associated with the current skeleton
  13538. */
  13539. dispose(): void;
  13540. /**
  13541. * Serialize the skeleton in a JSON object
  13542. * @returns a JSON object
  13543. */
  13544. serialize(): any;
  13545. /**
  13546. * Creates a new skeleton from serialized data
  13547. * @param parsedSkeleton defines the serialized data
  13548. * @param scene defines the hosting scene
  13549. * @returns a new skeleton
  13550. */
  13551. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13552. /**
  13553. * Compute all node absolute transforms
  13554. * @param forceUpdate defines if computation must be done even if cache is up to date
  13555. */
  13556. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13557. /**
  13558. * Gets the root pose matrix
  13559. * @returns a matrix
  13560. */
  13561. getPoseMatrix(): Nullable<Matrix>;
  13562. /**
  13563. * Sorts bones per internal index
  13564. */
  13565. sortBones(): void;
  13566. private _sortBones;
  13567. }
  13568. }
  13569. declare module "babylonjs/Bones/bone" {
  13570. import { Skeleton } from "babylonjs/Bones/skeleton";
  13571. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13572. import { Nullable } from "babylonjs/types";
  13573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13575. import { Node } from "babylonjs/node";
  13576. import { Space } from "babylonjs/Maths/math.axis";
  13577. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13578. /**
  13579. * Class used to store bone information
  13580. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13581. */
  13582. export class Bone extends Node {
  13583. /**
  13584. * defines the bone name
  13585. */
  13586. name: string;
  13587. private static _tmpVecs;
  13588. private static _tmpQuat;
  13589. private static _tmpMats;
  13590. /**
  13591. * Gets the list of child bones
  13592. */
  13593. children: Bone[];
  13594. /** Gets the animations associated with this bone */
  13595. animations: import("babylonjs/Animations/animation").Animation[];
  13596. /**
  13597. * Gets or sets bone length
  13598. */
  13599. length: number;
  13600. /**
  13601. * @hidden Internal only
  13602. * Set this value to map this bone to a different index in the transform matrices
  13603. * Set this value to -1 to exclude the bone from the transform matrices
  13604. */
  13605. _index: Nullable<number>;
  13606. private _skeleton;
  13607. private _localMatrix;
  13608. private _restPose;
  13609. private _baseMatrix;
  13610. private _absoluteTransform;
  13611. private _invertedAbsoluteTransform;
  13612. private _parent;
  13613. private _scalingDeterminant;
  13614. private _worldTransform;
  13615. private _localScaling;
  13616. private _localRotation;
  13617. private _localPosition;
  13618. private _needToDecompose;
  13619. private _needToCompose;
  13620. /** @hidden */
  13621. _linkedTransformNode: Nullable<TransformNode>;
  13622. /** @hidden */
  13623. _waitingTransformNodeId: Nullable<string>;
  13624. /** @hidden */
  13625. /** @hidden */
  13626. _matrix: Matrix;
  13627. /**
  13628. * Create a new bone
  13629. * @param name defines the bone name
  13630. * @param skeleton defines the parent skeleton
  13631. * @param parentBone defines the parent (can be null if the bone is the root)
  13632. * @param localMatrix defines the local matrix
  13633. * @param restPose defines the rest pose matrix
  13634. * @param baseMatrix defines the base matrix
  13635. * @param index defines index of the bone in the hiearchy
  13636. */
  13637. constructor(
  13638. /**
  13639. * defines the bone name
  13640. */
  13641. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13642. /**
  13643. * Gets the current object class name.
  13644. * @return the class name
  13645. */
  13646. getClassName(): string;
  13647. /**
  13648. * Gets the parent skeleton
  13649. * @returns a skeleton
  13650. */
  13651. getSkeleton(): Skeleton;
  13652. /**
  13653. * Gets parent bone
  13654. * @returns a bone or null if the bone is the root of the bone hierarchy
  13655. */
  13656. getParent(): Nullable<Bone>;
  13657. /**
  13658. * Returns an array containing the root bones
  13659. * @returns an array containing the root bones
  13660. */
  13661. getChildren(): Array<Bone>;
  13662. /**
  13663. * Sets the parent bone
  13664. * @param parent defines the parent (can be null if the bone is the root)
  13665. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13666. */
  13667. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13668. /**
  13669. * Gets the local matrix
  13670. * @returns a matrix
  13671. */
  13672. getLocalMatrix(): Matrix;
  13673. /**
  13674. * Gets the base matrix (initial matrix which remains unchanged)
  13675. * @returns a matrix
  13676. */
  13677. getBaseMatrix(): Matrix;
  13678. /**
  13679. * Gets the rest pose matrix
  13680. * @returns a matrix
  13681. */
  13682. getRestPose(): Matrix;
  13683. /**
  13684. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13685. */
  13686. getWorldMatrix(): Matrix;
  13687. /**
  13688. * Sets the local matrix to rest pose matrix
  13689. */
  13690. returnToRest(): void;
  13691. /**
  13692. * Gets the inverse of the absolute transform matrix.
  13693. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13694. * @returns a matrix
  13695. */
  13696. getInvertedAbsoluteTransform(): Matrix;
  13697. /**
  13698. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13699. * @returns a matrix
  13700. */
  13701. getAbsoluteTransform(): Matrix;
  13702. /**
  13703. * Links with the given transform node.
  13704. * The local matrix of this bone is copied from the transform node every frame.
  13705. * @param transformNode defines the transform node to link to
  13706. */
  13707. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13708. /**
  13709. * Gets the node used to drive the bone's transformation
  13710. * @returns a transform node or null
  13711. */
  13712. getTransformNode(): Nullable<TransformNode>;
  13713. /** Gets or sets current position (in local space) */
  13714. position: Vector3;
  13715. /** Gets or sets current rotation (in local space) */
  13716. rotation: Vector3;
  13717. /** Gets or sets current rotation quaternion (in local space) */
  13718. rotationQuaternion: Quaternion;
  13719. /** Gets or sets current scaling (in local space) */
  13720. scaling: Vector3;
  13721. /**
  13722. * Gets the animation properties override
  13723. */
  13724. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13725. private _decompose;
  13726. private _compose;
  13727. /**
  13728. * Update the base and local matrices
  13729. * @param matrix defines the new base or local matrix
  13730. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13731. * @param updateLocalMatrix defines if the local matrix should be updated
  13732. */
  13733. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13734. /** @hidden */
  13735. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13736. /**
  13737. * Flag the bone as dirty (Forcing it to update everything)
  13738. */
  13739. markAsDirty(): void;
  13740. /** @hidden */
  13741. _markAsDirtyAndCompose(): void;
  13742. private _markAsDirtyAndDecompose;
  13743. /**
  13744. * Translate the bone in local or world space
  13745. * @param vec The amount to translate the bone
  13746. * @param space The space that the translation is in
  13747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13748. */
  13749. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13750. /**
  13751. * Set the postion of the bone in local or world space
  13752. * @param position The position to set the bone
  13753. * @param space The space that the position is in
  13754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13755. */
  13756. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13757. /**
  13758. * Set the absolute position of the bone (world space)
  13759. * @param position The position to set the bone
  13760. * @param mesh The mesh that this bone is attached to
  13761. */
  13762. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13763. /**
  13764. * Scale the bone on the x, y and z axes (in local space)
  13765. * @param x The amount to scale the bone on the x axis
  13766. * @param y The amount to scale the bone on the y axis
  13767. * @param z The amount to scale the bone on the z axis
  13768. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13769. */
  13770. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13771. /**
  13772. * Set the bone scaling in local space
  13773. * @param scale defines the scaling vector
  13774. */
  13775. setScale(scale: Vector3): void;
  13776. /**
  13777. * Gets the current scaling in local space
  13778. * @returns the current scaling vector
  13779. */
  13780. getScale(): Vector3;
  13781. /**
  13782. * Gets the current scaling in local space and stores it in a target vector
  13783. * @param result defines the target vector
  13784. */
  13785. getScaleToRef(result: Vector3): void;
  13786. /**
  13787. * Set the yaw, pitch, and roll of the bone in local or world space
  13788. * @param yaw The rotation of the bone on the y axis
  13789. * @param pitch The rotation of the bone on the x axis
  13790. * @param roll The rotation of the bone on the z axis
  13791. * @param space The space that the axes of rotation are in
  13792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13793. */
  13794. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13795. /**
  13796. * Add a rotation to the bone on an axis in local or world space
  13797. * @param axis The axis to rotate the bone on
  13798. * @param amount The amount to rotate the bone
  13799. * @param space The space that the axis is in
  13800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13801. */
  13802. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13803. /**
  13804. * Set the rotation of the bone to a particular axis angle in local or world space
  13805. * @param axis The axis to rotate the bone on
  13806. * @param angle The angle that the bone should be rotated to
  13807. * @param space The space that the axis is in
  13808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13809. */
  13810. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13811. /**
  13812. * Set the euler rotation of the bone in local of world space
  13813. * @param rotation The euler rotation that the bone should be set to
  13814. * @param space The space that the rotation is in
  13815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13816. */
  13817. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13818. /**
  13819. * Set the quaternion rotation of the bone in local of world space
  13820. * @param quat The quaternion rotation that the bone should be set to
  13821. * @param space The space that the rotation is in
  13822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13823. */
  13824. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13825. /**
  13826. * Set the rotation matrix of the bone in local of world space
  13827. * @param rotMat The rotation matrix that the bone should be set to
  13828. * @param space The space that the rotation is in
  13829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13830. */
  13831. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13832. private _rotateWithMatrix;
  13833. private _getNegativeRotationToRef;
  13834. /**
  13835. * Get the position of the bone in local or world space
  13836. * @param space The space that the returned position is in
  13837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13838. * @returns The position of the bone
  13839. */
  13840. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13841. /**
  13842. * Copy the position of the bone to a vector3 in local or world space
  13843. * @param space The space that the returned position is in
  13844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13845. * @param result The vector3 to copy the position to
  13846. */
  13847. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13848. /**
  13849. * Get the absolute position of the bone (world space)
  13850. * @param mesh The mesh that this bone is attached to
  13851. * @returns The absolute position of the bone
  13852. */
  13853. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13854. /**
  13855. * Copy the absolute position of the bone (world space) to the result param
  13856. * @param mesh The mesh that this bone is attached to
  13857. * @param result The vector3 to copy the absolute position to
  13858. */
  13859. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13860. /**
  13861. * Compute the absolute transforms of this bone and its children
  13862. */
  13863. computeAbsoluteTransforms(): void;
  13864. /**
  13865. * Get the world direction from an axis that is in the local space of the bone
  13866. * @param localAxis The local direction that is used to compute the world direction
  13867. * @param mesh The mesh that this bone is attached to
  13868. * @returns The world direction
  13869. */
  13870. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13871. /**
  13872. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13873. * @param localAxis The local direction that is used to compute the world direction
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @param result The vector3 that the world direction will be copied to
  13876. */
  13877. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13878. /**
  13879. * Get the euler rotation of the bone in local or world space
  13880. * @param space The space that the rotation should be in
  13881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13882. * @returns The euler rotation
  13883. */
  13884. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13885. /**
  13886. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13887. * @param space The space that the rotation should be in
  13888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13889. * @param result The vector3 that the rotation should be copied to
  13890. */
  13891. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13892. /**
  13893. * Get the quaternion rotation of the bone in either local or world space
  13894. * @param space The space that the rotation should be in
  13895. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13896. * @returns The quaternion rotation
  13897. */
  13898. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13899. /**
  13900. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13901. * @param space The space that the rotation should be in
  13902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13903. * @param result The quaternion that the rotation should be copied to
  13904. */
  13905. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13906. /**
  13907. * Get the rotation matrix of the bone in local or world space
  13908. * @param space The space that the rotation should be in
  13909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13910. * @returns The rotation matrix
  13911. */
  13912. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13913. /**
  13914. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13915. * @param space The space that the rotation should be in
  13916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13917. * @param result The quaternion that the rotation should be copied to
  13918. */
  13919. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13920. /**
  13921. * Get the world position of a point that is in the local space of the bone
  13922. * @param position The local position
  13923. * @param mesh The mesh that this bone is attached to
  13924. * @returns The world position
  13925. */
  13926. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13927. /**
  13928. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13929. * @param position The local position
  13930. * @param mesh The mesh that this bone is attached to
  13931. * @param result The vector3 that the world position should be copied to
  13932. */
  13933. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13934. /**
  13935. * Get the local position of a point that is in world space
  13936. * @param position The world position
  13937. * @param mesh The mesh that this bone is attached to
  13938. * @returns The local position
  13939. */
  13940. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13941. /**
  13942. * Get the local position of a point that is in world space and copy it to the result param
  13943. * @param position The world position
  13944. * @param mesh The mesh that this bone is attached to
  13945. * @param result The vector3 that the local position should be copied to
  13946. */
  13947. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13948. }
  13949. }
  13950. declare module "babylonjs/Meshes/transformNode" {
  13951. import { DeepImmutable } from "babylonjs/types";
  13952. import { Observable } from "babylonjs/Misc/observable";
  13953. import { Nullable } from "babylonjs/types";
  13954. import { Camera } from "babylonjs/Cameras/camera";
  13955. import { Scene } from "babylonjs/scene";
  13956. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13957. import { Node } from "babylonjs/node";
  13958. import { Bone } from "babylonjs/Bones/bone";
  13959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13960. import { Space } from "babylonjs/Maths/math.axis";
  13961. /**
  13962. * 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.
  13963. * @see https://doc.babylonjs.com/how_to/transformnode
  13964. */
  13965. export class TransformNode extends Node {
  13966. /**
  13967. * Object will not rotate to face the camera
  13968. */
  13969. static BILLBOARDMODE_NONE: number;
  13970. /**
  13971. * Object will rotate to face the camera but only on the x axis
  13972. */
  13973. static BILLBOARDMODE_X: number;
  13974. /**
  13975. * Object will rotate to face the camera but only on the y axis
  13976. */
  13977. static BILLBOARDMODE_Y: number;
  13978. /**
  13979. * Object will rotate to face the camera but only on the z axis
  13980. */
  13981. static BILLBOARDMODE_Z: number;
  13982. /**
  13983. * Object will rotate to face the camera
  13984. */
  13985. static BILLBOARDMODE_ALL: number;
  13986. /**
  13987. * Object will rotate to face the camera's position instead of orientation
  13988. */
  13989. static BILLBOARDMODE_USE_POSITION: number;
  13990. private _forward;
  13991. private _forwardInverted;
  13992. private _up;
  13993. private _right;
  13994. private _rightInverted;
  13995. private _position;
  13996. private _rotation;
  13997. private _rotationQuaternion;
  13998. protected _scaling: Vector3;
  13999. protected _isDirty: boolean;
  14000. private _transformToBoneReferal;
  14001. private _isAbsoluteSynced;
  14002. private _billboardMode;
  14003. /**
  14004. * Gets or sets the billboard mode. Default is 0.
  14005. *
  14006. * | Value | Type | Description |
  14007. * | --- | --- | --- |
  14008. * | 0 | BILLBOARDMODE_NONE | |
  14009. * | 1 | BILLBOARDMODE_X | |
  14010. * | 2 | BILLBOARDMODE_Y | |
  14011. * | 4 | BILLBOARDMODE_Z | |
  14012. * | 7 | BILLBOARDMODE_ALL | |
  14013. *
  14014. */
  14015. billboardMode: number;
  14016. private _preserveParentRotationForBillboard;
  14017. /**
  14018. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14019. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14020. */
  14021. preserveParentRotationForBillboard: boolean;
  14022. /**
  14023. * 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
  14024. */
  14025. scalingDeterminant: number;
  14026. private _infiniteDistance;
  14027. /**
  14028. * Gets or sets the distance of the object to max, often used by skybox
  14029. */
  14030. infiniteDistance: boolean;
  14031. /**
  14032. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14033. * By default the system will update normals to compensate
  14034. */
  14035. ignoreNonUniformScaling: boolean;
  14036. /**
  14037. * 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
  14038. */
  14039. reIntegrateRotationIntoRotationQuaternion: boolean;
  14040. /** @hidden */
  14041. _poseMatrix: Nullable<Matrix>;
  14042. /** @hidden */
  14043. _localMatrix: Matrix;
  14044. private _usePivotMatrix;
  14045. private _absolutePosition;
  14046. private _absoluteScaling;
  14047. private _absoluteRotationQuaternion;
  14048. private _pivotMatrix;
  14049. private _pivotMatrixInverse;
  14050. protected _postMultiplyPivotMatrix: boolean;
  14051. protected _isWorldMatrixFrozen: boolean;
  14052. /** @hidden */
  14053. _indexInSceneTransformNodesArray: number;
  14054. /**
  14055. * An event triggered after the world matrix is updated
  14056. */
  14057. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14058. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14059. /**
  14060. * Gets a string identifying the name of the class
  14061. * @returns "TransformNode" string
  14062. */
  14063. getClassName(): string;
  14064. /**
  14065. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14066. */
  14067. position: Vector3;
  14068. /**
  14069. * 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)).
  14070. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14071. */
  14072. rotation: Vector3;
  14073. /**
  14074. * 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)).
  14075. */
  14076. scaling: Vector3;
  14077. /**
  14078. * 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).
  14079. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14080. */
  14081. rotationQuaternion: Nullable<Quaternion>;
  14082. /**
  14083. * The forward direction of that transform in world space.
  14084. */
  14085. readonly forward: Vector3;
  14086. /**
  14087. * The up direction of that transform in world space.
  14088. */
  14089. readonly up: Vector3;
  14090. /**
  14091. * The right direction of that transform in world space.
  14092. */
  14093. readonly right: Vector3;
  14094. /**
  14095. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14096. * @param matrix the matrix to copy the pose from
  14097. * @returns this TransformNode.
  14098. */
  14099. updatePoseMatrix(matrix: Matrix): TransformNode;
  14100. /**
  14101. * Returns the mesh Pose matrix.
  14102. * @returns the pose matrix
  14103. */
  14104. getPoseMatrix(): Matrix;
  14105. /** @hidden */
  14106. _isSynchronized(): boolean;
  14107. /** @hidden */
  14108. _initCache(): void;
  14109. /**
  14110. * Flag the transform node as dirty (Forcing it to update everything)
  14111. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14112. * @returns this transform node
  14113. */
  14114. markAsDirty(property: string): TransformNode;
  14115. /**
  14116. * Returns the current mesh absolute position.
  14117. * Returns a Vector3.
  14118. */
  14119. readonly absolutePosition: Vector3;
  14120. /**
  14121. * Returns the current mesh absolute scaling.
  14122. * Returns a Vector3.
  14123. */
  14124. readonly absoluteScaling: Vector3;
  14125. /**
  14126. * Returns the current mesh absolute rotation.
  14127. * Returns a Quaternion.
  14128. */
  14129. readonly absoluteRotationQuaternion: Quaternion;
  14130. /**
  14131. * Sets a new matrix to apply before all other transformation
  14132. * @param matrix defines the transform matrix
  14133. * @returns the current TransformNode
  14134. */
  14135. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14136. /**
  14137. * Sets a new pivot matrix to the current node
  14138. * @param matrix defines the new pivot matrix to use
  14139. * @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
  14140. * @returns the current TransformNode
  14141. */
  14142. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14143. /**
  14144. * Returns the mesh pivot matrix.
  14145. * Default : Identity.
  14146. * @returns the matrix
  14147. */
  14148. getPivotMatrix(): Matrix;
  14149. /**
  14150. * Instantiate (when possible) or clone that node with its hierarchy
  14151. * @param newParent defines the new parent to use for the instance (or clone)
  14152. * @returns an instance (or a clone) of the current node with its hiearchy
  14153. */
  14154. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14155. /**
  14156. * Prevents the World matrix to be computed any longer
  14157. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14158. * @returns the TransformNode.
  14159. */
  14160. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14161. /**
  14162. * Allows back the World matrix computation.
  14163. * @returns the TransformNode.
  14164. */
  14165. unfreezeWorldMatrix(): this;
  14166. /**
  14167. * True if the World matrix has been frozen.
  14168. */
  14169. readonly isWorldMatrixFrozen: boolean;
  14170. /**
  14171. * Retuns the mesh absolute position in the World.
  14172. * @returns a Vector3.
  14173. */
  14174. getAbsolutePosition(): Vector3;
  14175. /**
  14176. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14177. * @param absolutePosition the absolute position to set
  14178. * @returns the TransformNode.
  14179. */
  14180. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14181. /**
  14182. * Sets the mesh position in its local space.
  14183. * @param vector3 the position to set in localspace
  14184. * @returns the TransformNode.
  14185. */
  14186. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14187. /**
  14188. * Returns the mesh position in the local space from the current World matrix values.
  14189. * @returns a new Vector3.
  14190. */
  14191. getPositionExpressedInLocalSpace(): Vector3;
  14192. /**
  14193. * Translates the mesh along the passed Vector3 in its local space.
  14194. * @param vector3 the distance to translate in localspace
  14195. * @returns the TransformNode.
  14196. */
  14197. locallyTranslate(vector3: Vector3): TransformNode;
  14198. private static _lookAtVectorCache;
  14199. /**
  14200. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14201. * @param targetPoint the position (must be in same space as current mesh) to look at
  14202. * @param yawCor optional yaw (y-axis) correction in radians
  14203. * @param pitchCor optional pitch (x-axis) correction in radians
  14204. * @param rollCor optional roll (z-axis) correction in radians
  14205. * @param space the choosen space of the target
  14206. * @returns the TransformNode.
  14207. */
  14208. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14209. /**
  14210. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14211. * This Vector3 is expressed in the World space.
  14212. * @param localAxis axis to rotate
  14213. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14214. */
  14215. getDirection(localAxis: Vector3): Vector3;
  14216. /**
  14217. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14218. * localAxis is expressed in the mesh local space.
  14219. * result is computed in the Wordl space from the mesh World matrix.
  14220. * @param localAxis axis to rotate
  14221. * @param result the resulting transformnode
  14222. * @returns this TransformNode.
  14223. */
  14224. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14225. /**
  14226. * Sets this transform node rotation to the given local axis.
  14227. * @param localAxis the axis in local space
  14228. * @param yawCor optional yaw (y-axis) correction in radians
  14229. * @param pitchCor optional pitch (x-axis) correction in radians
  14230. * @param rollCor optional roll (z-axis) correction in radians
  14231. * @returns this TransformNode
  14232. */
  14233. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14234. /**
  14235. * Sets a new pivot point to the current node
  14236. * @param point defines the new pivot point to use
  14237. * @param space defines if the point is in world or local space (local by default)
  14238. * @returns the current TransformNode
  14239. */
  14240. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14241. /**
  14242. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14243. * @returns the pivot point
  14244. */
  14245. getPivotPoint(): Vector3;
  14246. /**
  14247. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14248. * @param result the vector3 to store the result
  14249. * @returns this TransformNode.
  14250. */
  14251. getPivotPointToRef(result: Vector3): TransformNode;
  14252. /**
  14253. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14254. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14255. */
  14256. getAbsolutePivotPoint(): Vector3;
  14257. /**
  14258. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14259. * @param result vector3 to store the result
  14260. * @returns this TransformNode.
  14261. */
  14262. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14263. /**
  14264. * Defines the passed node as the parent of the current node.
  14265. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14266. * @see https://doc.babylonjs.com/how_to/parenting
  14267. * @param node the node ot set as the parent
  14268. * @returns this TransformNode.
  14269. */
  14270. setParent(node: Nullable<Node>): TransformNode;
  14271. private _nonUniformScaling;
  14272. /**
  14273. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14274. */
  14275. readonly nonUniformScaling: boolean;
  14276. /** @hidden */
  14277. _updateNonUniformScalingState(value: boolean): boolean;
  14278. /**
  14279. * Attach the current TransformNode to another TransformNode associated with a bone
  14280. * @param bone Bone affecting the TransformNode
  14281. * @param affectedTransformNode TransformNode associated with the bone
  14282. * @returns this object
  14283. */
  14284. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14285. /**
  14286. * Detach the transform node if its associated with a bone
  14287. * @returns this object
  14288. */
  14289. detachFromBone(): TransformNode;
  14290. private static _rotationAxisCache;
  14291. /**
  14292. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14293. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14294. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14295. * The passed axis is also normalized.
  14296. * @param axis the axis to rotate around
  14297. * @param amount the amount to rotate in radians
  14298. * @param space Space to rotate in (Default: local)
  14299. * @returns the TransformNode.
  14300. */
  14301. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14302. /**
  14303. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14304. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14305. * The passed axis is also normalized. .
  14306. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14307. * @param point the point to rotate around
  14308. * @param axis the axis to rotate around
  14309. * @param amount the amount to rotate in radians
  14310. * @returns the TransformNode
  14311. */
  14312. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14313. /**
  14314. * Translates the mesh along the axis vector for the passed distance in the given space.
  14315. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14316. * @param axis the axis to translate in
  14317. * @param distance the distance to translate
  14318. * @param space Space to rotate in (Default: local)
  14319. * @returns the TransformNode.
  14320. */
  14321. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14322. /**
  14323. * Adds a rotation step to the mesh current rotation.
  14324. * x, y, z are Euler angles expressed in radians.
  14325. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14326. * This means this rotation is made in the mesh local space only.
  14327. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14328. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14329. * ```javascript
  14330. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14331. * ```
  14332. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14333. * 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.
  14334. * @param x Rotation to add
  14335. * @param y Rotation to add
  14336. * @param z Rotation to add
  14337. * @returns the TransformNode.
  14338. */
  14339. addRotation(x: number, y: number, z: number): TransformNode;
  14340. /**
  14341. * @hidden
  14342. */
  14343. protected _getEffectiveParent(): Nullable<Node>;
  14344. /**
  14345. * Computes the world matrix of the node
  14346. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14347. * @returns the world matrix
  14348. */
  14349. computeWorldMatrix(force?: boolean): Matrix;
  14350. protected _afterComputeWorldMatrix(): void;
  14351. /**
  14352. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14353. * @param func callback function to add
  14354. *
  14355. * @returns the TransformNode.
  14356. */
  14357. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14358. /**
  14359. * Removes a registered callback function.
  14360. * @param func callback function to remove
  14361. * @returns the TransformNode.
  14362. */
  14363. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14364. /**
  14365. * Gets the position of the current mesh in camera space
  14366. * @param camera defines the camera to use
  14367. * @returns a position
  14368. */
  14369. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14370. /**
  14371. * Returns the distance from the mesh to the active camera
  14372. * @param camera defines the camera to use
  14373. * @returns the distance
  14374. */
  14375. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14376. /**
  14377. * Clone the current transform node
  14378. * @param name Name of the new clone
  14379. * @param newParent New parent for the clone
  14380. * @param doNotCloneChildren Do not clone children hierarchy
  14381. * @returns the new transform node
  14382. */
  14383. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14384. /**
  14385. * Serializes the objects information.
  14386. * @param currentSerializationObject defines the object to serialize in
  14387. * @returns the serialized object
  14388. */
  14389. serialize(currentSerializationObject?: any): any;
  14390. /**
  14391. * Returns a new TransformNode object parsed from the source provided.
  14392. * @param parsedTransformNode is the source.
  14393. * @param scene the scne the object belongs to
  14394. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14395. * @returns a new TransformNode object parsed from the source provided.
  14396. */
  14397. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14398. /**
  14399. * Get all child-transformNodes of this node
  14400. * @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
  14401. * @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
  14402. * @returns an array of TransformNode
  14403. */
  14404. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14405. /**
  14406. * Releases resources associated with this transform node.
  14407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14409. */
  14410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14411. /**
  14412. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14413. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14414. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14415. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14416. * @returns the current mesh
  14417. */
  14418. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14419. private _syncAbsoluteScalingAndRotation;
  14420. }
  14421. }
  14422. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14423. import { Observable } from "babylonjs/Misc/observable";
  14424. import { Nullable } from "babylonjs/types";
  14425. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14426. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14428. import { Ray } from "babylonjs/Culling/ray";
  14429. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14430. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14431. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14432. /**
  14433. * Defines the types of pose enabled controllers that are supported
  14434. */
  14435. export enum PoseEnabledControllerType {
  14436. /**
  14437. * HTC Vive
  14438. */
  14439. VIVE = 0,
  14440. /**
  14441. * Oculus Rift
  14442. */
  14443. OCULUS = 1,
  14444. /**
  14445. * Windows mixed reality
  14446. */
  14447. WINDOWS = 2,
  14448. /**
  14449. * Samsung gear VR
  14450. */
  14451. GEAR_VR = 3,
  14452. /**
  14453. * Google Daydream
  14454. */
  14455. DAYDREAM = 4,
  14456. /**
  14457. * Generic
  14458. */
  14459. GENERIC = 5
  14460. }
  14461. /**
  14462. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14463. */
  14464. export interface MutableGamepadButton {
  14465. /**
  14466. * Value of the button/trigger
  14467. */
  14468. value: number;
  14469. /**
  14470. * If the button/trigger is currently touched
  14471. */
  14472. touched: boolean;
  14473. /**
  14474. * If the button/trigger is currently pressed
  14475. */
  14476. pressed: boolean;
  14477. }
  14478. /**
  14479. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14480. * @hidden
  14481. */
  14482. export interface ExtendedGamepadButton extends GamepadButton {
  14483. /**
  14484. * If the button/trigger is currently pressed
  14485. */
  14486. readonly pressed: boolean;
  14487. /**
  14488. * If the button/trigger is currently touched
  14489. */
  14490. readonly touched: boolean;
  14491. /**
  14492. * Value of the button/trigger
  14493. */
  14494. readonly value: number;
  14495. }
  14496. /** @hidden */
  14497. export interface _GamePadFactory {
  14498. /**
  14499. * Returns wether or not the current gamepad can be created for this type of controller.
  14500. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14501. * @returns true if it can be created, otherwise false
  14502. */
  14503. canCreate(gamepadInfo: any): boolean;
  14504. /**
  14505. * Creates a new instance of the Gamepad.
  14506. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14507. * @returns the new gamepad instance
  14508. */
  14509. create(gamepadInfo: any): Gamepad;
  14510. }
  14511. /**
  14512. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14513. */
  14514. export class PoseEnabledControllerHelper {
  14515. /** @hidden */
  14516. static _ControllerFactories: _GamePadFactory[];
  14517. /** @hidden */
  14518. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14519. /**
  14520. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14521. * @param vrGamepad the gamepad to initialized
  14522. * @returns a vr controller of the type the gamepad identified as
  14523. */
  14524. static InitiateController(vrGamepad: any): Gamepad;
  14525. }
  14526. /**
  14527. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14528. */
  14529. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14530. /**
  14531. * If the controller is used in a webXR session
  14532. */
  14533. isXR: boolean;
  14534. private _deviceRoomPosition;
  14535. private _deviceRoomRotationQuaternion;
  14536. /**
  14537. * The device position in babylon space
  14538. */
  14539. devicePosition: Vector3;
  14540. /**
  14541. * The device rotation in babylon space
  14542. */
  14543. deviceRotationQuaternion: Quaternion;
  14544. /**
  14545. * The scale factor of the device in babylon space
  14546. */
  14547. deviceScaleFactor: number;
  14548. /**
  14549. * (Likely devicePosition should be used instead) The device position in its room space
  14550. */
  14551. position: Vector3;
  14552. /**
  14553. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14554. */
  14555. rotationQuaternion: Quaternion;
  14556. /**
  14557. * The type of controller (Eg. Windows mixed reality)
  14558. */
  14559. controllerType: PoseEnabledControllerType;
  14560. protected _calculatedPosition: Vector3;
  14561. private _calculatedRotation;
  14562. /**
  14563. * The raw pose from the device
  14564. */
  14565. rawPose: DevicePose;
  14566. private _trackPosition;
  14567. private _maxRotationDistFromHeadset;
  14568. private _draggedRoomRotation;
  14569. /**
  14570. * @hidden
  14571. */
  14572. _disableTrackPosition(fixedPosition: Vector3): void;
  14573. /**
  14574. * Internal, the mesh attached to the controller
  14575. * @hidden
  14576. */
  14577. _mesh: Nullable<AbstractMesh>;
  14578. private _poseControlledCamera;
  14579. private _leftHandSystemQuaternion;
  14580. /**
  14581. * Internal, matrix used to convert room space to babylon space
  14582. * @hidden
  14583. */
  14584. _deviceToWorld: Matrix;
  14585. /**
  14586. * Node to be used when casting a ray from the controller
  14587. * @hidden
  14588. */
  14589. _pointingPoseNode: Nullable<TransformNode>;
  14590. /**
  14591. * Name of the child mesh that can be used to cast a ray from the controller
  14592. */
  14593. static readonly POINTING_POSE: string;
  14594. /**
  14595. * Creates a new PoseEnabledController from a gamepad
  14596. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14597. */
  14598. constructor(browserGamepad: any);
  14599. private _workingMatrix;
  14600. /**
  14601. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14602. */
  14603. update(): void;
  14604. /**
  14605. * Updates only the pose device and mesh without doing any button event checking
  14606. */
  14607. protected _updatePoseAndMesh(): void;
  14608. /**
  14609. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14610. * @param poseData raw pose fromthe device
  14611. */
  14612. updateFromDevice(poseData: DevicePose): void;
  14613. /**
  14614. * @hidden
  14615. */
  14616. _meshAttachedObservable: Observable<AbstractMesh>;
  14617. /**
  14618. * Attaches a mesh to the controller
  14619. * @param mesh the mesh to be attached
  14620. */
  14621. attachToMesh(mesh: AbstractMesh): void;
  14622. /**
  14623. * Attaches the controllers mesh to a camera
  14624. * @param camera the camera the mesh should be attached to
  14625. */
  14626. attachToPoseControlledCamera(camera: TargetCamera): void;
  14627. /**
  14628. * Disposes of the controller
  14629. */
  14630. dispose(): void;
  14631. /**
  14632. * The mesh that is attached to the controller
  14633. */
  14634. readonly mesh: Nullable<AbstractMesh>;
  14635. /**
  14636. * Gets the ray of the controller in the direction the controller is pointing
  14637. * @param length the length the resulting ray should be
  14638. * @returns a ray in the direction the controller is pointing
  14639. */
  14640. getForwardRay(length?: number): Ray;
  14641. }
  14642. }
  14643. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14644. import { Observable } from "babylonjs/Misc/observable";
  14645. import { Scene } from "babylonjs/scene";
  14646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14647. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14648. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14649. /**
  14650. * Defines the WebVRController object that represents controllers tracked in 3D space
  14651. */
  14652. export abstract class WebVRController extends PoseEnabledController {
  14653. /**
  14654. * Internal, the default controller model for the controller
  14655. */
  14656. protected _defaultModel: AbstractMesh;
  14657. /**
  14658. * Fired when the trigger state has changed
  14659. */
  14660. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14661. /**
  14662. * Fired when the main button state has changed
  14663. */
  14664. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14665. /**
  14666. * Fired when the secondary button state has changed
  14667. */
  14668. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14669. /**
  14670. * Fired when the pad state has changed
  14671. */
  14672. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14673. /**
  14674. * Fired when controllers stick values have changed
  14675. */
  14676. onPadValuesChangedObservable: Observable<StickValues>;
  14677. /**
  14678. * Array of button availible on the controller
  14679. */
  14680. protected _buttons: Array<MutableGamepadButton>;
  14681. private _onButtonStateChange;
  14682. /**
  14683. * Fired when a controller button's state has changed
  14684. * @param callback the callback containing the button that was modified
  14685. */
  14686. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14687. /**
  14688. * X and Y axis corresponding to the controllers joystick
  14689. */
  14690. pad: StickValues;
  14691. /**
  14692. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14693. */
  14694. hand: string;
  14695. /**
  14696. * The default controller model for the controller
  14697. */
  14698. readonly defaultModel: AbstractMesh;
  14699. /**
  14700. * Creates a new WebVRController from a gamepad
  14701. * @param vrGamepad the gamepad that the WebVRController should be created from
  14702. */
  14703. constructor(vrGamepad: any);
  14704. /**
  14705. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14706. */
  14707. update(): void;
  14708. /**
  14709. * Function to be called when a button is modified
  14710. */
  14711. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14712. /**
  14713. * Loads a mesh and attaches it to the controller
  14714. * @param scene the scene the mesh should be added to
  14715. * @param meshLoaded callback for when the mesh has been loaded
  14716. */
  14717. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14718. private _setButtonValue;
  14719. private _changes;
  14720. private _checkChanges;
  14721. /**
  14722. * Disposes of th webVRCOntroller
  14723. */
  14724. dispose(): void;
  14725. }
  14726. }
  14727. declare module "babylonjs/Lights/hemisphericLight" {
  14728. import { Nullable } from "babylonjs/types";
  14729. import { Scene } from "babylonjs/scene";
  14730. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14731. import { Color3 } from "babylonjs/Maths/math.color";
  14732. import { Effect } from "babylonjs/Materials/effect";
  14733. import { Light } from "babylonjs/Lights/light";
  14734. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14735. /**
  14736. * The HemisphericLight simulates the ambient environment light,
  14737. * so the passed direction is the light reflection direction, not the incoming direction.
  14738. */
  14739. export class HemisphericLight extends Light {
  14740. /**
  14741. * The groundColor is the light in the opposite direction to the one specified during creation.
  14742. * 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.
  14743. */
  14744. groundColor: Color3;
  14745. /**
  14746. * The light reflection direction, not the incoming direction.
  14747. */
  14748. direction: Vector3;
  14749. /**
  14750. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14751. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14752. * The HemisphericLight can't cast shadows.
  14753. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14754. * @param name The friendly name of the light
  14755. * @param direction The direction of the light reflection
  14756. * @param scene The scene the light belongs to
  14757. */
  14758. constructor(name: string, direction: Vector3, scene: Scene);
  14759. protected _buildUniformLayout(): void;
  14760. /**
  14761. * Returns the string "HemisphericLight".
  14762. * @return The class name
  14763. */
  14764. getClassName(): string;
  14765. /**
  14766. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14767. * Returns the updated direction.
  14768. * @param target The target the direction should point to
  14769. * @return The computed direction
  14770. */
  14771. setDirectionToTarget(target: Vector3): Vector3;
  14772. /**
  14773. * Returns the shadow generator associated to the light.
  14774. * @returns Always null for hemispheric lights because it does not support shadows.
  14775. */
  14776. getShadowGenerator(): Nullable<IShadowGenerator>;
  14777. /**
  14778. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14779. * @param effect The effect to update
  14780. * @param lightIndex The index of the light in the effect to update
  14781. * @returns The hemispheric light
  14782. */
  14783. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14784. /**
  14785. * Computes the world matrix of the node
  14786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14787. * @param useWasUpdatedFlag defines a reserved property
  14788. * @returns the world matrix
  14789. */
  14790. computeWorldMatrix(): Matrix;
  14791. /**
  14792. * Returns the integer 3.
  14793. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14794. */
  14795. getTypeID(): number;
  14796. /**
  14797. * Prepares the list of defines specific to the light type.
  14798. * @param defines the list of defines
  14799. * @param lightIndex defines the index of the light for the effect
  14800. */
  14801. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14802. }
  14803. }
  14804. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14805. /** @hidden */
  14806. export var vrMultiviewToSingleviewPixelShader: {
  14807. name: string;
  14808. shader: string;
  14809. };
  14810. }
  14811. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14813. import { Scene } from "babylonjs/scene";
  14814. /**
  14815. * Renders to multiple views with a single draw call
  14816. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14817. */
  14818. export class MultiviewRenderTarget extends RenderTargetTexture {
  14819. /**
  14820. * Creates a multiview render target
  14821. * @param scene scene used with the render target
  14822. * @param size the size of the render target (used for each view)
  14823. */
  14824. constructor(scene: Scene, size?: number | {
  14825. width: number;
  14826. height: number;
  14827. } | {
  14828. ratio: number;
  14829. });
  14830. /**
  14831. * @hidden
  14832. * @param faceIndex the face index, if its a cube texture
  14833. */
  14834. _bindFrameBuffer(faceIndex?: number): void;
  14835. /**
  14836. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14837. * @returns the view count
  14838. */
  14839. getViewCount(): number;
  14840. }
  14841. }
  14842. declare module "babylonjs/Maths/math.frustum" {
  14843. import { Matrix } from "babylonjs/Maths/math.vector";
  14844. import { DeepImmutable } from "babylonjs/types";
  14845. import { Plane } from "babylonjs/Maths/math.plane";
  14846. /**
  14847. * Reprasents a camera frustum
  14848. */
  14849. export class Frustum {
  14850. /**
  14851. * Gets the planes representing the frustum
  14852. * @param transform matrix to be applied to the returned planes
  14853. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14854. */
  14855. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14856. /**
  14857. * Gets the near frustum plane transformed by the transform matrix
  14858. * @param transform transformation matrix to be applied to the resulting frustum plane
  14859. * @param frustumPlane the resuling frustum plane
  14860. */
  14861. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14862. /**
  14863. * Gets the far frustum plane transformed by the transform matrix
  14864. * @param transform transformation matrix to be applied to the resulting frustum plane
  14865. * @param frustumPlane the resuling frustum plane
  14866. */
  14867. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14868. /**
  14869. * Gets the left frustum plane transformed by the transform matrix
  14870. * @param transform transformation matrix to be applied to the resulting frustum plane
  14871. * @param frustumPlane the resuling frustum plane
  14872. */
  14873. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14874. /**
  14875. * Gets the right frustum plane transformed by the transform matrix
  14876. * @param transform transformation matrix to be applied to the resulting frustum plane
  14877. * @param frustumPlane the resuling frustum plane
  14878. */
  14879. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14880. /**
  14881. * Gets the top frustum plane transformed by the transform matrix
  14882. * @param transform transformation matrix to be applied to the resulting frustum plane
  14883. * @param frustumPlane the resuling frustum plane
  14884. */
  14885. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14886. /**
  14887. * Gets the bottom frustum plane transformed by the transform matrix
  14888. * @param transform transformation matrix to be applied to the resulting frustum plane
  14889. * @param frustumPlane the resuling frustum plane
  14890. */
  14891. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14892. /**
  14893. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14894. * @param transform transformation matrix to be applied to the resulting frustum planes
  14895. * @param frustumPlanes the resuling frustum planes
  14896. */
  14897. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14898. }
  14899. }
  14900. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14901. import { Camera } from "babylonjs/Cameras/camera";
  14902. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14903. import { Nullable } from "babylonjs/types";
  14904. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14905. import { Matrix } from "babylonjs/Maths/math.vector";
  14906. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14907. module "babylonjs/Engines/engine" {
  14908. interface Engine {
  14909. /**
  14910. * Creates a new multiview render target
  14911. * @param width defines the width of the texture
  14912. * @param height defines the height of the texture
  14913. * @returns the created multiview texture
  14914. */
  14915. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14916. /**
  14917. * Binds a multiview framebuffer to be drawn to
  14918. * @param multiviewTexture texture to bind
  14919. */
  14920. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14921. }
  14922. }
  14923. module "babylonjs/Cameras/camera" {
  14924. interface Camera {
  14925. /**
  14926. * @hidden
  14927. * 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)
  14928. */
  14929. _useMultiviewToSingleView: boolean;
  14930. /**
  14931. * @hidden
  14932. * 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)
  14933. */
  14934. _multiviewTexture: Nullable<RenderTargetTexture>;
  14935. /**
  14936. * @hidden
  14937. * ensures the multiview texture of the camera exists and has the specified width/height
  14938. * @param width height to set on the multiview texture
  14939. * @param height width to set on the multiview texture
  14940. */
  14941. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14942. }
  14943. }
  14944. module "babylonjs/scene" {
  14945. interface Scene {
  14946. /** @hidden */
  14947. _transformMatrixR: Matrix;
  14948. /** @hidden */
  14949. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14950. /** @hidden */
  14951. _createMultiviewUbo(): void;
  14952. /** @hidden */
  14953. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14954. /** @hidden */
  14955. _renderMultiviewToSingleView(camera: Camera): void;
  14956. }
  14957. }
  14958. }
  14959. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14960. import { Camera } from "babylonjs/Cameras/camera";
  14961. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14962. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14963. import "babylonjs/Engines/Extensions/engine.multiview";
  14964. /**
  14965. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14966. * This will not be used for webXR as it supports displaying texture arrays directly
  14967. */
  14968. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14969. /**
  14970. * Initializes a VRMultiviewToSingleview
  14971. * @param name name of the post process
  14972. * @param camera camera to be applied to
  14973. * @param scaleFactor scaling factor to the size of the output texture
  14974. */
  14975. constructor(name: string, camera: Camera, scaleFactor: number);
  14976. }
  14977. }
  14978. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14979. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14980. import { Nullable } from "babylonjs/types";
  14981. import { Size } from "babylonjs/Maths/math.size";
  14982. import { Observable } from "babylonjs/Misc/observable";
  14983. module "babylonjs/Engines/engine" {
  14984. interface Engine {
  14985. /** @hidden */
  14986. _vrDisplay: any;
  14987. /** @hidden */
  14988. _vrSupported: boolean;
  14989. /** @hidden */
  14990. _oldSize: Size;
  14991. /** @hidden */
  14992. _oldHardwareScaleFactor: number;
  14993. /** @hidden */
  14994. _vrExclusivePointerMode: boolean;
  14995. /** @hidden */
  14996. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14997. /** @hidden */
  14998. _onVRDisplayPointerRestricted: () => void;
  14999. /** @hidden */
  15000. _onVRDisplayPointerUnrestricted: () => void;
  15001. /** @hidden */
  15002. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15003. /** @hidden */
  15004. _onVrDisplayDisconnect: Nullable<() => void>;
  15005. /** @hidden */
  15006. _onVrDisplayPresentChange: Nullable<() => void>;
  15007. /**
  15008. * Observable signaled when VR display mode changes
  15009. */
  15010. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15011. /**
  15012. * Observable signaled when VR request present is complete
  15013. */
  15014. onVRRequestPresentComplete: Observable<boolean>;
  15015. /**
  15016. * Observable signaled when VR request present starts
  15017. */
  15018. onVRRequestPresentStart: Observable<Engine>;
  15019. /**
  15020. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15021. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15022. */
  15023. isInVRExclusivePointerMode: boolean;
  15024. /**
  15025. * Gets a boolean indicating if a webVR device was detected
  15026. * @returns true if a webVR device was detected
  15027. */
  15028. isVRDevicePresent(): boolean;
  15029. /**
  15030. * Gets the current webVR device
  15031. * @returns the current webVR device (or null)
  15032. */
  15033. getVRDevice(): any;
  15034. /**
  15035. * Initializes a webVR display and starts listening to display change events
  15036. * The onVRDisplayChangedObservable will be notified upon these changes
  15037. * @returns A promise containing a VRDisplay and if vr is supported
  15038. */
  15039. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15040. /** @hidden */
  15041. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15042. /**
  15043. * Call this function to switch to webVR mode
  15044. * Will do nothing if webVR is not supported or if there is no webVR device
  15045. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15046. */
  15047. enableVR(): void;
  15048. /** @hidden */
  15049. _onVRFullScreenTriggered(): void;
  15050. }
  15051. }
  15052. }
  15053. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15054. import { Nullable } from "babylonjs/types";
  15055. import { Observable } from "babylonjs/Misc/observable";
  15056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15057. import { Scene } from "babylonjs/scene";
  15058. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15059. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15060. import { Node } from "babylonjs/node";
  15061. import { Ray } from "babylonjs/Culling/ray";
  15062. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15063. import "babylonjs/Engines/Extensions/engine.webVR";
  15064. /**
  15065. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15066. * IMPORTANT!! The data is right-hand data.
  15067. * @export
  15068. * @interface DevicePose
  15069. */
  15070. export interface DevicePose {
  15071. /**
  15072. * The position of the device, values in array are [x,y,z].
  15073. */
  15074. readonly position: Nullable<Float32Array>;
  15075. /**
  15076. * The linearVelocity of the device, values in array are [x,y,z].
  15077. */
  15078. readonly linearVelocity: Nullable<Float32Array>;
  15079. /**
  15080. * The linearAcceleration of the device, values in array are [x,y,z].
  15081. */
  15082. readonly linearAcceleration: Nullable<Float32Array>;
  15083. /**
  15084. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15085. */
  15086. readonly orientation: Nullable<Float32Array>;
  15087. /**
  15088. * The angularVelocity of the device, values in array are [x,y,z].
  15089. */
  15090. readonly angularVelocity: Nullable<Float32Array>;
  15091. /**
  15092. * The angularAcceleration of the device, values in array are [x,y,z].
  15093. */
  15094. readonly angularAcceleration: Nullable<Float32Array>;
  15095. }
  15096. /**
  15097. * Interface representing a pose controlled object in Babylon.
  15098. * A pose controlled object has both regular pose values as well as pose values
  15099. * from an external device such as a VR head mounted display
  15100. */
  15101. export interface PoseControlled {
  15102. /**
  15103. * The position of the object in babylon space.
  15104. */
  15105. position: Vector3;
  15106. /**
  15107. * The rotation quaternion of the object in babylon space.
  15108. */
  15109. rotationQuaternion: Quaternion;
  15110. /**
  15111. * The position of the device in babylon space.
  15112. */
  15113. devicePosition?: Vector3;
  15114. /**
  15115. * The rotation quaternion of the device in babylon space.
  15116. */
  15117. deviceRotationQuaternion: Quaternion;
  15118. /**
  15119. * The raw pose coming from the device.
  15120. */
  15121. rawPose: Nullable<DevicePose>;
  15122. /**
  15123. * The scale of the device to be used when translating from device space to babylon space.
  15124. */
  15125. deviceScaleFactor: number;
  15126. /**
  15127. * Updates the poseControlled values based on the input device pose.
  15128. * @param poseData the pose data to update the object with
  15129. */
  15130. updateFromDevice(poseData: DevicePose): void;
  15131. }
  15132. /**
  15133. * Set of options to customize the webVRCamera
  15134. */
  15135. export interface WebVROptions {
  15136. /**
  15137. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15138. */
  15139. trackPosition?: boolean;
  15140. /**
  15141. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15142. */
  15143. positionScale?: number;
  15144. /**
  15145. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15146. */
  15147. displayName?: string;
  15148. /**
  15149. * Should the native controller meshes be initialized. (default: true)
  15150. */
  15151. controllerMeshes?: boolean;
  15152. /**
  15153. * Creating a default HemiLight only on controllers. (default: true)
  15154. */
  15155. defaultLightingOnControllers?: boolean;
  15156. /**
  15157. * If you don't want to use the default VR button of the helper. (default: false)
  15158. */
  15159. useCustomVRButton?: boolean;
  15160. /**
  15161. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15162. */
  15163. customVRButton?: HTMLButtonElement;
  15164. /**
  15165. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15166. */
  15167. rayLength?: number;
  15168. /**
  15169. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15170. */
  15171. defaultHeight?: number;
  15172. /**
  15173. * If multiview should be used if availible (default: false)
  15174. */
  15175. useMultiview?: boolean;
  15176. }
  15177. /**
  15178. * This represents a WebVR camera.
  15179. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15180. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15181. */
  15182. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15183. private webVROptions;
  15184. /**
  15185. * @hidden
  15186. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15187. */
  15188. _vrDevice: any;
  15189. /**
  15190. * The rawPose of the vrDevice.
  15191. */
  15192. rawPose: Nullable<DevicePose>;
  15193. private _onVREnabled;
  15194. private _specsVersion;
  15195. private _attached;
  15196. private _frameData;
  15197. protected _descendants: Array<Node>;
  15198. private _deviceRoomPosition;
  15199. /** @hidden */
  15200. _deviceRoomRotationQuaternion: Quaternion;
  15201. private _standingMatrix;
  15202. /**
  15203. * Represents device position in babylon space.
  15204. */
  15205. devicePosition: Vector3;
  15206. /**
  15207. * Represents device rotation in babylon space.
  15208. */
  15209. deviceRotationQuaternion: Quaternion;
  15210. /**
  15211. * The scale of the device to be used when translating from device space to babylon space.
  15212. */
  15213. deviceScaleFactor: number;
  15214. private _deviceToWorld;
  15215. private _worldToDevice;
  15216. /**
  15217. * References to the webVR controllers for the vrDevice.
  15218. */
  15219. controllers: Array<WebVRController>;
  15220. /**
  15221. * Emits an event when a controller is attached.
  15222. */
  15223. onControllersAttachedObservable: Observable<WebVRController[]>;
  15224. /**
  15225. * Emits an event when a controller's mesh has been loaded;
  15226. */
  15227. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15228. /**
  15229. * Emits an event when the HMD's pose has been updated.
  15230. */
  15231. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15232. private _poseSet;
  15233. /**
  15234. * If the rig cameras be used as parent instead of this camera.
  15235. */
  15236. rigParenting: boolean;
  15237. private _lightOnControllers;
  15238. private _defaultHeight?;
  15239. /**
  15240. * Instantiates a WebVRFreeCamera.
  15241. * @param name The name of the WebVRFreeCamera
  15242. * @param position The starting anchor position for the camera
  15243. * @param scene The scene the camera belongs to
  15244. * @param webVROptions a set of customizable options for the webVRCamera
  15245. */
  15246. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15247. /**
  15248. * Gets the device distance from the ground in meters.
  15249. * @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.
  15250. */
  15251. deviceDistanceToRoomGround(): number;
  15252. /**
  15253. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15254. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15255. */
  15256. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15257. /**
  15258. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15259. * @returns A promise with a boolean set to if the standing matrix is supported.
  15260. */
  15261. useStandingMatrixAsync(): Promise<boolean>;
  15262. /**
  15263. * Disposes the camera
  15264. */
  15265. dispose(): void;
  15266. /**
  15267. * Gets a vrController by name.
  15268. * @param name The name of the controller to retreive
  15269. * @returns the controller matching the name specified or null if not found
  15270. */
  15271. getControllerByName(name: string): Nullable<WebVRController>;
  15272. private _leftController;
  15273. /**
  15274. * The controller corresponding to the users left hand.
  15275. */
  15276. readonly leftController: Nullable<WebVRController>;
  15277. private _rightController;
  15278. /**
  15279. * The controller corresponding to the users right hand.
  15280. */
  15281. readonly rightController: Nullable<WebVRController>;
  15282. /**
  15283. * Casts a ray forward from the vrCamera's gaze.
  15284. * @param length Length of the ray (default: 100)
  15285. * @returns the ray corresponding to the gaze
  15286. */
  15287. getForwardRay(length?: number): Ray;
  15288. /**
  15289. * @hidden
  15290. * Updates the camera based on device's frame data
  15291. */
  15292. _checkInputs(): void;
  15293. /**
  15294. * Updates the poseControlled values based on the input device pose.
  15295. * @param poseData Pose coming from the device
  15296. */
  15297. updateFromDevice(poseData: DevicePose): void;
  15298. private _htmlElementAttached;
  15299. private _detachIfAttached;
  15300. /**
  15301. * WebVR's attach control will start broadcasting frames to the device.
  15302. * Note that in certain browsers (chrome for example) this function must be called
  15303. * within a user-interaction callback. Example:
  15304. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15305. *
  15306. * @param element html element to attach the vrDevice to
  15307. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15308. */
  15309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15310. /**
  15311. * Detaches the camera from the html element and disables VR
  15312. *
  15313. * @param element html element to detach from
  15314. */
  15315. detachControl(element: HTMLElement): void;
  15316. /**
  15317. * @returns the name of this class
  15318. */
  15319. getClassName(): string;
  15320. /**
  15321. * Calls resetPose on the vrDisplay
  15322. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15323. */
  15324. resetToCurrentRotation(): void;
  15325. /**
  15326. * @hidden
  15327. * Updates the rig cameras (left and right eye)
  15328. */
  15329. _updateRigCameras(): void;
  15330. private _workingVector;
  15331. private _oneVector;
  15332. private _workingMatrix;
  15333. private updateCacheCalled;
  15334. private _correctPositionIfNotTrackPosition;
  15335. /**
  15336. * @hidden
  15337. * Updates the cached values of the camera
  15338. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15339. */
  15340. _updateCache(ignoreParentClass?: boolean): void;
  15341. /**
  15342. * @hidden
  15343. * Get current device position in babylon world
  15344. */
  15345. _computeDevicePosition(): void;
  15346. /**
  15347. * Updates the current device position and rotation in the babylon world
  15348. */
  15349. update(): void;
  15350. /**
  15351. * @hidden
  15352. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15353. * @returns an identity matrix
  15354. */
  15355. _getViewMatrix(): Matrix;
  15356. private _tmpMatrix;
  15357. /**
  15358. * This function is called by the two RIG cameras.
  15359. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15360. * @hidden
  15361. */
  15362. _getWebVRViewMatrix(): Matrix;
  15363. /** @hidden */
  15364. _getWebVRProjectionMatrix(): Matrix;
  15365. private _onGamepadConnectedObserver;
  15366. private _onGamepadDisconnectedObserver;
  15367. private _updateCacheWhenTrackingDisabledObserver;
  15368. /**
  15369. * Initializes the controllers and their meshes
  15370. */
  15371. initControllers(): void;
  15372. }
  15373. }
  15374. declare module "babylonjs/PostProcesses/postProcess" {
  15375. import { Nullable } from "babylonjs/types";
  15376. import { SmartArray } from "babylonjs/Misc/smartArray";
  15377. import { Observable } from "babylonjs/Misc/observable";
  15378. import { Vector2 } from "babylonjs/Maths/math.vector";
  15379. import { Camera } from "babylonjs/Cameras/camera";
  15380. import { Effect } from "babylonjs/Materials/effect";
  15381. import "babylonjs/Shaders/postprocess.vertex";
  15382. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15383. import { Engine } from "babylonjs/Engines/engine";
  15384. import { Color4 } from "babylonjs/Maths/math.color";
  15385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15386. /**
  15387. * Size options for a post process
  15388. */
  15389. export type PostProcessOptions = {
  15390. width: number;
  15391. height: number;
  15392. };
  15393. /**
  15394. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15395. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15396. */
  15397. export class PostProcess {
  15398. /** Name of the PostProcess. */
  15399. name: string;
  15400. /**
  15401. * Gets or sets the unique id of the post process
  15402. */
  15403. uniqueId: number;
  15404. /**
  15405. * Width of the texture to apply the post process on
  15406. */
  15407. width: number;
  15408. /**
  15409. * Height of the texture to apply the post process on
  15410. */
  15411. height: number;
  15412. /**
  15413. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15414. * @hidden
  15415. */
  15416. _outputTexture: Nullable<InternalTexture>;
  15417. /**
  15418. * Sampling mode used by the shader
  15419. * See https://doc.babylonjs.com/classes/3.1/texture
  15420. */
  15421. renderTargetSamplingMode: number;
  15422. /**
  15423. * Clear color to use when screen clearing
  15424. */
  15425. clearColor: Color4;
  15426. /**
  15427. * If the buffer needs to be cleared before applying the post process. (default: true)
  15428. * Should be set to false if shader will overwrite all previous pixels.
  15429. */
  15430. autoClear: boolean;
  15431. /**
  15432. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15433. */
  15434. alphaMode: number;
  15435. /**
  15436. * Sets the setAlphaBlendConstants of the babylon engine
  15437. */
  15438. alphaConstants: Color4;
  15439. /**
  15440. * Animations to be used for the post processing
  15441. */
  15442. animations: import("babylonjs/Animations/animation").Animation[];
  15443. /**
  15444. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15445. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15446. */
  15447. enablePixelPerfectMode: boolean;
  15448. /**
  15449. * Force the postprocess to be applied without taking in account viewport
  15450. */
  15451. forceFullscreenViewport: boolean;
  15452. /**
  15453. * List of inspectable custom properties (used by the Inspector)
  15454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15455. */
  15456. inspectableCustomProperties: IInspectable[];
  15457. /**
  15458. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15459. *
  15460. * | Value | Type | Description |
  15461. * | ----- | ----------------------------------- | ----------- |
  15462. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15463. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15464. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15465. *
  15466. */
  15467. scaleMode: number;
  15468. /**
  15469. * Force textures to be a power of two (default: false)
  15470. */
  15471. alwaysForcePOT: boolean;
  15472. private _samples;
  15473. /**
  15474. * Number of sample textures (default: 1)
  15475. */
  15476. samples: number;
  15477. /**
  15478. * Modify the scale of the post process to be the same as the viewport (default: false)
  15479. */
  15480. adaptScaleToCurrentViewport: boolean;
  15481. private _camera;
  15482. private _scene;
  15483. private _engine;
  15484. private _options;
  15485. private _reusable;
  15486. private _textureType;
  15487. /**
  15488. * Smart array of input and output textures for the post process.
  15489. * @hidden
  15490. */
  15491. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15492. /**
  15493. * The index in _textures that corresponds to the output texture.
  15494. * @hidden
  15495. */
  15496. _currentRenderTextureInd: number;
  15497. private _effect;
  15498. private _samplers;
  15499. private _fragmentUrl;
  15500. private _vertexUrl;
  15501. private _parameters;
  15502. private _scaleRatio;
  15503. protected _indexParameters: any;
  15504. private _shareOutputWithPostProcess;
  15505. private _texelSize;
  15506. private _forcedOutputTexture;
  15507. /**
  15508. * Returns the fragment url or shader name used in the post process.
  15509. * @returns the fragment url or name in the shader store.
  15510. */
  15511. getEffectName(): string;
  15512. /**
  15513. * An event triggered when the postprocess is activated.
  15514. */
  15515. onActivateObservable: Observable<Camera>;
  15516. private _onActivateObserver;
  15517. /**
  15518. * A function that is added to the onActivateObservable
  15519. */
  15520. onActivate: Nullable<(camera: Camera) => void>;
  15521. /**
  15522. * An event triggered when the postprocess changes its size.
  15523. */
  15524. onSizeChangedObservable: Observable<PostProcess>;
  15525. private _onSizeChangedObserver;
  15526. /**
  15527. * A function that is added to the onSizeChangedObservable
  15528. */
  15529. onSizeChanged: (postProcess: PostProcess) => void;
  15530. /**
  15531. * An event triggered when the postprocess applies its effect.
  15532. */
  15533. onApplyObservable: Observable<Effect>;
  15534. private _onApplyObserver;
  15535. /**
  15536. * A function that is added to the onApplyObservable
  15537. */
  15538. onApply: (effect: Effect) => void;
  15539. /**
  15540. * An event triggered before rendering the postprocess
  15541. */
  15542. onBeforeRenderObservable: Observable<Effect>;
  15543. private _onBeforeRenderObserver;
  15544. /**
  15545. * A function that is added to the onBeforeRenderObservable
  15546. */
  15547. onBeforeRender: (effect: Effect) => void;
  15548. /**
  15549. * An event triggered after rendering the postprocess
  15550. */
  15551. onAfterRenderObservable: Observable<Effect>;
  15552. private _onAfterRenderObserver;
  15553. /**
  15554. * A function that is added to the onAfterRenderObservable
  15555. */
  15556. onAfterRender: (efect: Effect) => void;
  15557. /**
  15558. * 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
  15559. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15560. */
  15561. inputTexture: InternalTexture;
  15562. /**
  15563. * Gets the camera which post process is applied to.
  15564. * @returns The camera the post process is applied to.
  15565. */
  15566. getCamera(): Camera;
  15567. /**
  15568. * Gets the texel size of the postprocess.
  15569. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15570. */
  15571. readonly texelSize: Vector2;
  15572. /**
  15573. * Creates a new instance PostProcess
  15574. * @param name The name of the PostProcess.
  15575. * @param fragmentUrl The url of the fragment shader to be used.
  15576. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15577. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15578. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15579. * @param camera The camera to apply the render pass to.
  15580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15581. * @param engine The engine which the post process will be applied. (default: current engine)
  15582. * @param reusable If the post process can be reused on the same frame. (default: false)
  15583. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15584. * @param textureType Type of textures used when performing the post process. (default: 0)
  15585. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15586. * @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
  15587. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15588. */
  15589. constructor(
  15590. /** Name of the PostProcess. */
  15591. 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);
  15592. /**
  15593. * Gets a string idenfifying the name of the class
  15594. * @returns "PostProcess" string
  15595. */
  15596. getClassName(): string;
  15597. /**
  15598. * Gets the engine which this post process belongs to.
  15599. * @returns The engine the post process was enabled with.
  15600. */
  15601. getEngine(): Engine;
  15602. /**
  15603. * The effect that is created when initializing the post process.
  15604. * @returns The created effect corresponding the the postprocess.
  15605. */
  15606. getEffect(): Effect;
  15607. /**
  15608. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15609. * @param postProcess The post process to share the output with.
  15610. * @returns This post process.
  15611. */
  15612. shareOutputWith(postProcess: PostProcess): PostProcess;
  15613. /**
  15614. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15615. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15616. */
  15617. useOwnOutput(): void;
  15618. /**
  15619. * Updates the effect with the current post process compile time values and recompiles the shader.
  15620. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15621. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15622. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15623. * @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
  15624. * @param onCompiled Called when the shader has been compiled.
  15625. * @param onError Called if there is an error when compiling a shader.
  15626. */
  15627. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15628. /**
  15629. * The post process is reusable if it can be used multiple times within one frame.
  15630. * @returns If the post process is reusable
  15631. */
  15632. isReusable(): boolean;
  15633. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15634. markTextureDirty(): void;
  15635. /**
  15636. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15637. * 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.
  15638. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15639. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15640. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15641. * @returns The target texture that was bound to be written to.
  15642. */
  15643. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15644. /**
  15645. * If the post process is supported.
  15646. */
  15647. readonly isSupported: boolean;
  15648. /**
  15649. * The aspect ratio of the output texture.
  15650. */
  15651. readonly aspectRatio: number;
  15652. /**
  15653. * Get a value indicating if the post-process is ready to be used
  15654. * @returns true if the post-process is ready (shader is compiled)
  15655. */
  15656. isReady(): boolean;
  15657. /**
  15658. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15659. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15660. */
  15661. apply(): Nullable<Effect>;
  15662. private _disposeTextures;
  15663. /**
  15664. * Disposes the post process.
  15665. * @param camera The camera to dispose the post process on.
  15666. */
  15667. dispose(camera?: Camera): void;
  15668. }
  15669. }
  15670. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15671. /** @hidden */
  15672. export var kernelBlurVaryingDeclaration: {
  15673. name: string;
  15674. shader: string;
  15675. };
  15676. }
  15677. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15678. /** @hidden */
  15679. export var kernelBlurFragment: {
  15680. name: string;
  15681. shader: string;
  15682. };
  15683. }
  15684. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15685. /** @hidden */
  15686. export var kernelBlurFragment2: {
  15687. name: string;
  15688. shader: string;
  15689. };
  15690. }
  15691. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15692. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15693. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15694. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15695. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15696. /** @hidden */
  15697. export var kernelBlurPixelShader: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15703. /** @hidden */
  15704. export var kernelBlurVertex: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15710. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15711. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15712. /** @hidden */
  15713. export var kernelBlurVertexShader: {
  15714. name: string;
  15715. shader: string;
  15716. };
  15717. }
  15718. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15719. import { Vector2 } from "babylonjs/Maths/math.vector";
  15720. import { Nullable } from "babylonjs/types";
  15721. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15722. import { Camera } from "babylonjs/Cameras/camera";
  15723. import { Effect } from "babylonjs/Materials/effect";
  15724. import { Engine } from "babylonjs/Engines/engine";
  15725. import "babylonjs/Shaders/kernelBlur.fragment";
  15726. import "babylonjs/Shaders/kernelBlur.vertex";
  15727. /**
  15728. * The Blur Post Process which blurs an image based on a kernel and direction.
  15729. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15730. */
  15731. export class BlurPostProcess extends PostProcess {
  15732. /** The direction in which to blur the image. */
  15733. direction: Vector2;
  15734. private blockCompilation;
  15735. protected _kernel: number;
  15736. protected _idealKernel: number;
  15737. protected _packedFloat: boolean;
  15738. private _staticDefines;
  15739. /**
  15740. * Sets the length in pixels of the blur sample region
  15741. */
  15742. /**
  15743. * Gets the length in pixels of the blur sample region
  15744. */
  15745. kernel: number;
  15746. /**
  15747. * Sets wether or not the blur needs to unpack/repack floats
  15748. */
  15749. /**
  15750. * Gets wether or not the blur is unpacking/repacking floats
  15751. */
  15752. packedFloat: boolean;
  15753. /**
  15754. * Creates a new instance BlurPostProcess
  15755. * @param name The name of the effect.
  15756. * @param direction The direction in which to blur the image.
  15757. * @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.
  15758. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15759. * @param camera The camera to apply the render pass to.
  15760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15761. * @param engine The engine which the post process will be applied. (default: current engine)
  15762. * @param reusable If the post process can be reused on the same frame. (default: false)
  15763. * @param textureType Type of textures used when performing the post process. (default: 0)
  15764. * @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)
  15765. */
  15766. constructor(name: string,
  15767. /** The direction in which to blur the image. */
  15768. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15769. /**
  15770. * Updates the effect with the current post process compile time values and recompiles the shader.
  15771. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15772. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15773. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15774. * @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
  15775. * @param onCompiled Called when the shader has been compiled.
  15776. * @param onError Called if there is an error when compiling a shader.
  15777. */
  15778. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15779. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15780. /**
  15781. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15782. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15783. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15784. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15785. * The gaps between physical kernels are compensated for in the weighting of the samples
  15786. * @param idealKernel Ideal blur kernel.
  15787. * @return Nearest best kernel.
  15788. */
  15789. protected _nearestBestKernel(idealKernel: number): number;
  15790. /**
  15791. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15792. * @param x The point on the Gaussian distribution to sample.
  15793. * @return the value of the Gaussian function at x.
  15794. */
  15795. protected _gaussianWeight(x: number): number;
  15796. /**
  15797. * Generates a string that can be used as a floating point number in GLSL.
  15798. * @param x Value to print.
  15799. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15800. * @return GLSL float string.
  15801. */
  15802. protected _glslFloat(x: number, decimalFigures?: number): string;
  15803. }
  15804. }
  15805. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15806. import { Scene } from "babylonjs/scene";
  15807. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15808. import { Plane } from "babylonjs/Maths/math.plane";
  15809. /**
  15810. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15811. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15812. * You can then easily use it as a reflectionTexture on a flat surface.
  15813. * In case the surface is not a plane, please consider relying on reflection probes.
  15814. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15815. */
  15816. export class MirrorTexture extends RenderTargetTexture {
  15817. private scene;
  15818. /**
  15819. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15820. * 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.
  15821. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15822. */
  15823. mirrorPlane: Plane;
  15824. /**
  15825. * Define the blur ratio used to blur the reflection if needed.
  15826. */
  15827. blurRatio: number;
  15828. /**
  15829. * Define the adaptive blur kernel used to blur the reflection if needed.
  15830. * This will autocompute the closest best match for the `blurKernel`
  15831. */
  15832. adaptiveBlurKernel: number;
  15833. /**
  15834. * Define the blur kernel used to blur the reflection if needed.
  15835. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15836. */
  15837. blurKernel: number;
  15838. /**
  15839. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15840. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15841. */
  15842. blurKernelX: number;
  15843. /**
  15844. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15845. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15846. */
  15847. blurKernelY: number;
  15848. private _autoComputeBlurKernel;
  15849. protected _onRatioRescale(): void;
  15850. private _updateGammaSpace;
  15851. private _imageProcessingConfigChangeObserver;
  15852. private _transformMatrix;
  15853. private _mirrorMatrix;
  15854. private _savedViewMatrix;
  15855. private _blurX;
  15856. private _blurY;
  15857. private _adaptiveBlurKernel;
  15858. private _blurKernelX;
  15859. private _blurKernelY;
  15860. private _blurRatio;
  15861. /**
  15862. * Instantiates a Mirror Texture.
  15863. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15864. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15865. * You can then easily use it as a reflectionTexture on a flat surface.
  15866. * In case the surface is not a plane, please consider relying on reflection probes.
  15867. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15868. * @param name
  15869. * @param size
  15870. * @param scene
  15871. * @param generateMipMaps
  15872. * @param type
  15873. * @param samplingMode
  15874. * @param generateDepthBuffer
  15875. */
  15876. constructor(name: string, size: number | {
  15877. width: number;
  15878. height: number;
  15879. } | {
  15880. ratio: number;
  15881. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15882. private _preparePostProcesses;
  15883. /**
  15884. * Clone the mirror texture.
  15885. * @returns the cloned texture
  15886. */
  15887. clone(): MirrorTexture;
  15888. /**
  15889. * Serialize the texture to a JSON representation you could use in Parse later on
  15890. * @returns the serialized JSON representation
  15891. */
  15892. serialize(): any;
  15893. /**
  15894. * Dispose the texture and release its associated resources.
  15895. */
  15896. dispose(): void;
  15897. }
  15898. }
  15899. declare module "babylonjs/Materials/Textures/texture" {
  15900. import { Observable } from "babylonjs/Misc/observable";
  15901. import { Nullable } from "babylonjs/types";
  15902. import { Scene } from "babylonjs/scene";
  15903. import { Matrix } from "babylonjs/Maths/math.vector";
  15904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15905. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15906. import { Engine } from "babylonjs/Engines/engine";
  15907. /**
  15908. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15909. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15910. */
  15911. export class Texture extends BaseTexture {
  15912. /** @hidden */
  15913. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15914. /** @hidden */
  15915. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15916. /** @hidden */
  15917. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15918. /** nearest is mag = nearest and min = nearest and mip = linear */
  15919. static readonly NEAREST_SAMPLINGMODE: number;
  15920. /** nearest is mag = nearest and min = nearest and mip = linear */
  15921. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15923. static readonly BILINEAR_SAMPLINGMODE: number;
  15924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15925. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15926. /** Trilinear is mag = linear and min = linear and mip = linear */
  15927. static readonly TRILINEAR_SAMPLINGMODE: number;
  15928. /** Trilinear is mag = linear and min = linear and mip = linear */
  15929. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15930. /** mag = nearest and min = nearest and mip = nearest */
  15931. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15932. /** mag = nearest and min = linear and mip = nearest */
  15933. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15934. /** mag = nearest and min = linear and mip = linear */
  15935. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15936. /** mag = nearest and min = linear and mip = none */
  15937. static readonly NEAREST_LINEAR: number;
  15938. /** mag = nearest and min = nearest and mip = none */
  15939. static readonly NEAREST_NEAREST: number;
  15940. /** mag = linear and min = nearest and mip = nearest */
  15941. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15942. /** mag = linear and min = nearest and mip = linear */
  15943. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15944. /** mag = linear and min = linear and mip = none */
  15945. static readonly LINEAR_LINEAR: number;
  15946. /** mag = linear and min = nearest and mip = none */
  15947. static readonly LINEAR_NEAREST: number;
  15948. /** Explicit coordinates mode */
  15949. static readonly EXPLICIT_MODE: number;
  15950. /** Spherical coordinates mode */
  15951. static readonly SPHERICAL_MODE: number;
  15952. /** Planar coordinates mode */
  15953. static readonly PLANAR_MODE: number;
  15954. /** Cubic coordinates mode */
  15955. static readonly CUBIC_MODE: number;
  15956. /** Projection coordinates mode */
  15957. static readonly PROJECTION_MODE: number;
  15958. /** Inverse Cubic coordinates mode */
  15959. static readonly SKYBOX_MODE: number;
  15960. /** Inverse Cubic coordinates mode */
  15961. static readonly INVCUBIC_MODE: number;
  15962. /** Equirectangular coordinates mode */
  15963. static readonly EQUIRECTANGULAR_MODE: number;
  15964. /** Equirectangular Fixed coordinates mode */
  15965. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15966. /** Equirectangular Fixed Mirrored coordinates mode */
  15967. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15968. /** Texture is not repeating outside of 0..1 UVs */
  15969. static readonly CLAMP_ADDRESSMODE: number;
  15970. /** Texture is repeating outside of 0..1 UVs */
  15971. static readonly WRAP_ADDRESSMODE: number;
  15972. /** Texture is repeating and mirrored */
  15973. static readonly MIRROR_ADDRESSMODE: number;
  15974. /**
  15975. * 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
  15976. */
  15977. static UseSerializedUrlIfAny: boolean;
  15978. /**
  15979. * Define the url of the texture.
  15980. */
  15981. url: Nullable<string>;
  15982. /**
  15983. * Define an offset on the texture to offset the u coordinates of the UVs
  15984. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15985. */
  15986. uOffset: number;
  15987. /**
  15988. * Define an offset on the texture to offset the v coordinates of the UVs
  15989. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15990. */
  15991. vOffset: number;
  15992. /**
  15993. * Define an offset on the texture to scale the u coordinates of the UVs
  15994. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15995. */
  15996. uScale: number;
  15997. /**
  15998. * Define an offset on the texture to scale the v coordinates of the UVs
  15999. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16000. */
  16001. vScale: number;
  16002. /**
  16003. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16004. * @see http://doc.babylonjs.com/how_to/more_materials
  16005. */
  16006. uAng: number;
  16007. /**
  16008. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16009. * @see http://doc.babylonjs.com/how_to/more_materials
  16010. */
  16011. vAng: number;
  16012. /**
  16013. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16014. * @see http://doc.babylonjs.com/how_to/more_materials
  16015. */
  16016. wAng: number;
  16017. /**
  16018. * Defines the center of rotation (U)
  16019. */
  16020. uRotationCenter: number;
  16021. /**
  16022. * Defines the center of rotation (V)
  16023. */
  16024. vRotationCenter: number;
  16025. /**
  16026. * Defines the center of rotation (W)
  16027. */
  16028. wRotationCenter: number;
  16029. /**
  16030. * Are mip maps generated for this texture or not.
  16031. */
  16032. readonly noMipmap: boolean;
  16033. /**
  16034. * List of inspectable custom properties (used by the Inspector)
  16035. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16036. */
  16037. inspectableCustomProperties: Nullable<IInspectable[]>;
  16038. private _noMipmap;
  16039. /** @hidden */
  16040. _invertY: boolean;
  16041. private _rowGenerationMatrix;
  16042. private _cachedTextureMatrix;
  16043. private _projectionModeMatrix;
  16044. private _t0;
  16045. private _t1;
  16046. private _t2;
  16047. private _cachedUOffset;
  16048. private _cachedVOffset;
  16049. private _cachedUScale;
  16050. private _cachedVScale;
  16051. private _cachedUAng;
  16052. private _cachedVAng;
  16053. private _cachedWAng;
  16054. private _cachedProjectionMatrixId;
  16055. private _cachedCoordinatesMode;
  16056. /** @hidden */
  16057. protected _initialSamplingMode: number;
  16058. /** @hidden */
  16059. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16060. private _deleteBuffer;
  16061. protected _format: Nullable<number>;
  16062. private _delayedOnLoad;
  16063. private _delayedOnError;
  16064. /**
  16065. * Observable triggered once the texture has been loaded.
  16066. */
  16067. onLoadObservable: Observable<Texture>;
  16068. protected _isBlocking: boolean;
  16069. /**
  16070. * Is the texture preventing material to render while loading.
  16071. * If false, a default texture will be used instead of the loading one during the preparation step.
  16072. */
  16073. isBlocking: boolean;
  16074. /**
  16075. * Get the current sampling mode associated with the texture.
  16076. */
  16077. readonly samplingMode: number;
  16078. /**
  16079. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16080. */
  16081. readonly invertY: boolean;
  16082. /**
  16083. * Instantiates a new texture.
  16084. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16085. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16086. * @param url define the url of the picture to load as a texture
  16087. * @param scene define the scene or engine the texture will belong to
  16088. * @param noMipmap define if the texture will require mip maps or not
  16089. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16090. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16091. * @param onLoad define a callback triggered when the texture has been loaded
  16092. * @param onError define a callback triggered when an error occurred during the loading session
  16093. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16094. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16095. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16096. */
  16097. 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);
  16098. /**
  16099. * Update the url (and optional buffer) of this texture if url was null during construction.
  16100. * @param url the url of the texture
  16101. * @param buffer the buffer of the texture (defaults to null)
  16102. * @param onLoad callback called when the texture is loaded (defaults to null)
  16103. */
  16104. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16105. /**
  16106. * Finish the loading sequence of a texture flagged as delayed load.
  16107. * @hidden
  16108. */
  16109. delayLoad(): void;
  16110. private _prepareRowForTextureGeneration;
  16111. /**
  16112. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16113. * @returns the transform matrix of the texture.
  16114. */
  16115. getTextureMatrix(): Matrix;
  16116. /**
  16117. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16118. * @returns The reflection texture transform
  16119. */
  16120. getReflectionTextureMatrix(): Matrix;
  16121. /**
  16122. * Clones the texture.
  16123. * @returns the cloned texture
  16124. */
  16125. clone(): Texture;
  16126. /**
  16127. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16128. * @returns The JSON representation of the texture
  16129. */
  16130. serialize(): any;
  16131. /**
  16132. * Get the current class name of the texture useful for serialization or dynamic coding.
  16133. * @returns "Texture"
  16134. */
  16135. getClassName(): string;
  16136. /**
  16137. * Dispose the texture and release its associated resources.
  16138. */
  16139. dispose(): void;
  16140. /**
  16141. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16142. * @param parsedTexture Define the JSON representation of the texture
  16143. * @param scene Define the scene the parsed texture should be instantiated in
  16144. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16145. * @returns The parsed texture if successful
  16146. */
  16147. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16148. /**
  16149. * Creates a texture from its base 64 representation.
  16150. * @param data Define the base64 payload without the data: prefix
  16151. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16152. * @param scene Define the scene the texture should belong to
  16153. * @param noMipmap Forces the texture to not create mip map information if true
  16154. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16155. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16156. * @param onLoad define a callback triggered when the texture has been loaded
  16157. * @param onError define a callback triggered when an error occurred during the loading session
  16158. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16159. * @returns the created texture
  16160. */
  16161. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16162. /**
  16163. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16164. * @param data Define the base64 payload without the data: prefix
  16165. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16166. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16167. * @param scene Define the scene the texture should belong to
  16168. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16169. * @param noMipmap Forces the texture to not create mip map information if true
  16170. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16171. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16172. * @param onLoad define a callback triggered when the texture has been loaded
  16173. * @param onError define a callback triggered when an error occurred during the loading session
  16174. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16175. * @returns the created texture
  16176. */
  16177. 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;
  16178. }
  16179. }
  16180. declare module "babylonjs/PostProcesses/postProcessManager" {
  16181. import { Nullable } from "babylonjs/types";
  16182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16183. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16184. import { Scene } from "babylonjs/scene";
  16185. /**
  16186. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16187. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16188. */
  16189. export class PostProcessManager {
  16190. private _scene;
  16191. private _indexBuffer;
  16192. private _vertexBuffers;
  16193. /**
  16194. * Creates a new instance PostProcess
  16195. * @param scene The scene that the post process is associated with.
  16196. */
  16197. constructor(scene: Scene);
  16198. private _prepareBuffers;
  16199. private _buildIndexBuffer;
  16200. /**
  16201. * Rebuilds the vertex buffers of the manager.
  16202. * @hidden
  16203. */
  16204. _rebuild(): void;
  16205. /**
  16206. * Prepares a frame to be run through a post process.
  16207. * @param sourceTexture The input texture to the post procesess. (default: null)
  16208. * @param postProcesses An array of post processes to be run. (default: null)
  16209. * @returns True if the post processes were able to be run.
  16210. * @hidden
  16211. */
  16212. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16213. /**
  16214. * Manually render a set of post processes to a texture.
  16215. * @param postProcesses An array of post processes to be run.
  16216. * @param targetTexture The target texture to render to.
  16217. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16218. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16219. * @param lodLevel defines which lod of the texture to render to
  16220. */
  16221. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16222. /**
  16223. * Finalize the result of the output of the postprocesses.
  16224. * @param doNotPresent If true the result will not be displayed to the screen.
  16225. * @param targetTexture The target texture to render to.
  16226. * @param faceIndex The index of the face to bind the target texture to.
  16227. * @param postProcesses The array of post processes to render.
  16228. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16229. * @hidden
  16230. */
  16231. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16232. /**
  16233. * Disposes of the post process manager.
  16234. */
  16235. dispose(): void;
  16236. }
  16237. }
  16238. declare module "babylonjs/Misc/gradients" {
  16239. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16240. /** Interface used by value gradients (color, factor, ...) */
  16241. export interface IValueGradient {
  16242. /**
  16243. * Gets or sets the gradient value (between 0 and 1)
  16244. */
  16245. gradient: number;
  16246. }
  16247. /** Class used to store color4 gradient */
  16248. export class ColorGradient implements IValueGradient {
  16249. /**
  16250. * Gets or sets the gradient value (between 0 and 1)
  16251. */
  16252. gradient: number;
  16253. /**
  16254. * Gets or sets first associated color
  16255. */
  16256. color1: Color4;
  16257. /**
  16258. * Gets or sets second associated color
  16259. */
  16260. color2?: Color4;
  16261. /**
  16262. * Will get a color picked randomly between color1 and color2.
  16263. * If color2 is undefined then color1 will be used
  16264. * @param result defines the target Color4 to store the result in
  16265. */
  16266. getColorToRef(result: Color4): void;
  16267. }
  16268. /** Class used to store color 3 gradient */
  16269. export class Color3Gradient implements IValueGradient {
  16270. /**
  16271. * Gets or sets the gradient value (between 0 and 1)
  16272. */
  16273. gradient: number;
  16274. /**
  16275. * Gets or sets the associated color
  16276. */
  16277. color: Color3;
  16278. }
  16279. /** Class used to store factor gradient */
  16280. export class FactorGradient implements IValueGradient {
  16281. /**
  16282. * Gets or sets the gradient value (between 0 and 1)
  16283. */
  16284. gradient: number;
  16285. /**
  16286. * Gets or sets first associated factor
  16287. */
  16288. factor1: number;
  16289. /**
  16290. * Gets or sets second associated factor
  16291. */
  16292. factor2?: number;
  16293. /**
  16294. * Will get a number picked randomly between factor1 and factor2.
  16295. * If factor2 is undefined then factor1 will be used
  16296. * @returns the picked number
  16297. */
  16298. getFactor(): number;
  16299. }
  16300. /**
  16301. * Helper used to simplify some generic gradient tasks
  16302. */
  16303. export class GradientHelper {
  16304. /**
  16305. * Gets the current gradient from an array of IValueGradient
  16306. * @param ratio defines the current ratio to get
  16307. * @param gradients defines the array of IValueGradient
  16308. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16309. */
  16310. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16311. }
  16312. }
  16313. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16314. import { Scene } from "babylonjs/scene";
  16315. import { ISceneComponent } from "babylonjs/sceneComponent";
  16316. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16317. module "babylonjs/abstractScene" {
  16318. interface AbstractScene {
  16319. /**
  16320. * The list of procedural textures added to the scene
  16321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16322. */
  16323. proceduralTextures: Array<ProceduralTexture>;
  16324. }
  16325. }
  16326. /**
  16327. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16328. * in a given scene.
  16329. */
  16330. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16331. /**
  16332. * The component name helpfull to identify the component in the list of scene components.
  16333. */
  16334. readonly name: string;
  16335. /**
  16336. * The scene the component belongs to.
  16337. */
  16338. scene: Scene;
  16339. /**
  16340. * Creates a new instance of the component for the given scene
  16341. * @param scene Defines the scene to register the component in
  16342. */
  16343. constructor(scene: Scene);
  16344. /**
  16345. * Registers the component in a given scene
  16346. */
  16347. register(): void;
  16348. /**
  16349. * Rebuilds the elements related to this component in case of
  16350. * context lost for instance.
  16351. */
  16352. rebuild(): void;
  16353. /**
  16354. * Disposes the component and the associated ressources.
  16355. */
  16356. dispose(): void;
  16357. private _beforeClear;
  16358. }
  16359. }
  16360. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16361. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16362. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16363. module "babylonjs/Engines/engine" {
  16364. interface Engine {
  16365. /**
  16366. * Creates a new render target cube texture
  16367. * @param size defines the size of the texture
  16368. * @param options defines the options used to create the texture
  16369. * @returns a new render target cube texture stored in an InternalTexture
  16370. */
  16371. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16372. }
  16373. }
  16374. }
  16375. declare module "babylonjs/Shaders/procedural.vertex" {
  16376. /** @hidden */
  16377. export var proceduralVertexShader: {
  16378. name: string;
  16379. shader: string;
  16380. };
  16381. }
  16382. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16383. import { Observable } from "babylonjs/Misc/observable";
  16384. import { Nullable } from "babylonjs/types";
  16385. import { Scene } from "babylonjs/scene";
  16386. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16387. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16388. import { Effect } from "babylonjs/Materials/effect";
  16389. import { Texture } from "babylonjs/Materials/Textures/texture";
  16390. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16391. import "babylonjs/Shaders/procedural.vertex";
  16392. /**
  16393. * 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.
  16394. * This is the base class of any Procedural texture and contains most of the shareable code.
  16395. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16396. */
  16397. export class ProceduralTexture extends Texture {
  16398. isCube: boolean;
  16399. /**
  16400. * Define if the texture is enabled or not (disabled texture will not render)
  16401. */
  16402. isEnabled: boolean;
  16403. /**
  16404. * Define if the texture must be cleared before rendering (default is true)
  16405. */
  16406. autoClear: boolean;
  16407. /**
  16408. * Callback called when the texture is generated
  16409. */
  16410. onGenerated: () => void;
  16411. /**
  16412. * Event raised when the texture is generated
  16413. */
  16414. onGeneratedObservable: Observable<ProceduralTexture>;
  16415. /** @hidden */
  16416. _generateMipMaps: boolean;
  16417. /** @hidden **/
  16418. _effect: Effect;
  16419. /** @hidden */
  16420. _textures: {
  16421. [key: string]: Texture;
  16422. };
  16423. private _size;
  16424. private _currentRefreshId;
  16425. private _refreshRate;
  16426. private _vertexBuffers;
  16427. private _indexBuffer;
  16428. private _uniforms;
  16429. private _samplers;
  16430. private _fragment;
  16431. private _floats;
  16432. private _ints;
  16433. private _floatsArrays;
  16434. private _colors3;
  16435. private _colors4;
  16436. private _vectors2;
  16437. private _vectors3;
  16438. private _matrices;
  16439. private _fallbackTexture;
  16440. private _fallbackTextureUsed;
  16441. private _engine;
  16442. private _cachedDefines;
  16443. private _contentUpdateId;
  16444. private _contentData;
  16445. /**
  16446. * Instantiates a new procedural texture.
  16447. * 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.
  16448. * This is the base class of any Procedural texture and contains most of the shareable code.
  16449. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16450. * @param name Define the name of the texture
  16451. * @param size Define the size of the texture to create
  16452. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16453. * @param scene Define the scene the texture belongs to
  16454. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16455. * @param generateMipMaps Define if the texture should creates mip maps or not
  16456. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16457. */
  16458. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16459. /**
  16460. * The effect that is created when initializing the post process.
  16461. * @returns The created effect corresponding the the postprocess.
  16462. */
  16463. getEffect(): Effect;
  16464. /**
  16465. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16466. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16467. */
  16468. getContent(): Nullable<ArrayBufferView>;
  16469. private _createIndexBuffer;
  16470. /** @hidden */
  16471. _rebuild(): void;
  16472. /**
  16473. * Resets the texture in order to recreate its associated resources.
  16474. * This can be called in case of context loss
  16475. */
  16476. reset(): void;
  16477. protected _getDefines(): string;
  16478. /**
  16479. * Is the texture ready to be used ? (rendered at least once)
  16480. * @returns true if ready, otherwise, false.
  16481. */
  16482. isReady(): boolean;
  16483. /**
  16484. * Resets the refresh counter of the texture and start bak from scratch.
  16485. * Could be useful to regenerate the texture if it is setup to render only once.
  16486. */
  16487. resetRefreshCounter(): void;
  16488. /**
  16489. * Set the fragment shader to use in order to render the texture.
  16490. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16491. */
  16492. setFragment(fragment: any): void;
  16493. /**
  16494. * Define the refresh rate of the texture or the rendering frequency.
  16495. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16496. */
  16497. refreshRate: number;
  16498. /** @hidden */
  16499. _shouldRender(): boolean;
  16500. /**
  16501. * Get the size the texture is rendering at.
  16502. * @returns the size (texture is always squared)
  16503. */
  16504. getRenderSize(): number;
  16505. /**
  16506. * Resize the texture to new value.
  16507. * @param size Define the new size the texture should have
  16508. * @param generateMipMaps Define whether the new texture should create mip maps
  16509. */
  16510. resize(size: number, generateMipMaps: boolean): void;
  16511. private _checkUniform;
  16512. /**
  16513. * Set a texture in the shader program used to render.
  16514. * @param name Define the name of the uniform samplers as defined in the shader
  16515. * @param texture Define the texture to bind to this sampler
  16516. * @return the texture itself allowing "fluent" like uniform updates
  16517. */
  16518. setTexture(name: string, texture: Texture): ProceduralTexture;
  16519. /**
  16520. * Set a float in the shader.
  16521. * @param name Define the name of the uniform as defined in the shader
  16522. * @param value Define the value to give to the uniform
  16523. * @return the texture itself allowing "fluent" like uniform updates
  16524. */
  16525. setFloat(name: string, value: number): ProceduralTexture;
  16526. /**
  16527. * Set a int in the shader.
  16528. * @param name Define the name of the uniform as defined in the shader
  16529. * @param value Define the value to give to the uniform
  16530. * @return the texture itself allowing "fluent" like uniform updates
  16531. */
  16532. setInt(name: string, value: number): ProceduralTexture;
  16533. /**
  16534. * Set an array of floats in the shader.
  16535. * @param name Define the name of the uniform as defined in the shader
  16536. * @param value Define the value to give to the uniform
  16537. * @return the texture itself allowing "fluent" like uniform updates
  16538. */
  16539. setFloats(name: string, value: number[]): ProceduralTexture;
  16540. /**
  16541. * Set a vec3 in the shader from a Color3.
  16542. * @param name Define the name of the uniform as defined in the shader
  16543. * @param value Define the value to give to the uniform
  16544. * @return the texture itself allowing "fluent" like uniform updates
  16545. */
  16546. setColor3(name: string, value: Color3): ProceduralTexture;
  16547. /**
  16548. * Set a vec4 in the shader from a Color4.
  16549. * @param name Define the name of the uniform as defined in the shader
  16550. * @param value Define the value to give to the uniform
  16551. * @return the texture itself allowing "fluent" like uniform updates
  16552. */
  16553. setColor4(name: string, value: Color4): ProceduralTexture;
  16554. /**
  16555. * Set a vec2 in the shader from a Vector2.
  16556. * @param name Define the name of the uniform as defined in the shader
  16557. * @param value Define the value to give to the uniform
  16558. * @return the texture itself allowing "fluent" like uniform updates
  16559. */
  16560. setVector2(name: string, value: Vector2): ProceduralTexture;
  16561. /**
  16562. * Set a vec3 in the shader from a Vector3.
  16563. * @param name Define the name of the uniform as defined in the shader
  16564. * @param value Define the value to give to the uniform
  16565. * @return the texture itself allowing "fluent" like uniform updates
  16566. */
  16567. setVector3(name: string, value: Vector3): ProceduralTexture;
  16568. /**
  16569. * Set a mat4 in the shader from a MAtrix.
  16570. * @param name Define the name of the uniform as defined in the shader
  16571. * @param value Define the value to give to the uniform
  16572. * @return the texture itself allowing "fluent" like uniform updates
  16573. */
  16574. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16575. /**
  16576. * Render the texture to its associated render target.
  16577. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16578. */
  16579. render(useCameraPostProcess?: boolean): void;
  16580. /**
  16581. * Clone the texture.
  16582. * @returns the cloned texture
  16583. */
  16584. clone(): ProceduralTexture;
  16585. /**
  16586. * Dispose the texture and release its asoociated resources.
  16587. */
  16588. dispose(): void;
  16589. }
  16590. }
  16591. declare module "babylonjs/Particles/baseParticleSystem" {
  16592. import { Nullable } from "babylonjs/types";
  16593. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16595. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16596. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16597. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16598. import { Scene } from "babylonjs/scene";
  16599. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16600. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16601. import { Texture } from "babylonjs/Materials/Textures/texture";
  16602. import { Color4 } from "babylonjs/Maths/math.color";
  16603. import { Animation } from "babylonjs/Animations/animation";
  16604. /**
  16605. * This represents the base class for particle system in Babylon.
  16606. * 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.
  16607. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16608. * @example https://doc.babylonjs.com/babylon101/particles
  16609. */
  16610. export class BaseParticleSystem {
  16611. /**
  16612. * Source color is added to the destination color without alpha affecting the result
  16613. */
  16614. static BLENDMODE_ONEONE: number;
  16615. /**
  16616. * Blend current color and particle color using particle’s alpha
  16617. */
  16618. static BLENDMODE_STANDARD: number;
  16619. /**
  16620. * Add current color and particle color multiplied by particle’s alpha
  16621. */
  16622. static BLENDMODE_ADD: number;
  16623. /**
  16624. * Multiply current color with particle color
  16625. */
  16626. static BLENDMODE_MULTIPLY: number;
  16627. /**
  16628. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16629. */
  16630. static BLENDMODE_MULTIPLYADD: number;
  16631. /**
  16632. * List of animations used by the particle system.
  16633. */
  16634. animations: Animation[];
  16635. /**
  16636. * The id of the Particle system.
  16637. */
  16638. id: string;
  16639. /**
  16640. * The friendly name of the Particle system.
  16641. */
  16642. name: string;
  16643. /**
  16644. * The rendering group used by the Particle system to chose when to render.
  16645. */
  16646. renderingGroupId: number;
  16647. /**
  16648. * The emitter represents the Mesh or position we are attaching the particle system to.
  16649. */
  16650. emitter: Nullable<AbstractMesh | Vector3>;
  16651. /**
  16652. * The maximum number of particles to emit per frame
  16653. */
  16654. emitRate: number;
  16655. /**
  16656. * If you want to launch only a few particles at once, that can be done, as well.
  16657. */
  16658. manualEmitCount: number;
  16659. /**
  16660. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16661. */
  16662. updateSpeed: number;
  16663. /**
  16664. * The amount of time the particle system is running (depends of the overall update speed).
  16665. */
  16666. targetStopDuration: number;
  16667. /**
  16668. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16669. */
  16670. disposeOnStop: boolean;
  16671. /**
  16672. * Minimum power of emitting particles.
  16673. */
  16674. minEmitPower: number;
  16675. /**
  16676. * Maximum power of emitting particles.
  16677. */
  16678. maxEmitPower: number;
  16679. /**
  16680. * Minimum life time of emitting particles.
  16681. */
  16682. minLifeTime: number;
  16683. /**
  16684. * Maximum life time of emitting particles.
  16685. */
  16686. maxLifeTime: number;
  16687. /**
  16688. * Minimum Size of emitting particles.
  16689. */
  16690. minSize: number;
  16691. /**
  16692. * Maximum Size of emitting particles.
  16693. */
  16694. maxSize: number;
  16695. /**
  16696. * Minimum scale of emitting particles on X axis.
  16697. */
  16698. minScaleX: number;
  16699. /**
  16700. * Maximum scale of emitting particles on X axis.
  16701. */
  16702. maxScaleX: number;
  16703. /**
  16704. * Minimum scale of emitting particles on Y axis.
  16705. */
  16706. minScaleY: number;
  16707. /**
  16708. * Maximum scale of emitting particles on Y axis.
  16709. */
  16710. maxScaleY: number;
  16711. /**
  16712. * Gets or sets the minimal initial rotation in radians.
  16713. */
  16714. minInitialRotation: number;
  16715. /**
  16716. * Gets or sets the maximal initial rotation in radians.
  16717. */
  16718. maxInitialRotation: number;
  16719. /**
  16720. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16721. */
  16722. minAngularSpeed: number;
  16723. /**
  16724. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16725. */
  16726. maxAngularSpeed: number;
  16727. /**
  16728. * The texture used to render each particle. (this can be a spritesheet)
  16729. */
  16730. particleTexture: Nullable<Texture>;
  16731. /**
  16732. * The layer mask we are rendering the particles through.
  16733. */
  16734. layerMask: number;
  16735. /**
  16736. * This can help using your own shader to render the particle system.
  16737. * The according effect will be created
  16738. */
  16739. customShader: any;
  16740. /**
  16741. * By default particle system starts as soon as they are created. This prevents the
  16742. * automatic start to happen and let you decide when to start emitting particles.
  16743. */
  16744. preventAutoStart: boolean;
  16745. private _noiseTexture;
  16746. /**
  16747. * Gets or sets a texture used to add random noise to particle positions
  16748. */
  16749. noiseTexture: Nullable<ProceduralTexture>;
  16750. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16751. noiseStrength: Vector3;
  16752. /**
  16753. * Callback triggered when the particle animation is ending.
  16754. */
  16755. onAnimationEnd: Nullable<() => void>;
  16756. /**
  16757. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16758. */
  16759. blendMode: number;
  16760. /**
  16761. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16762. * to override the particles.
  16763. */
  16764. forceDepthWrite: boolean;
  16765. /** 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 */
  16766. preWarmCycles: number;
  16767. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16768. preWarmStepOffset: number;
  16769. /**
  16770. * 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)
  16771. */
  16772. spriteCellChangeSpeed: number;
  16773. /**
  16774. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16775. */
  16776. startSpriteCellID: number;
  16777. /**
  16778. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16779. */
  16780. endSpriteCellID: number;
  16781. /**
  16782. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16783. */
  16784. spriteCellWidth: number;
  16785. /**
  16786. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16787. */
  16788. spriteCellHeight: number;
  16789. /**
  16790. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16791. */
  16792. spriteRandomStartCell: boolean;
  16793. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16794. translationPivot: Vector2;
  16795. /** @hidden */
  16796. protected _isAnimationSheetEnabled: boolean;
  16797. /**
  16798. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16799. */
  16800. beginAnimationOnStart: boolean;
  16801. /**
  16802. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16803. */
  16804. beginAnimationFrom: number;
  16805. /**
  16806. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16807. */
  16808. beginAnimationTo: number;
  16809. /**
  16810. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16811. */
  16812. beginAnimationLoop: boolean;
  16813. /**
  16814. * Gets or sets a world offset applied to all particles
  16815. */
  16816. worldOffset: Vector3;
  16817. /**
  16818. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16819. */
  16820. isAnimationSheetEnabled: boolean;
  16821. /**
  16822. * Get hosting scene
  16823. * @returns the scene
  16824. */
  16825. getScene(): Scene;
  16826. /**
  16827. * You can use gravity if you want to give an orientation to your particles.
  16828. */
  16829. gravity: Vector3;
  16830. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16831. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16832. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16833. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16834. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16835. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16836. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16837. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16838. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16839. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16840. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16841. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16842. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16843. /**
  16844. * Defines the delay in milliseconds before starting the system (0 by default)
  16845. */
  16846. startDelay: number;
  16847. /**
  16848. * Gets the current list of drag gradients.
  16849. * You must use addDragGradient and removeDragGradient to udpate this list
  16850. * @returns the list of drag gradients
  16851. */
  16852. getDragGradients(): Nullable<Array<FactorGradient>>;
  16853. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16854. limitVelocityDamping: number;
  16855. /**
  16856. * Gets the current list of limit velocity gradients.
  16857. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16858. * @returns the list of limit velocity gradients
  16859. */
  16860. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16861. /**
  16862. * Gets the current list of color gradients.
  16863. * You must use addColorGradient and removeColorGradient to udpate this list
  16864. * @returns the list of color gradients
  16865. */
  16866. getColorGradients(): Nullable<Array<ColorGradient>>;
  16867. /**
  16868. * Gets the current list of size gradients.
  16869. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16870. * @returns the list of size gradients
  16871. */
  16872. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16873. /**
  16874. * Gets the current list of color remap gradients.
  16875. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16876. * @returns the list of color remap gradients
  16877. */
  16878. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Gets the current list of alpha remap gradients.
  16881. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16882. * @returns the list of alpha remap gradients
  16883. */
  16884. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16885. /**
  16886. * Gets the current list of life time gradients.
  16887. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16888. * @returns the list of life time gradients
  16889. */
  16890. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Gets the current list of angular speed gradients.
  16893. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16894. * @returns the list of angular speed gradients
  16895. */
  16896. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16897. /**
  16898. * Gets the current list of velocity gradients.
  16899. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16900. * @returns the list of velocity gradients
  16901. */
  16902. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16903. /**
  16904. * Gets the current list of start size gradients.
  16905. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16906. * @returns the list of start size gradients
  16907. */
  16908. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16909. /**
  16910. * Gets the current list of emit rate gradients.
  16911. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16912. * @returns the list of emit rate gradients
  16913. */
  16914. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16917. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16918. */
  16919. direction1: Vector3;
  16920. /**
  16921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16922. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16923. */
  16924. direction2: Vector3;
  16925. /**
  16926. * 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.
  16927. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16928. */
  16929. minEmitBox: Vector3;
  16930. /**
  16931. * 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.
  16932. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16933. */
  16934. maxEmitBox: Vector3;
  16935. /**
  16936. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16937. */
  16938. color1: Color4;
  16939. /**
  16940. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16941. */
  16942. color2: Color4;
  16943. /**
  16944. * Color the particle will have at the end of its lifetime
  16945. */
  16946. colorDead: Color4;
  16947. /**
  16948. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16949. */
  16950. textureMask: Color4;
  16951. /**
  16952. * The particle emitter type defines the emitter used by the particle system.
  16953. * It can be for example box, sphere, or cone...
  16954. */
  16955. particleEmitterType: IParticleEmitterType;
  16956. /** @hidden */
  16957. _isSubEmitter: boolean;
  16958. /**
  16959. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16960. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16961. */
  16962. billboardMode: number;
  16963. protected _isBillboardBased: boolean;
  16964. /**
  16965. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16966. */
  16967. isBillboardBased: boolean;
  16968. /**
  16969. * The scene the particle system belongs to.
  16970. */
  16971. protected _scene: Scene;
  16972. /**
  16973. * Local cache of defines for image processing.
  16974. */
  16975. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16976. /**
  16977. * Default configuration related to image processing available in the standard Material.
  16978. */
  16979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16980. /**
  16981. * Gets the image processing configuration used either in this material.
  16982. */
  16983. /**
  16984. * Sets the Default image processing configuration used either in the this material.
  16985. *
  16986. * If sets to null, the scene one is in use.
  16987. */
  16988. imageProcessingConfiguration: ImageProcessingConfiguration;
  16989. /**
  16990. * Attaches a new image processing configuration to the Standard Material.
  16991. * @param configuration
  16992. */
  16993. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16994. /** @hidden */
  16995. protected _reset(): void;
  16996. /** @hidden */
  16997. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16998. /**
  16999. * Instantiates a particle system.
  17000. * 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.
  17001. * @param name The name of the particle system
  17002. */
  17003. constructor(name: string);
  17004. /**
  17005. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17006. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17007. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17008. * @returns the emitter
  17009. */
  17010. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17011. /**
  17012. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17013. * @param radius The radius of the hemisphere to emit from
  17014. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17015. * @returns the emitter
  17016. */
  17017. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17018. /**
  17019. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17020. * @param radius The radius of the sphere to emit from
  17021. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17022. * @returns the emitter
  17023. */
  17024. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17025. /**
  17026. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17027. * @param radius The radius of the sphere to emit from
  17028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17030. * @returns the emitter
  17031. */
  17032. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17033. /**
  17034. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17035. * @param radius The radius of the emission cylinder
  17036. * @param height The height of the emission cylinder
  17037. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17038. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17039. * @returns the emitter
  17040. */
  17041. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17042. /**
  17043. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17044. * @param radius The radius of the cylinder to emit from
  17045. * @param height The height of the emission cylinder
  17046. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17049. * @returns the emitter
  17050. */
  17051. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17052. /**
  17053. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17054. * @param radius The radius of the cone to emit from
  17055. * @param angle The base angle of the cone
  17056. * @returns the emitter
  17057. */
  17058. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17059. /**
  17060. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17061. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17062. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17063. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17064. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17065. * @returns the emitter
  17066. */
  17067. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17068. }
  17069. }
  17070. declare module "babylonjs/Particles/subEmitter" {
  17071. import { Scene } from "babylonjs/scene";
  17072. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17073. /**
  17074. * Type of sub emitter
  17075. */
  17076. export enum SubEmitterType {
  17077. /**
  17078. * Attached to the particle over it's lifetime
  17079. */
  17080. ATTACHED = 0,
  17081. /**
  17082. * Created when the particle dies
  17083. */
  17084. END = 1
  17085. }
  17086. /**
  17087. * Sub emitter class used to emit particles from an existing particle
  17088. */
  17089. export class SubEmitter {
  17090. /**
  17091. * the particle system to be used by the sub emitter
  17092. */
  17093. particleSystem: ParticleSystem;
  17094. /**
  17095. * Type of the submitter (Default: END)
  17096. */
  17097. type: SubEmitterType;
  17098. /**
  17099. * 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)
  17100. * Note: This only is supported when using an emitter of type Mesh
  17101. */
  17102. inheritDirection: boolean;
  17103. /**
  17104. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17105. */
  17106. inheritedVelocityAmount: number;
  17107. /**
  17108. * Creates a sub emitter
  17109. * @param particleSystem the particle system to be used by the sub emitter
  17110. */
  17111. constructor(
  17112. /**
  17113. * the particle system to be used by the sub emitter
  17114. */
  17115. particleSystem: ParticleSystem);
  17116. /**
  17117. * Clones the sub emitter
  17118. * @returns the cloned sub emitter
  17119. */
  17120. clone(): SubEmitter;
  17121. /**
  17122. * Serialize current object to a JSON object
  17123. * @returns the serialized object
  17124. */
  17125. serialize(): any;
  17126. /** @hidden */
  17127. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17128. /**
  17129. * Creates a new SubEmitter from a serialized JSON version
  17130. * @param serializationObject defines the JSON object to read from
  17131. * @param scene defines the hosting scene
  17132. * @param rootUrl defines the rootUrl for data loading
  17133. * @returns a new SubEmitter
  17134. */
  17135. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17136. /** Release associated resources */
  17137. dispose(): void;
  17138. }
  17139. }
  17140. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17141. /** @hidden */
  17142. export var clipPlaneFragmentDeclaration: {
  17143. name: string;
  17144. shader: string;
  17145. };
  17146. }
  17147. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17148. /** @hidden */
  17149. export var imageProcessingDeclaration: {
  17150. name: string;
  17151. shader: string;
  17152. };
  17153. }
  17154. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17155. /** @hidden */
  17156. export var imageProcessingFunctions: {
  17157. name: string;
  17158. shader: string;
  17159. };
  17160. }
  17161. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17162. /** @hidden */
  17163. export var clipPlaneFragment: {
  17164. name: string;
  17165. shader: string;
  17166. };
  17167. }
  17168. declare module "babylonjs/Shaders/particles.fragment" {
  17169. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17170. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17171. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17172. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17173. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17174. /** @hidden */
  17175. export var particlesPixelShader: {
  17176. name: string;
  17177. shader: string;
  17178. };
  17179. }
  17180. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17181. /** @hidden */
  17182. export var clipPlaneVertexDeclaration: {
  17183. name: string;
  17184. shader: string;
  17185. };
  17186. }
  17187. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17188. /** @hidden */
  17189. export var clipPlaneVertex: {
  17190. name: string;
  17191. shader: string;
  17192. };
  17193. }
  17194. declare module "babylonjs/Shaders/particles.vertex" {
  17195. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17196. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17197. /** @hidden */
  17198. export var particlesVertexShader: {
  17199. name: string;
  17200. shader: string;
  17201. };
  17202. }
  17203. declare module "babylonjs/Particles/particleSystem" {
  17204. import { Nullable } from "babylonjs/types";
  17205. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17206. import { Observable } from "babylonjs/Misc/observable";
  17207. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17208. import { Effect } from "babylonjs/Materials/effect";
  17209. import { Scene, IDisposable } from "babylonjs/scene";
  17210. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17211. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17212. import { Particle } from "babylonjs/Particles/particle";
  17213. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17215. import "babylonjs/Shaders/particles.fragment";
  17216. import "babylonjs/Shaders/particles.vertex";
  17217. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17218. /**
  17219. * This represents a particle system in Babylon.
  17220. * 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.
  17221. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17222. * @example https://doc.babylonjs.com/babylon101/particles
  17223. */
  17224. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17225. /**
  17226. * Billboard mode will only apply to Y axis
  17227. */
  17228. static readonly BILLBOARDMODE_Y: number;
  17229. /**
  17230. * Billboard mode will apply to all axes
  17231. */
  17232. static readonly BILLBOARDMODE_ALL: number;
  17233. /**
  17234. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17235. */
  17236. static readonly BILLBOARDMODE_STRETCHED: number;
  17237. /**
  17238. * This function can be defined to provide custom update for active particles.
  17239. * This function will be called instead of regular update (age, position, color, etc.).
  17240. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17241. */
  17242. updateFunction: (particles: Particle[]) => void;
  17243. private _emitterWorldMatrix;
  17244. /**
  17245. * This function can be defined to specify initial direction for every new particle.
  17246. * It by default use the emitterType defined function
  17247. */
  17248. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17249. /**
  17250. * This function can be defined to specify initial position for every new particle.
  17251. * It by default use the emitterType defined function
  17252. */
  17253. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17254. /**
  17255. * @hidden
  17256. */
  17257. _inheritedVelocityOffset: Vector3;
  17258. /**
  17259. * An event triggered when the system is disposed
  17260. */
  17261. onDisposeObservable: Observable<ParticleSystem>;
  17262. private _onDisposeObserver;
  17263. /**
  17264. * Sets a callback that will be triggered when the system is disposed
  17265. */
  17266. onDispose: () => void;
  17267. private _particles;
  17268. private _epsilon;
  17269. private _capacity;
  17270. private _stockParticles;
  17271. private _newPartsExcess;
  17272. private _vertexData;
  17273. private _vertexBuffer;
  17274. private _vertexBuffers;
  17275. private _spriteBuffer;
  17276. private _indexBuffer;
  17277. private _effect;
  17278. private _customEffect;
  17279. private _cachedDefines;
  17280. private _scaledColorStep;
  17281. private _colorDiff;
  17282. private _scaledDirection;
  17283. private _scaledGravity;
  17284. private _currentRenderId;
  17285. private _alive;
  17286. private _useInstancing;
  17287. private _started;
  17288. private _stopped;
  17289. private _actualFrame;
  17290. private _scaledUpdateSpeed;
  17291. private _vertexBufferSize;
  17292. /** @hidden */
  17293. _currentEmitRateGradient: Nullable<FactorGradient>;
  17294. /** @hidden */
  17295. _currentEmitRate1: number;
  17296. /** @hidden */
  17297. _currentEmitRate2: number;
  17298. /** @hidden */
  17299. _currentStartSizeGradient: Nullable<FactorGradient>;
  17300. /** @hidden */
  17301. _currentStartSize1: number;
  17302. /** @hidden */
  17303. _currentStartSize2: number;
  17304. private readonly _rawTextureWidth;
  17305. private _rampGradientsTexture;
  17306. private _useRampGradients;
  17307. /** Gets or sets a boolean indicating that ramp gradients must be used
  17308. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17309. */
  17310. useRampGradients: boolean;
  17311. /**
  17312. * 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.
  17313. * 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: [])
  17314. */
  17315. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17316. private _subEmitters;
  17317. /**
  17318. * @hidden
  17319. * If the particle systems emitter should be disposed when the particle system is disposed
  17320. */
  17321. _disposeEmitterOnDispose: boolean;
  17322. /**
  17323. * The current active Sub-systems, this property is used by the root particle system only.
  17324. */
  17325. activeSubSystems: Array<ParticleSystem>;
  17326. private _rootParticleSystem;
  17327. /**
  17328. * Gets the current list of active particles
  17329. */
  17330. readonly particles: Particle[];
  17331. /**
  17332. * Returns the string "ParticleSystem"
  17333. * @returns a string containing the class name
  17334. */
  17335. getClassName(): string;
  17336. /**
  17337. * Instantiates a particle system.
  17338. * 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.
  17339. * @param name The name of the particle system
  17340. * @param capacity The max number of particles alive at the same time
  17341. * @param scene The scene the particle system belongs to
  17342. * @param customEffect a custom effect used to change the way particles are rendered by default
  17343. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17344. * @param epsilon Offset used to render the particles
  17345. */
  17346. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17347. private _addFactorGradient;
  17348. private _removeFactorGradient;
  17349. /**
  17350. * Adds a new life time gradient
  17351. * @param gradient defines the gradient to use (between 0 and 1)
  17352. * @param factor defines the life time factor to affect to the specified gradient
  17353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17354. * @returns the current particle system
  17355. */
  17356. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17357. /**
  17358. * Remove a specific life time gradient
  17359. * @param gradient defines the gradient to remove
  17360. * @returns the current particle system
  17361. */
  17362. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17363. /**
  17364. * Adds a new size gradient
  17365. * @param gradient defines the gradient to use (between 0 and 1)
  17366. * @param factor defines the size factor to affect to the specified gradient
  17367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17368. * @returns the current particle system
  17369. */
  17370. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17371. /**
  17372. * Remove a specific size gradient
  17373. * @param gradient defines the gradient to remove
  17374. * @returns the current particle system
  17375. */
  17376. removeSizeGradient(gradient: number): IParticleSystem;
  17377. /**
  17378. * Adds a new color remap gradient
  17379. * @param gradient defines the gradient to use (between 0 and 1)
  17380. * @param min defines the color remap minimal range
  17381. * @param max defines the color remap maximal range
  17382. * @returns the current particle system
  17383. */
  17384. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17385. /**
  17386. * Remove a specific color remap gradient
  17387. * @param gradient defines the gradient to remove
  17388. * @returns the current particle system
  17389. */
  17390. removeColorRemapGradient(gradient: number): IParticleSystem;
  17391. /**
  17392. * Adds a new alpha remap gradient
  17393. * @param gradient defines the gradient to use (between 0 and 1)
  17394. * @param min defines the alpha remap minimal range
  17395. * @param max defines the alpha remap maximal range
  17396. * @returns the current particle system
  17397. */
  17398. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17399. /**
  17400. * Remove a specific alpha remap gradient
  17401. * @param gradient defines the gradient to remove
  17402. * @returns the current particle system
  17403. */
  17404. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17405. /**
  17406. * Adds a new angular speed gradient
  17407. * @param gradient defines the gradient to use (between 0 and 1)
  17408. * @param factor defines the angular speed to affect to the specified gradient
  17409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17410. * @returns the current particle system
  17411. */
  17412. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17413. /**
  17414. * Remove a specific angular speed gradient
  17415. * @param gradient defines the gradient to remove
  17416. * @returns the current particle system
  17417. */
  17418. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17419. /**
  17420. * Adds a new velocity gradient
  17421. * @param gradient defines the gradient to use (between 0 and 1)
  17422. * @param factor defines the velocity to affect to the specified gradient
  17423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17424. * @returns the current particle system
  17425. */
  17426. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17427. /**
  17428. * Remove a specific velocity gradient
  17429. * @param gradient defines the gradient to remove
  17430. * @returns the current particle system
  17431. */
  17432. removeVelocityGradient(gradient: number): IParticleSystem;
  17433. /**
  17434. * Adds a new limit velocity gradient
  17435. * @param gradient defines the gradient to use (between 0 and 1)
  17436. * @param factor defines the limit velocity value to affect to the specified gradient
  17437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17438. * @returns the current particle system
  17439. */
  17440. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17441. /**
  17442. * Remove a specific limit velocity gradient
  17443. * @param gradient defines the gradient to remove
  17444. * @returns the current particle system
  17445. */
  17446. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17447. /**
  17448. * Adds a new drag gradient
  17449. * @param gradient defines the gradient to use (between 0 and 1)
  17450. * @param factor defines the drag value to affect to the specified gradient
  17451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17452. * @returns the current particle system
  17453. */
  17454. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17455. /**
  17456. * Remove a specific drag gradient
  17457. * @param gradient defines the gradient to remove
  17458. * @returns the current particle system
  17459. */
  17460. removeDragGradient(gradient: number): IParticleSystem;
  17461. /**
  17462. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17463. * @param gradient defines the gradient to use (between 0 and 1)
  17464. * @param factor defines the emit rate value to affect to the specified gradient
  17465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17466. * @returns the current particle system
  17467. */
  17468. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17469. /**
  17470. * Remove a specific emit rate gradient
  17471. * @param gradient defines the gradient to remove
  17472. * @returns the current particle system
  17473. */
  17474. removeEmitRateGradient(gradient: number): IParticleSystem;
  17475. /**
  17476. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17477. * @param gradient defines the gradient to use (between 0 and 1)
  17478. * @param factor defines the start size value to affect to the specified gradient
  17479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17480. * @returns the current particle system
  17481. */
  17482. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17483. /**
  17484. * Remove a specific start size gradient
  17485. * @param gradient defines the gradient to remove
  17486. * @returns the current particle system
  17487. */
  17488. removeStartSizeGradient(gradient: number): IParticleSystem;
  17489. private _createRampGradientTexture;
  17490. /**
  17491. * Gets the current list of ramp gradients.
  17492. * You must use addRampGradient and removeRampGradient to udpate this list
  17493. * @returns the list of ramp gradients
  17494. */
  17495. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17496. /**
  17497. * Adds a new ramp gradient used to remap particle colors
  17498. * @param gradient defines the gradient to use (between 0 and 1)
  17499. * @param color defines the color to affect to the specified gradient
  17500. * @returns the current particle system
  17501. */
  17502. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17503. /**
  17504. * Remove a specific ramp gradient
  17505. * @param gradient defines the gradient to remove
  17506. * @returns the current particle system
  17507. */
  17508. removeRampGradient(gradient: number): ParticleSystem;
  17509. /**
  17510. * Adds a new color gradient
  17511. * @param gradient defines the gradient to use (between 0 and 1)
  17512. * @param color1 defines the color to affect to the specified gradient
  17513. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17514. * @returns this particle system
  17515. */
  17516. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17517. /**
  17518. * Remove a specific color gradient
  17519. * @param gradient defines the gradient to remove
  17520. * @returns this particle system
  17521. */
  17522. removeColorGradient(gradient: number): IParticleSystem;
  17523. private _fetchR;
  17524. protected _reset(): void;
  17525. private _resetEffect;
  17526. private _createVertexBuffers;
  17527. private _createIndexBuffer;
  17528. /**
  17529. * Gets the maximum number of particles active at the same time.
  17530. * @returns The max number of active particles.
  17531. */
  17532. getCapacity(): number;
  17533. /**
  17534. * Gets whether there are still active particles in the system.
  17535. * @returns True if it is alive, otherwise false.
  17536. */
  17537. isAlive(): boolean;
  17538. /**
  17539. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17540. * @returns True if it has been started, otherwise false.
  17541. */
  17542. isStarted(): boolean;
  17543. private _prepareSubEmitterInternalArray;
  17544. /**
  17545. * Starts the particle system and begins to emit
  17546. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17547. */
  17548. start(delay?: number): void;
  17549. /**
  17550. * Stops the particle system.
  17551. * @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.
  17552. */
  17553. stop(stopSubEmitters?: boolean): void;
  17554. /**
  17555. * Remove all active particles
  17556. */
  17557. reset(): void;
  17558. /**
  17559. * @hidden (for internal use only)
  17560. */
  17561. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17562. /**
  17563. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17564. * Its lifetime will start back at 0.
  17565. */
  17566. recycleParticle: (particle: Particle) => void;
  17567. private _stopSubEmitters;
  17568. private _createParticle;
  17569. private _removeFromRoot;
  17570. private _emitFromParticle;
  17571. private _update;
  17572. /** @hidden */
  17573. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17574. /** @hidden */
  17575. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17576. /** @hidden */
  17577. private _getEffect;
  17578. /**
  17579. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17580. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17581. */
  17582. animate(preWarmOnly?: boolean): void;
  17583. private _appendParticleVertices;
  17584. /**
  17585. * Rebuilds the particle system.
  17586. */
  17587. rebuild(): void;
  17588. /**
  17589. * Is this system ready to be used/rendered
  17590. * @return true if the system is ready
  17591. */
  17592. isReady(): boolean;
  17593. private _render;
  17594. /**
  17595. * Renders the particle system in its current state.
  17596. * @returns the current number of particles
  17597. */
  17598. render(): number;
  17599. /**
  17600. * Disposes the particle system and free the associated resources
  17601. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17602. */
  17603. dispose(disposeTexture?: boolean): void;
  17604. /**
  17605. * Clones the particle system.
  17606. * @param name The name of the cloned object
  17607. * @param newEmitter The new emitter to use
  17608. * @returns the cloned particle system
  17609. */
  17610. clone(name: string, newEmitter: any): ParticleSystem;
  17611. /**
  17612. * Serializes the particle system to a JSON object.
  17613. * @returns the JSON object
  17614. */
  17615. serialize(): any;
  17616. /** @hidden */
  17617. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17618. /** @hidden */
  17619. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17620. /**
  17621. * Parses a JSON object to create a particle system.
  17622. * @param parsedParticleSystem The JSON object to parse
  17623. * @param scene The scene to create the particle system in
  17624. * @param rootUrl The root url to use to load external dependencies like texture
  17625. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17626. * @returns the Parsed particle system
  17627. */
  17628. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17629. }
  17630. }
  17631. declare module "babylonjs/Particles/particle" {
  17632. import { Nullable } from "babylonjs/types";
  17633. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17634. import { Color4 } from "babylonjs/Maths/math.color";
  17635. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17636. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17637. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17638. /**
  17639. * A particle represents one of the element emitted by a particle system.
  17640. * This is mainly define by its coordinates, direction, velocity and age.
  17641. */
  17642. export class Particle {
  17643. /**
  17644. * The particle system the particle belongs to.
  17645. */
  17646. particleSystem: ParticleSystem;
  17647. private static _Count;
  17648. /**
  17649. * Unique ID of the particle
  17650. */
  17651. id: number;
  17652. /**
  17653. * The world position of the particle in the scene.
  17654. */
  17655. position: Vector3;
  17656. /**
  17657. * The world direction of the particle in the scene.
  17658. */
  17659. direction: Vector3;
  17660. /**
  17661. * The color of the particle.
  17662. */
  17663. color: Color4;
  17664. /**
  17665. * The color change of the particle per step.
  17666. */
  17667. colorStep: Color4;
  17668. /**
  17669. * Defines how long will the life of the particle be.
  17670. */
  17671. lifeTime: number;
  17672. /**
  17673. * The current age of the particle.
  17674. */
  17675. age: number;
  17676. /**
  17677. * The current size of the particle.
  17678. */
  17679. size: number;
  17680. /**
  17681. * The current scale of the particle.
  17682. */
  17683. scale: Vector2;
  17684. /**
  17685. * The current angle of the particle.
  17686. */
  17687. angle: number;
  17688. /**
  17689. * Defines how fast is the angle changing.
  17690. */
  17691. angularSpeed: number;
  17692. /**
  17693. * Defines the cell index used by the particle to be rendered from a sprite.
  17694. */
  17695. cellIndex: number;
  17696. /**
  17697. * The information required to support color remapping
  17698. */
  17699. remapData: Vector4;
  17700. /** @hidden */
  17701. _randomCellOffset?: number;
  17702. /** @hidden */
  17703. _initialDirection: Nullable<Vector3>;
  17704. /** @hidden */
  17705. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17706. /** @hidden */
  17707. _initialStartSpriteCellID: number;
  17708. /** @hidden */
  17709. _initialEndSpriteCellID: number;
  17710. /** @hidden */
  17711. _currentColorGradient: Nullable<ColorGradient>;
  17712. /** @hidden */
  17713. _currentColor1: Color4;
  17714. /** @hidden */
  17715. _currentColor2: Color4;
  17716. /** @hidden */
  17717. _currentSizeGradient: Nullable<FactorGradient>;
  17718. /** @hidden */
  17719. _currentSize1: number;
  17720. /** @hidden */
  17721. _currentSize2: number;
  17722. /** @hidden */
  17723. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17724. /** @hidden */
  17725. _currentAngularSpeed1: number;
  17726. /** @hidden */
  17727. _currentAngularSpeed2: number;
  17728. /** @hidden */
  17729. _currentVelocityGradient: Nullable<FactorGradient>;
  17730. /** @hidden */
  17731. _currentVelocity1: number;
  17732. /** @hidden */
  17733. _currentVelocity2: number;
  17734. /** @hidden */
  17735. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17736. /** @hidden */
  17737. _currentLimitVelocity1: number;
  17738. /** @hidden */
  17739. _currentLimitVelocity2: number;
  17740. /** @hidden */
  17741. _currentDragGradient: Nullable<FactorGradient>;
  17742. /** @hidden */
  17743. _currentDrag1: number;
  17744. /** @hidden */
  17745. _currentDrag2: number;
  17746. /** @hidden */
  17747. _randomNoiseCoordinates1: Vector3;
  17748. /** @hidden */
  17749. _randomNoiseCoordinates2: Vector3;
  17750. /**
  17751. * Creates a new instance Particle
  17752. * @param particleSystem the particle system the particle belongs to
  17753. */
  17754. constructor(
  17755. /**
  17756. * The particle system the particle belongs to.
  17757. */
  17758. particleSystem: ParticleSystem);
  17759. private updateCellInfoFromSystem;
  17760. /**
  17761. * Defines how the sprite cell index is updated for the particle
  17762. */
  17763. updateCellIndex(): void;
  17764. /** @hidden */
  17765. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17766. /** @hidden */
  17767. _inheritParticleInfoToSubEmitters(): void;
  17768. /** @hidden */
  17769. _reset(): void;
  17770. /**
  17771. * Copy the properties of particle to another one.
  17772. * @param other the particle to copy the information to.
  17773. */
  17774. copyTo(other: Particle): void;
  17775. }
  17776. }
  17777. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17778. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17779. import { Effect } from "babylonjs/Materials/effect";
  17780. import { Particle } from "babylonjs/Particles/particle";
  17781. /**
  17782. * Particle emitter represents a volume emitting particles.
  17783. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17784. */
  17785. export interface IParticleEmitterType {
  17786. /**
  17787. * Called by the particle System when the direction is computed for the created particle.
  17788. * @param worldMatrix is the world matrix of the particle system
  17789. * @param directionToUpdate is the direction vector to update with the result
  17790. * @param particle is the particle we are computed the direction for
  17791. */
  17792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17793. /**
  17794. * Called by the particle System when the position is computed for the created particle.
  17795. * @param worldMatrix is the world matrix of the particle system
  17796. * @param positionToUpdate is the position vector to update with the result
  17797. * @param particle is the particle we are computed the position for
  17798. */
  17799. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17800. /**
  17801. * Clones the current emitter and returns a copy of it
  17802. * @returns the new emitter
  17803. */
  17804. clone(): IParticleEmitterType;
  17805. /**
  17806. * Called by the GPUParticleSystem to setup the update shader
  17807. * @param effect defines the update shader
  17808. */
  17809. applyToShader(effect: Effect): void;
  17810. /**
  17811. * Returns a string to use to update the GPU particles update shader
  17812. * @returns the effect defines string
  17813. */
  17814. getEffectDefines(): string;
  17815. /**
  17816. * Returns a string representing the class name
  17817. * @returns a string containing the class name
  17818. */
  17819. getClassName(): string;
  17820. /**
  17821. * Serializes the particle system to a JSON object.
  17822. * @returns the JSON object
  17823. */
  17824. serialize(): any;
  17825. /**
  17826. * Parse properties from a JSON object
  17827. * @param serializationObject defines the JSON object
  17828. */
  17829. parse(serializationObject: any): void;
  17830. }
  17831. }
  17832. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17833. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17834. import { Effect } from "babylonjs/Materials/effect";
  17835. import { Particle } from "babylonjs/Particles/particle";
  17836. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17837. /**
  17838. * Particle emitter emitting particles from the inside of a box.
  17839. * It emits the particles randomly between 2 given directions.
  17840. */
  17841. export class BoxParticleEmitter implements IParticleEmitterType {
  17842. /**
  17843. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17844. */
  17845. direction1: Vector3;
  17846. /**
  17847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17848. */
  17849. direction2: Vector3;
  17850. /**
  17851. * 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.
  17852. */
  17853. minEmitBox: Vector3;
  17854. /**
  17855. * 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.
  17856. */
  17857. maxEmitBox: Vector3;
  17858. /**
  17859. * Creates a new instance BoxParticleEmitter
  17860. */
  17861. constructor();
  17862. /**
  17863. * Called by the particle System when the direction is computed for the created particle.
  17864. * @param worldMatrix is the world matrix of the particle system
  17865. * @param directionToUpdate is the direction vector to update with the result
  17866. * @param particle is the particle we are computed the direction for
  17867. */
  17868. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17869. /**
  17870. * Called by the particle System when the position is computed for the created particle.
  17871. * @param worldMatrix is the world matrix of the particle system
  17872. * @param positionToUpdate is the position vector to update with the result
  17873. * @param particle is the particle we are computed the position for
  17874. */
  17875. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17876. /**
  17877. * Clones the current emitter and returns a copy of it
  17878. * @returns the new emitter
  17879. */
  17880. clone(): BoxParticleEmitter;
  17881. /**
  17882. * Called by the GPUParticleSystem to setup the update shader
  17883. * @param effect defines the update shader
  17884. */
  17885. applyToShader(effect: Effect): void;
  17886. /**
  17887. * Returns a string to use to update the GPU particles update shader
  17888. * @returns a string containng the defines string
  17889. */
  17890. getEffectDefines(): string;
  17891. /**
  17892. * Returns the string "BoxParticleEmitter"
  17893. * @returns a string containing the class name
  17894. */
  17895. getClassName(): string;
  17896. /**
  17897. * Serializes the particle system to a JSON object.
  17898. * @returns the JSON object
  17899. */
  17900. serialize(): any;
  17901. /**
  17902. * Parse properties from a JSON object
  17903. * @param serializationObject defines the JSON object
  17904. */
  17905. parse(serializationObject: any): void;
  17906. }
  17907. }
  17908. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17909. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17910. import { Effect } from "babylonjs/Materials/effect";
  17911. import { Particle } from "babylonjs/Particles/particle";
  17912. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17913. /**
  17914. * Particle emitter emitting particles from the inside of a cone.
  17915. * It emits the particles alongside the cone volume from the base to the particle.
  17916. * The emission direction might be randomized.
  17917. */
  17918. export class ConeParticleEmitter implements IParticleEmitterType {
  17919. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17920. directionRandomizer: number;
  17921. private _radius;
  17922. private _angle;
  17923. private _height;
  17924. /**
  17925. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17926. */
  17927. radiusRange: number;
  17928. /**
  17929. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17930. */
  17931. heightRange: number;
  17932. /**
  17933. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17934. */
  17935. emitFromSpawnPointOnly: boolean;
  17936. /**
  17937. * Gets or sets the radius of the emission cone
  17938. */
  17939. radius: number;
  17940. /**
  17941. * Gets or sets the angle of the emission cone
  17942. */
  17943. angle: number;
  17944. private _buildHeight;
  17945. /**
  17946. * Creates a new instance ConeParticleEmitter
  17947. * @param radius the radius of the emission cone (1 by default)
  17948. * @param angle the cone base angle (PI by default)
  17949. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17950. */
  17951. constructor(radius?: number, angle?: number,
  17952. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17953. directionRandomizer?: number);
  17954. /**
  17955. * Called by the particle System when the direction is computed for the created particle.
  17956. * @param worldMatrix is the world matrix of the particle system
  17957. * @param directionToUpdate is the direction vector to update with the result
  17958. * @param particle is the particle we are computed the direction for
  17959. */
  17960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17961. /**
  17962. * Called by the particle System when the position is computed for the created particle.
  17963. * @param worldMatrix is the world matrix of the particle system
  17964. * @param positionToUpdate is the position vector to update with the result
  17965. * @param particle is the particle we are computed the position for
  17966. */
  17967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17968. /**
  17969. * Clones the current emitter and returns a copy of it
  17970. * @returns the new emitter
  17971. */
  17972. clone(): ConeParticleEmitter;
  17973. /**
  17974. * Called by the GPUParticleSystem to setup the update shader
  17975. * @param effect defines the update shader
  17976. */
  17977. applyToShader(effect: Effect): void;
  17978. /**
  17979. * Returns a string to use to update the GPU particles update shader
  17980. * @returns a string containng the defines string
  17981. */
  17982. getEffectDefines(): string;
  17983. /**
  17984. * Returns the string "ConeParticleEmitter"
  17985. * @returns a string containing the class name
  17986. */
  17987. getClassName(): string;
  17988. /**
  17989. * Serializes the particle system to a JSON object.
  17990. * @returns the JSON object
  17991. */
  17992. serialize(): any;
  17993. /**
  17994. * Parse properties from a JSON object
  17995. * @param serializationObject defines the JSON object
  17996. */
  17997. parse(serializationObject: any): void;
  17998. }
  17999. }
  18000. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18001. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18002. import { Effect } from "babylonjs/Materials/effect";
  18003. import { Particle } from "babylonjs/Particles/particle";
  18004. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18005. /**
  18006. * Particle emitter emitting particles from the inside of a cylinder.
  18007. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18008. */
  18009. export class CylinderParticleEmitter implements IParticleEmitterType {
  18010. /**
  18011. * The radius of the emission cylinder.
  18012. */
  18013. radius: number;
  18014. /**
  18015. * The height of the emission cylinder.
  18016. */
  18017. height: number;
  18018. /**
  18019. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18020. */
  18021. radiusRange: number;
  18022. /**
  18023. * How much to randomize the particle direction [0-1].
  18024. */
  18025. directionRandomizer: number;
  18026. /**
  18027. * Creates a new instance CylinderParticleEmitter
  18028. * @param radius the radius of the emission cylinder (1 by default)
  18029. * @param height the height of the emission cylinder (1 by default)
  18030. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18031. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18032. */
  18033. constructor(
  18034. /**
  18035. * The radius of the emission cylinder.
  18036. */
  18037. radius?: number,
  18038. /**
  18039. * The height of the emission cylinder.
  18040. */
  18041. height?: number,
  18042. /**
  18043. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18044. */
  18045. radiusRange?: number,
  18046. /**
  18047. * How much to randomize the particle direction [0-1].
  18048. */
  18049. directionRandomizer?: number);
  18050. /**
  18051. * Called by the particle System when the direction is computed for the created particle.
  18052. * @param worldMatrix is the world matrix of the particle system
  18053. * @param directionToUpdate is the direction vector to update with the result
  18054. * @param particle is the particle we are computed the direction for
  18055. */
  18056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18057. /**
  18058. * Called by the particle System when the position is computed for the created particle.
  18059. * @param worldMatrix is the world matrix of the particle system
  18060. * @param positionToUpdate is the position vector to update with the result
  18061. * @param particle is the particle we are computed the position for
  18062. */
  18063. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18064. /**
  18065. * Clones the current emitter and returns a copy of it
  18066. * @returns the new emitter
  18067. */
  18068. clone(): CylinderParticleEmitter;
  18069. /**
  18070. * Called by the GPUParticleSystem to setup the update shader
  18071. * @param effect defines the update shader
  18072. */
  18073. applyToShader(effect: Effect): void;
  18074. /**
  18075. * Returns a string to use to update the GPU particles update shader
  18076. * @returns a string containng the defines string
  18077. */
  18078. getEffectDefines(): string;
  18079. /**
  18080. * Returns the string "CylinderParticleEmitter"
  18081. * @returns a string containing the class name
  18082. */
  18083. getClassName(): string;
  18084. /**
  18085. * Serializes the particle system to a JSON object.
  18086. * @returns the JSON object
  18087. */
  18088. serialize(): any;
  18089. /**
  18090. * Parse properties from a JSON object
  18091. * @param serializationObject defines the JSON object
  18092. */
  18093. parse(serializationObject: any): void;
  18094. }
  18095. /**
  18096. * Particle emitter emitting particles from the inside of a cylinder.
  18097. * It emits the particles randomly between two vectors.
  18098. */
  18099. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18100. /**
  18101. * The min limit of the emission direction.
  18102. */
  18103. direction1: Vector3;
  18104. /**
  18105. * The max limit of the emission direction.
  18106. */
  18107. direction2: Vector3;
  18108. /**
  18109. * Creates a new instance CylinderDirectedParticleEmitter
  18110. * @param radius the radius of the emission cylinder (1 by default)
  18111. * @param height the height of the emission cylinder (1 by default)
  18112. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18113. * @param direction1 the min limit of the emission direction (up vector by default)
  18114. * @param direction2 the max limit of the emission direction (up vector by default)
  18115. */
  18116. constructor(radius?: number, height?: number, radiusRange?: number,
  18117. /**
  18118. * The min limit of the emission direction.
  18119. */
  18120. direction1?: Vector3,
  18121. /**
  18122. * The max limit of the emission direction.
  18123. */
  18124. direction2?: Vector3);
  18125. /**
  18126. * Called by the particle System when the direction is computed for the created particle.
  18127. * @param worldMatrix is the world matrix of the particle system
  18128. * @param directionToUpdate is the direction vector to update with the result
  18129. * @param particle is the particle we are computed the direction for
  18130. */
  18131. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18132. /**
  18133. * Clones the current emitter and returns a copy of it
  18134. * @returns the new emitter
  18135. */
  18136. clone(): CylinderDirectedParticleEmitter;
  18137. /**
  18138. * Called by the GPUParticleSystem to setup the update shader
  18139. * @param effect defines the update shader
  18140. */
  18141. applyToShader(effect: Effect): void;
  18142. /**
  18143. * Returns a string to use to update the GPU particles update shader
  18144. * @returns a string containng the defines string
  18145. */
  18146. getEffectDefines(): string;
  18147. /**
  18148. * Returns the string "CylinderDirectedParticleEmitter"
  18149. * @returns a string containing the class name
  18150. */
  18151. getClassName(): string;
  18152. /**
  18153. * Serializes the particle system to a JSON object.
  18154. * @returns the JSON object
  18155. */
  18156. serialize(): any;
  18157. /**
  18158. * Parse properties from a JSON object
  18159. * @param serializationObject defines the JSON object
  18160. */
  18161. parse(serializationObject: any): void;
  18162. }
  18163. }
  18164. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18165. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18166. import { Effect } from "babylonjs/Materials/effect";
  18167. import { Particle } from "babylonjs/Particles/particle";
  18168. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18169. /**
  18170. * Particle emitter emitting particles from the inside of a hemisphere.
  18171. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18172. */
  18173. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18174. /**
  18175. * The radius of the emission hemisphere.
  18176. */
  18177. radius: number;
  18178. /**
  18179. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18180. */
  18181. radiusRange: number;
  18182. /**
  18183. * How much to randomize the particle direction [0-1].
  18184. */
  18185. directionRandomizer: number;
  18186. /**
  18187. * Creates a new instance HemisphericParticleEmitter
  18188. * @param radius the radius of the emission hemisphere (1 by default)
  18189. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18190. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18191. */
  18192. constructor(
  18193. /**
  18194. * The radius of the emission hemisphere.
  18195. */
  18196. radius?: number,
  18197. /**
  18198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18199. */
  18200. radiusRange?: number,
  18201. /**
  18202. * How much to randomize the particle direction [0-1].
  18203. */
  18204. directionRandomizer?: number);
  18205. /**
  18206. * Called by the particle System when the direction is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param directionToUpdate is the direction vector to update with the result
  18209. * @param particle is the particle we are computed the direction for
  18210. */
  18211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Called by the particle System when the position is computed for the created particle.
  18214. * @param worldMatrix is the world matrix of the particle system
  18215. * @param positionToUpdate is the position vector to update with the result
  18216. * @param particle is the particle we are computed the position for
  18217. */
  18218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18219. /**
  18220. * Clones the current emitter and returns a copy of it
  18221. * @returns the new emitter
  18222. */
  18223. clone(): HemisphericParticleEmitter;
  18224. /**
  18225. * Called by the GPUParticleSystem to setup the update shader
  18226. * @param effect defines the update shader
  18227. */
  18228. applyToShader(effect: Effect): void;
  18229. /**
  18230. * Returns a string to use to update the GPU particles update shader
  18231. * @returns a string containng the defines string
  18232. */
  18233. getEffectDefines(): string;
  18234. /**
  18235. * Returns the string "HemisphericParticleEmitter"
  18236. * @returns a string containing the class name
  18237. */
  18238. getClassName(): string;
  18239. /**
  18240. * Serializes the particle system to a JSON object.
  18241. * @returns the JSON object
  18242. */
  18243. serialize(): any;
  18244. /**
  18245. * Parse properties from a JSON object
  18246. * @param serializationObject defines the JSON object
  18247. */
  18248. parse(serializationObject: any): void;
  18249. }
  18250. }
  18251. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18252. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18253. import { Effect } from "babylonjs/Materials/effect";
  18254. import { Particle } from "babylonjs/Particles/particle";
  18255. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18256. /**
  18257. * Particle emitter emitting particles from a point.
  18258. * It emits the particles randomly between 2 given directions.
  18259. */
  18260. export class PointParticleEmitter implements IParticleEmitterType {
  18261. /**
  18262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18263. */
  18264. direction1: Vector3;
  18265. /**
  18266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18267. */
  18268. direction2: Vector3;
  18269. /**
  18270. * Creates a new instance PointParticleEmitter
  18271. */
  18272. constructor();
  18273. /**
  18274. * Called by the particle System when the direction is computed for the created particle.
  18275. * @param worldMatrix is the world matrix of the particle system
  18276. * @param directionToUpdate is the direction vector to update with the result
  18277. * @param particle is the particle we are computed the direction for
  18278. */
  18279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18280. /**
  18281. * Called by the particle System when the position is computed for the created particle.
  18282. * @param worldMatrix is the world matrix of the particle system
  18283. * @param positionToUpdate is the position vector to update with the result
  18284. * @param particle is the particle we are computed the position for
  18285. */
  18286. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18287. /**
  18288. * Clones the current emitter and returns a copy of it
  18289. * @returns the new emitter
  18290. */
  18291. clone(): PointParticleEmitter;
  18292. /**
  18293. * Called by the GPUParticleSystem to setup the update shader
  18294. * @param effect defines the update shader
  18295. */
  18296. applyToShader(effect: Effect): void;
  18297. /**
  18298. * Returns a string to use to update the GPU particles update shader
  18299. * @returns a string containng the defines string
  18300. */
  18301. getEffectDefines(): string;
  18302. /**
  18303. * Returns the string "PointParticleEmitter"
  18304. * @returns a string containing the class name
  18305. */
  18306. getClassName(): string;
  18307. /**
  18308. * Serializes the particle system to a JSON object.
  18309. * @returns the JSON object
  18310. */
  18311. serialize(): any;
  18312. /**
  18313. * Parse properties from a JSON object
  18314. * @param serializationObject defines the JSON object
  18315. */
  18316. parse(serializationObject: any): void;
  18317. }
  18318. }
  18319. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18321. import { Effect } from "babylonjs/Materials/effect";
  18322. import { Particle } from "babylonjs/Particles/particle";
  18323. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18324. /**
  18325. * Particle emitter emitting particles from the inside of a sphere.
  18326. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18327. */
  18328. export class SphereParticleEmitter implements IParticleEmitterType {
  18329. /**
  18330. * The radius of the emission sphere.
  18331. */
  18332. radius: number;
  18333. /**
  18334. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18335. */
  18336. radiusRange: number;
  18337. /**
  18338. * How much to randomize the particle direction [0-1].
  18339. */
  18340. directionRandomizer: number;
  18341. /**
  18342. * Creates a new instance SphereParticleEmitter
  18343. * @param radius the radius of the emission sphere (1 by default)
  18344. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18345. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18346. */
  18347. constructor(
  18348. /**
  18349. * The radius of the emission sphere.
  18350. */
  18351. radius?: number,
  18352. /**
  18353. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18354. */
  18355. radiusRange?: number,
  18356. /**
  18357. * How much to randomize the particle direction [0-1].
  18358. */
  18359. directionRandomizer?: number);
  18360. /**
  18361. * Called by the particle System when the direction is computed for the created particle.
  18362. * @param worldMatrix is the world matrix of the particle system
  18363. * @param directionToUpdate is the direction vector to update with the result
  18364. * @param particle is the particle we are computed the direction for
  18365. */
  18366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18367. /**
  18368. * Called by the particle System when the position is computed for the created particle.
  18369. * @param worldMatrix is the world matrix of the particle system
  18370. * @param positionToUpdate is the position vector to update with the result
  18371. * @param particle is the particle we are computed the position for
  18372. */
  18373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18374. /**
  18375. * Clones the current emitter and returns a copy of it
  18376. * @returns the new emitter
  18377. */
  18378. clone(): SphereParticleEmitter;
  18379. /**
  18380. * Called by the GPUParticleSystem to setup the update shader
  18381. * @param effect defines the update shader
  18382. */
  18383. applyToShader(effect: Effect): void;
  18384. /**
  18385. * Returns a string to use to update the GPU particles update shader
  18386. * @returns a string containng the defines string
  18387. */
  18388. getEffectDefines(): string;
  18389. /**
  18390. * Returns the string "SphereParticleEmitter"
  18391. * @returns a string containing the class name
  18392. */
  18393. getClassName(): string;
  18394. /**
  18395. * Serializes the particle system to a JSON object.
  18396. * @returns the JSON object
  18397. */
  18398. serialize(): any;
  18399. /**
  18400. * Parse properties from a JSON object
  18401. * @param serializationObject defines the JSON object
  18402. */
  18403. parse(serializationObject: any): void;
  18404. }
  18405. /**
  18406. * Particle emitter emitting particles from the inside of a sphere.
  18407. * It emits the particles randomly between two vectors.
  18408. */
  18409. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18410. /**
  18411. * The min limit of the emission direction.
  18412. */
  18413. direction1: Vector3;
  18414. /**
  18415. * The max limit of the emission direction.
  18416. */
  18417. direction2: Vector3;
  18418. /**
  18419. * Creates a new instance SphereDirectedParticleEmitter
  18420. * @param radius the radius of the emission sphere (1 by default)
  18421. * @param direction1 the min limit of the emission direction (up vector by default)
  18422. * @param direction2 the max limit of the emission direction (up vector by default)
  18423. */
  18424. constructor(radius?: number,
  18425. /**
  18426. * The min limit of the emission direction.
  18427. */
  18428. direction1?: Vector3,
  18429. /**
  18430. * The max limit of the emission direction.
  18431. */
  18432. direction2?: Vector3);
  18433. /**
  18434. * Called by the particle System when the direction is computed for the created particle.
  18435. * @param worldMatrix is the world matrix of the particle system
  18436. * @param directionToUpdate is the direction vector to update with the result
  18437. * @param particle is the particle we are computed the direction for
  18438. */
  18439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18440. /**
  18441. * Clones the current emitter and returns a copy of it
  18442. * @returns the new emitter
  18443. */
  18444. clone(): SphereDirectedParticleEmitter;
  18445. /**
  18446. * Called by the GPUParticleSystem to setup the update shader
  18447. * @param effect defines the update shader
  18448. */
  18449. applyToShader(effect: Effect): void;
  18450. /**
  18451. * Returns a string to use to update the GPU particles update shader
  18452. * @returns a string containng the defines string
  18453. */
  18454. getEffectDefines(): string;
  18455. /**
  18456. * Returns the string "SphereDirectedParticleEmitter"
  18457. * @returns a string containing the class name
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Serializes the particle system to a JSON object.
  18462. * @returns the JSON object
  18463. */
  18464. serialize(): any;
  18465. /**
  18466. * Parse properties from a JSON object
  18467. * @param serializationObject defines the JSON object
  18468. */
  18469. parse(serializationObject: any): void;
  18470. }
  18471. }
  18472. declare module "babylonjs/Particles/EmitterTypes/index" {
  18473. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18474. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18475. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18476. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18477. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18478. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18479. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18480. }
  18481. declare module "babylonjs/Particles/IParticleSystem" {
  18482. import { Nullable } from "babylonjs/types";
  18483. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18484. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18487. import { Texture } from "babylonjs/Materials/Textures/texture";
  18488. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18489. import { Scene } from "babylonjs/scene";
  18490. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18491. import { Animation } from "babylonjs/Animations/animation";
  18492. /**
  18493. * Interface representing a particle system in Babylon.js.
  18494. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18495. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18496. */
  18497. export interface IParticleSystem {
  18498. /**
  18499. * List of animations used by the particle system.
  18500. */
  18501. animations: Animation[];
  18502. /**
  18503. * The id of the Particle system.
  18504. */
  18505. id: string;
  18506. /**
  18507. * The name of the Particle system.
  18508. */
  18509. name: string;
  18510. /**
  18511. * The emitter represents the Mesh or position we are attaching the particle system to.
  18512. */
  18513. emitter: Nullable<AbstractMesh | Vector3>;
  18514. /**
  18515. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18516. */
  18517. isBillboardBased: boolean;
  18518. /**
  18519. * The rendering group used by the Particle system to chose when to render.
  18520. */
  18521. renderingGroupId: number;
  18522. /**
  18523. * The layer mask we are rendering the particles through.
  18524. */
  18525. layerMask: number;
  18526. /**
  18527. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18528. */
  18529. updateSpeed: number;
  18530. /**
  18531. * The amount of time the particle system is running (depends of the overall update speed).
  18532. */
  18533. targetStopDuration: number;
  18534. /**
  18535. * The texture used to render each particle. (this can be a spritesheet)
  18536. */
  18537. particleTexture: Nullable<Texture>;
  18538. /**
  18539. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18540. */
  18541. blendMode: number;
  18542. /**
  18543. * Minimum life time of emitting particles.
  18544. */
  18545. minLifeTime: number;
  18546. /**
  18547. * Maximum life time of emitting particles.
  18548. */
  18549. maxLifeTime: number;
  18550. /**
  18551. * Minimum Size of emitting particles.
  18552. */
  18553. minSize: number;
  18554. /**
  18555. * Maximum Size of emitting particles.
  18556. */
  18557. maxSize: number;
  18558. /**
  18559. * Minimum scale of emitting particles on X axis.
  18560. */
  18561. minScaleX: number;
  18562. /**
  18563. * Maximum scale of emitting particles on X axis.
  18564. */
  18565. maxScaleX: number;
  18566. /**
  18567. * Minimum scale of emitting particles on Y axis.
  18568. */
  18569. minScaleY: number;
  18570. /**
  18571. * Maximum scale of emitting particles on Y axis.
  18572. */
  18573. maxScaleY: number;
  18574. /**
  18575. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18576. */
  18577. color1: Color4;
  18578. /**
  18579. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18580. */
  18581. color2: Color4;
  18582. /**
  18583. * Color the particle will have at the end of its lifetime.
  18584. */
  18585. colorDead: Color4;
  18586. /**
  18587. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18588. */
  18589. emitRate: number;
  18590. /**
  18591. * You can use gravity if you want to give an orientation to your particles.
  18592. */
  18593. gravity: Vector3;
  18594. /**
  18595. * Minimum power of emitting particles.
  18596. */
  18597. minEmitPower: number;
  18598. /**
  18599. * Maximum power of emitting particles.
  18600. */
  18601. maxEmitPower: number;
  18602. /**
  18603. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18604. */
  18605. minAngularSpeed: number;
  18606. /**
  18607. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18608. */
  18609. maxAngularSpeed: number;
  18610. /**
  18611. * Gets or sets the minimal initial rotation in radians.
  18612. */
  18613. minInitialRotation: number;
  18614. /**
  18615. * Gets or sets the maximal initial rotation in radians.
  18616. */
  18617. maxInitialRotation: number;
  18618. /**
  18619. * The particle emitter type defines the emitter used by the particle system.
  18620. * It can be for example box, sphere, or cone...
  18621. */
  18622. particleEmitterType: Nullable<IParticleEmitterType>;
  18623. /**
  18624. * Defines the delay in milliseconds before starting the system (0 by default)
  18625. */
  18626. startDelay: number;
  18627. /**
  18628. * 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
  18629. */
  18630. preWarmCycles: number;
  18631. /**
  18632. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18633. */
  18634. preWarmStepOffset: number;
  18635. /**
  18636. * 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)
  18637. */
  18638. spriteCellChangeSpeed: number;
  18639. /**
  18640. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18641. */
  18642. startSpriteCellID: number;
  18643. /**
  18644. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18645. */
  18646. endSpriteCellID: number;
  18647. /**
  18648. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18649. */
  18650. spriteCellWidth: number;
  18651. /**
  18652. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18653. */
  18654. spriteCellHeight: number;
  18655. /**
  18656. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18657. */
  18658. spriteRandomStartCell: boolean;
  18659. /**
  18660. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18661. */
  18662. isAnimationSheetEnabled: boolean;
  18663. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18664. translationPivot: Vector2;
  18665. /**
  18666. * Gets or sets a texture used to add random noise to particle positions
  18667. */
  18668. noiseTexture: Nullable<BaseTexture>;
  18669. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18670. noiseStrength: Vector3;
  18671. /**
  18672. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18673. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18674. */
  18675. billboardMode: number;
  18676. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18677. limitVelocityDamping: number;
  18678. /**
  18679. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18680. */
  18681. beginAnimationOnStart: boolean;
  18682. /**
  18683. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18684. */
  18685. beginAnimationFrom: number;
  18686. /**
  18687. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18688. */
  18689. beginAnimationTo: number;
  18690. /**
  18691. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18692. */
  18693. beginAnimationLoop: boolean;
  18694. /**
  18695. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18696. */
  18697. disposeOnStop: boolean;
  18698. /**
  18699. * Gets the maximum number of particles active at the same time.
  18700. * @returns The max number of active particles.
  18701. */
  18702. getCapacity(): number;
  18703. /**
  18704. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18705. * @returns True if it has been started, otherwise false.
  18706. */
  18707. isStarted(): boolean;
  18708. /**
  18709. * Animates the particle system for this frame.
  18710. */
  18711. animate(): void;
  18712. /**
  18713. * Renders the particle system in its current state.
  18714. * @returns the current number of particles
  18715. */
  18716. render(): number;
  18717. /**
  18718. * Dispose the particle system and frees its associated resources.
  18719. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18720. */
  18721. dispose(disposeTexture?: boolean): void;
  18722. /**
  18723. * Clones the particle system.
  18724. * @param name The name of the cloned object
  18725. * @param newEmitter The new emitter to use
  18726. * @returns the cloned particle system
  18727. */
  18728. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18729. /**
  18730. * Serializes the particle system to a JSON object.
  18731. * @returns the JSON object
  18732. */
  18733. serialize(): any;
  18734. /**
  18735. * Rebuild the particle system
  18736. */
  18737. rebuild(): void;
  18738. /**
  18739. * Starts the particle system and begins to emit
  18740. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18741. */
  18742. start(delay?: number): void;
  18743. /**
  18744. * Stops the particle system.
  18745. */
  18746. stop(): void;
  18747. /**
  18748. * Remove all active particles
  18749. */
  18750. reset(): void;
  18751. /**
  18752. * Is this system ready to be used/rendered
  18753. * @return true if the system is ready
  18754. */
  18755. isReady(): boolean;
  18756. /**
  18757. * Adds a new color gradient
  18758. * @param gradient defines the gradient to use (between 0 and 1)
  18759. * @param color1 defines the color to affect to the specified gradient
  18760. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18761. * @returns the current particle system
  18762. */
  18763. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18764. /**
  18765. * Remove a specific color gradient
  18766. * @param gradient defines the gradient to remove
  18767. * @returns the current particle system
  18768. */
  18769. removeColorGradient(gradient: number): IParticleSystem;
  18770. /**
  18771. * Adds a new size gradient
  18772. * @param gradient defines the gradient to use (between 0 and 1)
  18773. * @param factor defines the size factor to affect to the specified gradient
  18774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18775. * @returns the current particle system
  18776. */
  18777. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18778. /**
  18779. * Remove a specific size gradient
  18780. * @param gradient defines the gradient to remove
  18781. * @returns the current particle system
  18782. */
  18783. removeSizeGradient(gradient: number): IParticleSystem;
  18784. /**
  18785. * Gets the current list of color gradients.
  18786. * You must use addColorGradient and removeColorGradient to udpate this list
  18787. * @returns the list of color gradients
  18788. */
  18789. getColorGradients(): Nullable<Array<ColorGradient>>;
  18790. /**
  18791. * Gets the current list of size gradients.
  18792. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18793. * @returns the list of size gradients
  18794. */
  18795. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18796. /**
  18797. * Gets the current list of angular speed gradients.
  18798. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18799. * @returns the list of angular speed gradients
  18800. */
  18801. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18802. /**
  18803. * Adds a new angular speed gradient
  18804. * @param gradient defines the gradient to use (between 0 and 1)
  18805. * @param factor defines the angular speed to affect to the specified gradient
  18806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18807. * @returns the current particle system
  18808. */
  18809. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18810. /**
  18811. * Remove a specific angular speed gradient
  18812. * @param gradient defines the gradient to remove
  18813. * @returns the current particle system
  18814. */
  18815. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18816. /**
  18817. * Gets the current list of velocity gradients.
  18818. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18819. * @returns the list of velocity gradients
  18820. */
  18821. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18822. /**
  18823. * Adds a new velocity gradient
  18824. * @param gradient defines the gradient to use (between 0 and 1)
  18825. * @param factor defines the velocity to affect to the specified gradient
  18826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18827. * @returns the current particle system
  18828. */
  18829. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18830. /**
  18831. * Remove a specific velocity gradient
  18832. * @param gradient defines the gradient to remove
  18833. * @returns the current particle system
  18834. */
  18835. removeVelocityGradient(gradient: number): IParticleSystem;
  18836. /**
  18837. * Gets the current list of limit velocity gradients.
  18838. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18839. * @returns the list of limit velocity gradients
  18840. */
  18841. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18842. /**
  18843. * Adds a new limit velocity gradient
  18844. * @param gradient defines the gradient to use (between 0 and 1)
  18845. * @param factor defines the limit velocity to affect to the specified gradient
  18846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18847. * @returns the current particle system
  18848. */
  18849. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18850. /**
  18851. * Remove a specific limit velocity gradient
  18852. * @param gradient defines the gradient to remove
  18853. * @returns the current particle system
  18854. */
  18855. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18856. /**
  18857. * Adds a new drag gradient
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific drag gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeDragGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of drag gradients.
  18872. * You must use addDragGradient and removeDragGradient to udpate this list
  18873. * @returns the list of drag gradients
  18874. */
  18875. getDragGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18878. * @param gradient defines the gradient to use (between 0 and 1)
  18879. * @param factor defines the emit rate to affect to the specified gradient
  18880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18881. * @returns the current particle system
  18882. */
  18883. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18884. /**
  18885. * Remove a specific emit rate gradient
  18886. * @param gradient defines the gradient to remove
  18887. * @returns the current particle system
  18888. */
  18889. removeEmitRateGradient(gradient: number): IParticleSystem;
  18890. /**
  18891. * Gets the current list of emit rate gradients.
  18892. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18893. * @returns the list of emit rate gradients
  18894. */
  18895. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18896. /**
  18897. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18898. * @param gradient defines the gradient to use (between 0 and 1)
  18899. * @param factor defines the start size to affect to the specified gradient
  18900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18901. * @returns the current particle system
  18902. */
  18903. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18904. /**
  18905. * Remove a specific start size gradient
  18906. * @param gradient defines the gradient to remove
  18907. * @returns the current particle system
  18908. */
  18909. removeStartSizeGradient(gradient: number): IParticleSystem;
  18910. /**
  18911. * Gets the current list of start size gradients.
  18912. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18913. * @returns the list of start size gradients
  18914. */
  18915. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18916. /**
  18917. * Adds a new life time gradient
  18918. * @param gradient defines the gradient to use (between 0 and 1)
  18919. * @param factor defines the life time factor to affect to the specified gradient
  18920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18921. * @returns the current particle system
  18922. */
  18923. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18924. /**
  18925. * Remove a specific life time gradient
  18926. * @param gradient defines the gradient to remove
  18927. * @returns the current particle system
  18928. */
  18929. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18930. /**
  18931. * Gets the current list of life time gradients.
  18932. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18933. * @returns the list of life time gradients
  18934. */
  18935. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18936. /**
  18937. * Gets the current list of color gradients.
  18938. * You must use addColorGradient and removeColorGradient to udpate this list
  18939. * @returns the list of color gradients
  18940. */
  18941. getColorGradients(): Nullable<Array<ColorGradient>>;
  18942. /**
  18943. * Adds a new ramp gradient used to remap particle colors
  18944. * @param gradient defines the gradient to use (between 0 and 1)
  18945. * @param color defines the color to affect to the specified gradient
  18946. * @returns the current particle system
  18947. */
  18948. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18949. /**
  18950. * Gets the current list of ramp gradients.
  18951. * You must use addRampGradient and removeRampGradient to udpate this list
  18952. * @returns the list of ramp gradients
  18953. */
  18954. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18955. /** Gets or sets a boolean indicating that ramp gradients must be used
  18956. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18957. */
  18958. useRampGradients: boolean;
  18959. /**
  18960. * Adds a new color remap gradient
  18961. * @param gradient defines the gradient to use (between 0 and 1)
  18962. * @param min defines the color remap minimal range
  18963. * @param max defines the color remap maximal range
  18964. * @returns the current particle system
  18965. */
  18966. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18967. /**
  18968. * Gets the current list of color remap gradients.
  18969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18970. * @returns the list of color remap gradients
  18971. */
  18972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18973. /**
  18974. * Adds a new alpha remap gradient
  18975. * @param gradient defines the gradient to use (between 0 and 1)
  18976. * @param min defines the alpha remap minimal range
  18977. * @param max defines the alpha remap maximal range
  18978. * @returns the current particle system
  18979. */
  18980. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18981. /**
  18982. * Gets the current list of alpha remap gradients.
  18983. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18984. * @returns the list of alpha remap gradients
  18985. */
  18986. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18987. /**
  18988. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18989. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18990. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18991. * @returns the emitter
  18992. */
  18993. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18994. /**
  18995. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18996. * @param radius The radius of the hemisphere to emit from
  18997. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18998. * @returns the emitter
  18999. */
  19000. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19001. /**
  19002. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19003. * @param radius The radius of the sphere to emit from
  19004. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19005. * @returns the emitter
  19006. */
  19007. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19008. /**
  19009. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19010. * @param radius The radius of the sphere to emit from
  19011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19013. * @returns the emitter
  19014. */
  19015. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19016. /**
  19017. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19018. * @param radius The radius of the emission cylinder
  19019. * @param height The height of the emission cylinder
  19020. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19021. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19022. * @returns the emitter
  19023. */
  19024. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19025. /**
  19026. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19027. * @param radius The radius of the cylinder to emit from
  19028. * @param height The height of the emission cylinder
  19029. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19030. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19031. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19032. * @returns the emitter
  19033. */
  19034. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19035. /**
  19036. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19037. * @param radius The radius of the cone to emit from
  19038. * @param angle The base angle of the cone
  19039. * @returns the emitter
  19040. */
  19041. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19042. /**
  19043. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19044. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19045. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19046. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19047. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19048. * @returns the emitter
  19049. */
  19050. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19051. /**
  19052. * Get hosting scene
  19053. * @returns the scene
  19054. */
  19055. getScene(): Scene;
  19056. }
  19057. }
  19058. declare module "babylonjs/Meshes/instancedMesh" {
  19059. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19060. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19061. import { Camera } from "babylonjs/Cameras/camera";
  19062. import { Node } from "babylonjs/node";
  19063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19064. import { Mesh } from "babylonjs/Meshes/mesh";
  19065. import { Material } from "babylonjs/Materials/material";
  19066. import { Skeleton } from "babylonjs/Bones/skeleton";
  19067. import { Light } from "babylonjs/Lights/light";
  19068. /**
  19069. * Creates an instance based on a source mesh.
  19070. */
  19071. export class InstancedMesh extends AbstractMesh {
  19072. private _sourceMesh;
  19073. private _currentLOD;
  19074. /** @hidden */
  19075. _indexInSourceMeshInstanceArray: number;
  19076. constructor(name: string, source: Mesh);
  19077. /**
  19078. * Returns the string "InstancedMesh".
  19079. */
  19080. getClassName(): string;
  19081. /** Gets the list of lights affecting that mesh */
  19082. readonly lightSources: Light[];
  19083. _resyncLightSources(): void;
  19084. _resyncLighSource(light: Light): void;
  19085. _removeLightSource(light: Light): void;
  19086. /**
  19087. * If the source mesh receives shadows
  19088. */
  19089. readonly receiveShadows: boolean;
  19090. /**
  19091. * The material of the source mesh
  19092. */
  19093. readonly material: Nullable<Material>;
  19094. /**
  19095. * Visibility of the source mesh
  19096. */
  19097. readonly visibility: number;
  19098. /**
  19099. * Skeleton of the source mesh
  19100. */
  19101. readonly skeleton: Nullable<Skeleton>;
  19102. /**
  19103. * Rendering ground id of the source mesh
  19104. */
  19105. renderingGroupId: number;
  19106. /**
  19107. * Returns the total number of vertices (integer).
  19108. */
  19109. getTotalVertices(): number;
  19110. /**
  19111. * Returns a positive integer : the total number of indices in this mesh geometry.
  19112. * @returns the numner of indices or zero if the mesh has no geometry.
  19113. */
  19114. getTotalIndices(): number;
  19115. /**
  19116. * The source mesh of the instance
  19117. */
  19118. readonly sourceMesh: Mesh;
  19119. /**
  19120. * Is this node ready to be used/rendered
  19121. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19122. * @return {boolean} is it ready
  19123. */
  19124. isReady(completeCheck?: boolean): boolean;
  19125. /**
  19126. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19127. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19128. * @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.
  19129. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19130. */
  19131. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19132. /**
  19133. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19134. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19135. * The `data` are either a numeric array either a Float32Array.
  19136. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19137. * 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).
  19138. * Note that a new underlying VertexBuffer object is created each call.
  19139. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19140. *
  19141. * Possible `kind` values :
  19142. * - VertexBuffer.PositionKind
  19143. * - VertexBuffer.UVKind
  19144. * - VertexBuffer.UV2Kind
  19145. * - VertexBuffer.UV3Kind
  19146. * - VertexBuffer.UV4Kind
  19147. * - VertexBuffer.UV5Kind
  19148. * - VertexBuffer.UV6Kind
  19149. * - VertexBuffer.ColorKind
  19150. * - VertexBuffer.MatricesIndicesKind
  19151. * - VertexBuffer.MatricesIndicesExtraKind
  19152. * - VertexBuffer.MatricesWeightsKind
  19153. * - VertexBuffer.MatricesWeightsExtraKind
  19154. *
  19155. * Returns the Mesh.
  19156. */
  19157. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19158. /**
  19159. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19160. * If the mesh has no geometry, it is simply returned as it is.
  19161. * The `data` are either a numeric array either a Float32Array.
  19162. * No new underlying VertexBuffer object is created.
  19163. * 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.
  19164. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19165. *
  19166. * Possible `kind` values :
  19167. * - VertexBuffer.PositionKind
  19168. * - VertexBuffer.UVKind
  19169. * - VertexBuffer.UV2Kind
  19170. * - VertexBuffer.UV3Kind
  19171. * - VertexBuffer.UV4Kind
  19172. * - VertexBuffer.UV5Kind
  19173. * - VertexBuffer.UV6Kind
  19174. * - VertexBuffer.ColorKind
  19175. * - VertexBuffer.MatricesIndicesKind
  19176. * - VertexBuffer.MatricesIndicesExtraKind
  19177. * - VertexBuffer.MatricesWeightsKind
  19178. * - VertexBuffer.MatricesWeightsExtraKind
  19179. *
  19180. * Returns the Mesh.
  19181. */
  19182. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19183. /**
  19184. * Sets the mesh indices.
  19185. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19186. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19187. * This method creates a new index buffer each call.
  19188. * Returns the Mesh.
  19189. */
  19190. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19191. /**
  19192. * Boolean : True if the mesh owns the requested kind of data.
  19193. */
  19194. isVerticesDataPresent(kind: string): boolean;
  19195. /**
  19196. * Returns an array of indices (IndicesArray).
  19197. */
  19198. getIndices(): Nullable<IndicesArray>;
  19199. readonly _positions: Nullable<Vector3[]>;
  19200. /**
  19201. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19202. * This means the mesh underlying bounding box and sphere are recomputed.
  19203. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19204. * @returns the current mesh
  19205. */
  19206. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19207. /** @hidden */
  19208. _preActivate(): InstancedMesh;
  19209. /** @hidden */
  19210. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19211. /** @hidden */
  19212. _postActivate(): void;
  19213. getWorldMatrix(): Matrix;
  19214. readonly isAnInstance: boolean;
  19215. /**
  19216. * Returns the current associated LOD AbstractMesh.
  19217. */
  19218. getLOD(camera: Camera): AbstractMesh;
  19219. /** @hidden */
  19220. _syncSubMeshes(): InstancedMesh;
  19221. /** @hidden */
  19222. _generatePointsArray(): boolean;
  19223. /**
  19224. * Creates a new InstancedMesh from the current mesh.
  19225. * - name (string) : the cloned mesh name
  19226. * - newParent (optional Node) : the optional Node to parent the clone to.
  19227. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19228. *
  19229. * Returns the clone.
  19230. */
  19231. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19232. /**
  19233. * Disposes the InstancedMesh.
  19234. * Returns nothing.
  19235. */
  19236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19237. }
  19238. }
  19239. declare module "babylonjs/Materials/shaderMaterial" {
  19240. import { Scene } from "babylonjs/scene";
  19241. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19243. import { Mesh } from "babylonjs/Meshes/mesh";
  19244. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19246. import { Texture } from "babylonjs/Materials/Textures/texture";
  19247. import { Material } from "babylonjs/Materials/material";
  19248. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19249. /**
  19250. * Defines the options associated with the creation of a shader material.
  19251. */
  19252. export interface IShaderMaterialOptions {
  19253. /**
  19254. * Does the material work in alpha blend mode
  19255. */
  19256. needAlphaBlending: boolean;
  19257. /**
  19258. * Does the material work in alpha test mode
  19259. */
  19260. needAlphaTesting: boolean;
  19261. /**
  19262. * The list of attribute names used in the shader
  19263. */
  19264. attributes: string[];
  19265. /**
  19266. * The list of unifrom names used in the shader
  19267. */
  19268. uniforms: string[];
  19269. /**
  19270. * The list of UBO names used in the shader
  19271. */
  19272. uniformBuffers: string[];
  19273. /**
  19274. * The list of sampler names used in the shader
  19275. */
  19276. samplers: string[];
  19277. /**
  19278. * The list of defines used in the shader
  19279. */
  19280. defines: string[];
  19281. }
  19282. /**
  19283. * 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.
  19284. *
  19285. * This returned material effects how the mesh will look based on the code in the shaders.
  19286. *
  19287. * @see http://doc.babylonjs.com/how_to/shader_material
  19288. */
  19289. export class ShaderMaterial extends Material {
  19290. private _shaderPath;
  19291. private _options;
  19292. private _textures;
  19293. private _textureArrays;
  19294. private _floats;
  19295. private _ints;
  19296. private _floatsArrays;
  19297. private _colors3;
  19298. private _colors3Arrays;
  19299. private _colors4;
  19300. private _colors4Arrays;
  19301. private _vectors2;
  19302. private _vectors3;
  19303. private _vectors4;
  19304. private _matrices;
  19305. private _matrices3x3;
  19306. private _matrices2x2;
  19307. private _vectors2Arrays;
  19308. private _vectors3Arrays;
  19309. private _vectors4Arrays;
  19310. private _cachedWorldViewMatrix;
  19311. private _cachedWorldViewProjectionMatrix;
  19312. private _renderId;
  19313. /**
  19314. * Instantiate a new shader material.
  19315. * 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.
  19316. * This returned material effects how the mesh will look based on the code in the shaders.
  19317. * @see http://doc.babylonjs.com/how_to/shader_material
  19318. * @param name Define the name of the material in the scene
  19319. * @param scene Define the scene the material belongs to
  19320. * @param shaderPath Defines the route to the shader code in one of three ways:
  19321. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19322. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19323. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19324. * @param options Define the options used to create the shader
  19325. */
  19326. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19327. /**
  19328. * Gets the options used to compile the shader.
  19329. * They can be modified to trigger a new compilation
  19330. */
  19331. readonly options: IShaderMaterialOptions;
  19332. /**
  19333. * Gets the current class name of the material e.g. "ShaderMaterial"
  19334. * Mainly use in serialization.
  19335. * @returns the class name
  19336. */
  19337. getClassName(): string;
  19338. /**
  19339. * Specifies if the material will require alpha blending
  19340. * @returns a boolean specifying if alpha blending is needed
  19341. */
  19342. needAlphaBlending(): boolean;
  19343. /**
  19344. * Specifies if this material should be rendered in alpha test mode
  19345. * @returns a boolean specifying if an alpha test is needed.
  19346. */
  19347. needAlphaTesting(): boolean;
  19348. private _checkUniform;
  19349. /**
  19350. * Set a texture in the shader.
  19351. * @param name Define the name of the uniform samplers as defined in the shader
  19352. * @param texture Define the texture to bind to this sampler
  19353. * @return the material itself allowing "fluent" like uniform updates
  19354. */
  19355. setTexture(name: string, texture: Texture): ShaderMaterial;
  19356. /**
  19357. * Set a texture array in the shader.
  19358. * @param name Define the name of the uniform sampler array as defined in the shader
  19359. * @param textures Define the list of textures to bind to this sampler
  19360. * @return the material itself allowing "fluent" like uniform updates
  19361. */
  19362. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19363. /**
  19364. * Set a float in the shader.
  19365. * @param name Define the name of the uniform as defined in the shader
  19366. * @param value Define the value to give to the uniform
  19367. * @return the material itself allowing "fluent" like uniform updates
  19368. */
  19369. setFloat(name: string, value: number): ShaderMaterial;
  19370. /**
  19371. * Set a int in the shader.
  19372. * @param name Define the name of the uniform as defined in the shader
  19373. * @param value Define the value to give to the uniform
  19374. * @return the material itself allowing "fluent" like uniform updates
  19375. */
  19376. setInt(name: string, value: number): ShaderMaterial;
  19377. /**
  19378. * Set an array of floats in the shader.
  19379. * @param name Define the name of the uniform as defined in the shader
  19380. * @param value Define the value to give to the uniform
  19381. * @return the material itself allowing "fluent" like uniform updates
  19382. */
  19383. setFloats(name: string, value: number[]): ShaderMaterial;
  19384. /**
  19385. * Set a vec3 in the shader from a Color3.
  19386. * @param name Define the name of the uniform as defined in the shader
  19387. * @param value Define the value to give to the uniform
  19388. * @return the material itself allowing "fluent" like uniform updates
  19389. */
  19390. setColor3(name: string, value: Color3): ShaderMaterial;
  19391. /**
  19392. * Set a vec3 array in the shader from a Color3 array.
  19393. * @param name Define the name of the uniform as defined in the shader
  19394. * @param value Define the value to give to the uniform
  19395. * @return the material itself allowing "fluent" like uniform updates
  19396. */
  19397. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19398. /**
  19399. * Set a vec4 in the shader from a Color4.
  19400. * @param name Define the name of the uniform as defined in the shader
  19401. * @param value Define the value to give to the uniform
  19402. * @return the material itself allowing "fluent" like uniform updates
  19403. */
  19404. setColor4(name: string, value: Color4): ShaderMaterial;
  19405. /**
  19406. * Set a vec4 array in the shader from a Color4 array.
  19407. * @param name Define the name of the uniform as defined in the shader
  19408. * @param value Define the value to give to the uniform
  19409. * @return the material itself allowing "fluent" like uniform updates
  19410. */
  19411. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19412. /**
  19413. * Set a vec2 in the shader from a Vector2.
  19414. * @param name Define the name of the uniform as defined in the shader
  19415. * @param value Define the value to give to the uniform
  19416. * @return the material itself allowing "fluent" like uniform updates
  19417. */
  19418. setVector2(name: string, value: Vector2): ShaderMaterial;
  19419. /**
  19420. * Set a vec3 in the shader from a Vector3.
  19421. * @param name Define the name of the uniform as defined in the shader
  19422. * @param value Define the value to give to the uniform
  19423. * @return the material itself allowing "fluent" like uniform updates
  19424. */
  19425. setVector3(name: string, value: Vector3): ShaderMaterial;
  19426. /**
  19427. * Set a vec4 in the shader from a Vector4.
  19428. * @param name Define the name of the uniform as defined in the shader
  19429. * @param value Define the value to give to the uniform
  19430. * @return the material itself allowing "fluent" like uniform updates
  19431. */
  19432. setVector4(name: string, value: Vector4): ShaderMaterial;
  19433. /**
  19434. * Set a mat4 in the shader from a Matrix.
  19435. * @param name Define the name of the uniform as defined in the shader
  19436. * @param value Define the value to give to the uniform
  19437. * @return the material itself allowing "fluent" like uniform updates
  19438. */
  19439. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19440. /**
  19441. * Set a mat3 in the shader from a Float32Array.
  19442. * @param name Define the name of the uniform as defined in the shader
  19443. * @param value Define the value to give to the uniform
  19444. * @return the material itself allowing "fluent" like uniform updates
  19445. */
  19446. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19447. /**
  19448. * Set a mat2 in the shader from a Float32Array.
  19449. * @param name Define the name of the uniform as defined in the shader
  19450. * @param value Define the value to give to the uniform
  19451. * @return the material itself allowing "fluent" like uniform updates
  19452. */
  19453. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19454. /**
  19455. * Set a vec2 array in the shader from a number array.
  19456. * @param name Define the name of the uniform as defined in the shader
  19457. * @param value Define the value to give to the uniform
  19458. * @return the material itself allowing "fluent" like uniform updates
  19459. */
  19460. setArray2(name: string, value: number[]): ShaderMaterial;
  19461. /**
  19462. * Set a vec3 array in the shader from a number array.
  19463. * @param name Define the name of the uniform as defined in the shader
  19464. * @param value Define the value to give to the uniform
  19465. * @return the material itself allowing "fluent" like uniform updates
  19466. */
  19467. setArray3(name: string, value: number[]): ShaderMaterial;
  19468. /**
  19469. * Set a vec4 array in the shader from a number array.
  19470. * @param name Define the name of the uniform as defined in the shader
  19471. * @param value Define the value to give to the uniform
  19472. * @return the material itself allowing "fluent" like uniform updates
  19473. */
  19474. setArray4(name: string, value: number[]): ShaderMaterial;
  19475. private _checkCache;
  19476. /**
  19477. * Specifies that the submesh is ready to be used
  19478. * @param mesh defines the mesh to check
  19479. * @param subMesh defines which submesh to check
  19480. * @param useInstances specifies that instances should be used
  19481. * @returns a boolean indicating that the submesh is ready or not
  19482. */
  19483. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19484. /**
  19485. * Checks if the material is ready to render the requested mesh
  19486. * @param mesh Define the mesh to render
  19487. * @param useInstances Define whether or not the material is used with instances
  19488. * @returns true if ready, otherwise false
  19489. */
  19490. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19491. /**
  19492. * Binds the world matrix to the material
  19493. * @param world defines the world transformation matrix
  19494. */
  19495. bindOnlyWorldMatrix(world: Matrix): void;
  19496. /**
  19497. * Binds the material to the mesh
  19498. * @param world defines the world transformation matrix
  19499. * @param mesh defines the mesh to bind the material to
  19500. */
  19501. bind(world: Matrix, mesh?: Mesh): void;
  19502. /**
  19503. * Gets the active textures from the material
  19504. * @returns an array of textures
  19505. */
  19506. getActiveTextures(): BaseTexture[];
  19507. /**
  19508. * Specifies if the material uses a texture
  19509. * @param texture defines the texture to check against the material
  19510. * @returns a boolean specifying if the material uses the texture
  19511. */
  19512. hasTexture(texture: BaseTexture): boolean;
  19513. /**
  19514. * Makes a duplicate of the material, and gives it a new name
  19515. * @param name defines the new name for the duplicated material
  19516. * @returns the cloned material
  19517. */
  19518. clone(name: string): ShaderMaterial;
  19519. /**
  19520. * Disposes the material
  19521. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19522. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19523. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19524. */
  19525. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19526. /**
  19527. * Serializes this material in a JSON representation
  19528. * @returns the serialized material object
  19529. */
  19530. serialize(): any;
  19531. /**
  19532. * Creates a shader material from parsed shader material data
  19533. * @param source defines the JSON represnetation of the material
  19534. * @param scene defines the hosting scene
  19535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19536. * @returns a new material
  19537. */
  19538. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19539. }
  19540. }
  19541. declare module "babylonjs/Shaders/color.fragment" {
  19542. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19543. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19544. /** @hidden */
  19545. export var colorPixelShader: {
  19546. name: string;
  19547. shader: string;
  19548. };
  19549. }
  19550. declare module "babylonjs/Shaders/color.vertex" {
  19551. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19552. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19553. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19554. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19555. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19556. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19557. /** @hidden */
  19558. export var colorVertexShader: {
  19559. name: string;
  19560. shader: string;
  19561. };
  19562. }
  19563. declare module "babylonjs/Meshes/linesMesh" {
  19564. import { Nullable } from "babylonjs/types";
  19565. import { Scene } from "babylonjs/scene";
  19566. import { Color3 } from "babylonjs/Maths/math.color";
  19567. import { Node } from "babylonjs/node";
  19568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19569. import { Mesh } from "babylonjs/Meshes/mesh";
  19570. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19571. import { Effect } from "babylonjs/Materials/effect";
  19572. import { Material } from "babylonjs/Materials/material";
  19573. import "babylonjs/Shaders/color.fragment";
  19574. import "babylonjs/Shaders/color.vertex";
  19575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19576. /**
  19577. * Line mesh
  19578. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19579. */
  19580. export class LinesMesh extends Mesh {
  19581. /**
  19582. * If vertex color should be applied to the mesh
  19583. */
  19584. readonly useVertexColor?: boolean | undefined;
  19585. /**
  19586. * If vertex alpha should be applied to the mesh
  19587. */
  19588. readonly useVertexAlpha?: boolean | undefined;
  19589. /**
  19590. * Color of the line (Default: White)
  19591. */
  19592. color: Color3;
  19593. /**
  19594. * Alpha of the line (Default: 1)
  19595. */
  19596. alpha: number;
  19597. /**
  19598. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19599. * This margin is expressed in world space coordinates, so its value may vary.
  19600. * Default value is 0.1
  19601. */
  19602. intersectionThreshold: number;
  19603. private _colorShader;
  19604. private color4;
  19605. /**
  19606. * Creates a new LinesMesh
  19607. * @param name defines the name
  19608. * @param scene defines the hosting scene
  19609. * @param parent defines the parent mesh if any
  19610. * @param source defines the optional source LinesMesh used to clone data from
  19611. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19612. * When false, achieved by calling a clone(), also passing False.
  19613. * This will make creation of children, recursive.
  19614. * @param useVertexColor defines if this LinesMesh supports vertex color
  19615. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19616. */
  19617. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19618. /**
  19619. * If vertex color should be applied to the mesh
  19620. */
  19621. useVertexColor?: boolean | undefined,
  19622. /**
  19623. * If vertex alpha should be applied to the mesh
  19624. */
  19625. useVertexAlpha?: boolean | undefined);
  19626. private _addClipPlaneDefine;
  19627. private _removeClipPlaneDefine;
  19628. isReady(): boolean;
  19629. /**
  19630. * Returns the string "LineMesh"
  19631. */
  19632. getClassName(): string;
  19633. /**
  19634. * @hidden
  19635. */
  19636. /**
  19637. * @hidden
  19638. */
  19639. material: Material;
  19640. /**
  19641. * @hidden
  19642. */
  19643. readonly checkCollisions: boolean;
  19644. /** @hidden */
  19645. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19646. /** @hidden */
  19647. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19648. /**
  19649. * Disposes of the line mesh
  19650. * @param doNotRecurse If children should be disposed
  19651. */
  19652. dispose(doNotRecurse?: boolean): void;
  19653. /**
  19654. * Returns a new LineMesh object cloned from the current one.
  19655. */
  19656. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19657. /**
  19658. * Creates a new InstancedLinesMesh object from the mesh model.
  19659. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19660. * @param name defines the name of the new instance
  19661. * @returns a new InstancedLinesMesh
  19662. */
  19663. createInstance(name: string): InstancedLinesMesh;
  19664. }
  19665. /**
  19666. * Creates an instance based on a source LinesMesh
  19667. */
  19668. export class InstancedLinesMesh extends InstancedMesh {
  19669. /**
  19670. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19671. * This margin is expressed in world space coordinates, so its value may vary.
  19672. * Initilized with the intersectionThreshold value of the source LinesMesh
  19673. */
  19674. intersectionThreshold: number;
  19675. constructor(name: string, source: LinesMesh);
  19676. /**
  19677. * Returns the string "InstancedLinesMesh".
  19678. */
  19679. getClassName(): string;
  19680. }
  19681. }
  19682. declare module "babylonjs/Shaders/line.fragment" {
  19683. /** @hidden */
  19684. export var linePixelShader: {
  19685. name: string;
  19686. shader: string;
  19687. };
  19688. }
  19689. declare module "babylonjs/Shaders/line.vertex" {
  19690. /** @hidden */
  19691. export var lineVertexShader: {
  19692. name: string;
  19693. shader: string;
  19694. };
  19695. }
  19696. declare module "babylonjs/Rendering/edgesRenderer" {
  19697. import { Nullable } from "babylonjs/types";
  19698. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19700. import { Vector3 } from "babylonjs/Maths/math.vector";
  19701. import { IDisposable } from "babylonjs/scene";
  19702. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19703. import "babylonjs/Shaders/line.fragment";
  19704. import "babylonjs/Shaders/line.vertex";
  19705. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19706. module "babylonjs/Meshes/abstractMesh" {
  19707. interface AbstractMesh {
  19708. /**
  19709. * Gets the edgesRenderer associated with the mesh
  19710. */
  19711. edgesRenderer: Nullable<EdgesRenderer>;
  19712. }
  19713. }
  19714. module "babylonjs/Meshes/linesMesh" {
  19715. interface LinesMesh {
  19716. /**
  19717. * Enables the edge rendering mode on the mesh.
  19718. * This mode makes the mesh edges visible
  19719. * @param epsilon defines the maximal distance between two angles to detect a face
  19720. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19721. * @returns the currentAbstractMesh
  19722. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19723. */
  19724. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19725. }
  19726. }
  19727. module "babylonjs/Meshes/linesMesh" {
  19728. interface InstancedLinesMesh {
  19729. /**
  19730. * Enables the edge rendering mode on the mesh.
  19731. * This mode makes the mesh edges visible
  19732. * @param epsilon defines the maximal distance between two angles to detect a face
  19733. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19734. * @returns the current InstancedLinesMesh
  19735. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19736. */
  19737. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19738. }
  19739. }
  19740. /**
  19741. * Defines the minimum contract an Edges renderer should follow.
  19742. */
  19743. export interface IEdgesRenderer extends IDisposable {
  19744. /**
  19745. * Gets or sets a boolean indicating if the edgesRenderer is active
  19746. */
  19747. isEnabled: boolean;
  19748. /**
  19749. * Renders the edges of the attached mesh,
  19750. */
  19751. render(): void;
  19752. /**
  19753. * Checks wether or not the edges renderer is ready to render.
  19754. * @return true if ready, otherwise false.
  19755. */
  19756. isReady(): boolean;
  19757. }
  19758. /**
  19759. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19760. */
  19761. export class EdgesRenderer implements IEdgesRenderer {
  19762. /**
  19763. * Define the size of the edges with an orthographic camera
  19764. */
  19765. edgesWidthScalerForOrthographic: number;
  19766. /**
  19767. * Define the size of the edges with a perspective camera
  19768. */
  19769. edgesWidthScalerForPerspective: number;
  19770. protected _source: AbstractMesh;
  19771. protected _linesPositions: number[];
  19772. protected _linesNormals: number[];
  19773. protected _linesIndices: number[];
  19774. protected _epsilon: number;
  19775. protected _indicesCount: number;
  19776. protected _lineShader: ShaderMaterial;
  19777. protected _ib: DataBuffer;
  19778. protected _buffers: {
  19779. [key: string]: Nullable<VertexBuffer>;
  19780. };
  19781. protected _checkVerticesInsteadOfIndices: boolean;
  19782. private _meshRebuildObserver;
  19783. private _meshDisposeObserver;
  19784. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19785. isEnabled: boolean;
  19786. /**
  19787. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19788. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19789. * @param source Mesh used to create edges
  19790. * @param epsilon sum of angles in adjacency to check for edge
  19791. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19792. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19793. */
  19794. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19795. protected _prepareRessources(): void;
  19796. /** @hidden */
  19797. _rebuild(): void;
  19798. /**
  19799. * Releases the required resources for the edges renderer
  19800. */
  19801. dispose(): void;
  19802. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19803. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19804. /**
  19805. * Checks if the pair of p0 and p1 is en edge
  19806. * @param faceIndex
  19807. * @param edge
  19808. * @param faceNormals
  19809. * @param p0
  19810. * @param p1
  19811. * @private
  19812. */
  19813. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19814. /**
  19815. * push line into the position, normal and index buffer
  19816. * @protected
  19817. */
  19818. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19819. /**
  19820. * Generates lines edges from adjacencjes
  19821. * @private
  19822. */
  19823. _generateEdgesLines(): void;
  19824. /**
  19825. * Checks wether or not the edges renderer is ready to render.
  19826. * @return true if ready, otherwise false.
  19827. */
  19828. isReady(): boolean;
  19829. /**
  19830. * Renders the edges of the attached mesh,
  19831. */
  19832. render(): void;
  19833. }
  19834. /**
  19835. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19836. */
  19837. export class LineEdgesRenderer extends EdgesRenderer {
  19838. /**
  19839. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19840. * @param source LineMesh used to generate edges
  19841. * @param epsilon not important (specified angle for edge detection)
  19842. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19843. */
  19844. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19845. /**
  19846. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19847. */
  19848. _generateEdgesLines(): void;
  19849. }
  19850. }
  19851. declare module "babylonjs/Rendering/renderingGroup" {
  19852. import { SmartArray } from "babylonjs/Misc/smartArray";
  19853. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19855. import { Nullable } from "babylonjs/types";
  19856. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19857. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19858. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19859. import { Material } from "babylonjs/Materials/material";
  19860. import { Scene } from "babylonjs/scene";
  19861. /**
  19862. * This represents the object necessary to create a rendering group.
  19863. * This is exclusively used and created by the rendering manager.
  19864. * To modify the behavior, you use the available helpers in your scene or meshes.
  19865. * @hidden
  19866. */
  19867. export class RenderingGroup {
  19868. index: number;
  19869. private static _zeroVector;
  19870. private _scene;
  19871. private _opaqueSubMeshes;
  19872. private _transparentSubMeshes;
  19873. private _alphaTestSubMeshes;
  19874. private _depthOnlySubMeshes;
  19875. private _particleSystems;
  19876. private _spriteManagers;
  19877. private _opaqueSortCompareFn;
  19878. private _alphaTestSortCompareFn;
  19879. private _transparentSortCompareFn;
  19880. private _renderOpaque;
  19881. private _renderAlphaTest;
  19882. private _renderTransparent;
  19883. /** @hidden */
  19884. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19885. onBeforeTransparentRendering: () => void;
  19886. /**
  19887. * Set the opaque sort comparison function.
  19888. * If null the sub meshes will be render in the order they were created
  19889. */
  19890. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19891. /**
  19892. * Set the alpha test sort comparison function.
  19893. * If null the sub meshes will be render in the order they were created
  19894. */
  19895. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19896. /**
  19897. * Set the transparent sort comparison function.
  19898. * If null the sub meshes will be render in the order they were created
  19899. */
  19900. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19901. /**
  19902. * Creates a new rendering group.
  19903. * @param index The rendering group index
  19904. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19905. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19906. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19907. */
  19908. 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>);
  19909. /**
  19910. * Render all the sub meshes contained in the group.
  19911. * @param customRenderFunction Used to override the default render behaviour of the group.
  19912. * @returns true if rendered some submeshes.
  19913. */
  19914. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19915. /**
  19916. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19917. * @param subMeshes The submeshes to render
  19918. */
  19919. private renderOpaqueSorted;
  19920. /**
  19921. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19922. * @param subMeshes The submeshes to render
  19923. */
  19924. private renderAlphaTestSorted;
  19925. /**
  19926. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19927. * @param subMeshes The submeshes to render
  19928. */
  19929. private renderTransparentSorted;
  19930. /**
  19931. * Renders the submeshes in a specified order.
  19932. * @param subMeshes The submeshes to sort before render
  19933. * @param sortCompareFn The comparison function use to sort
  19934. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19935. * @param transparent Specifies to activate blending if true
  19936. */
  19937. private static renderSorted;
  19938. /**
  19939. * Renders the submeshes in the order they were dispatched (no sort applied).
  19940. * @param subMeshes The submeshes to render
  19941. */
  19942. private static renderUnsorted;
  19943. /**
  19944. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19945. * are rendered back to front if in the same alpha index.
  19946. *
  19947. * @param a The first submesh
  19948. * @param b The second submesh
  19949. * @returns The result of the comparison
  19950. */
  19951. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19952. /**
  19953. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19954. * are rendered back to front.
  19955. *
  19956. * @param a The first submesh
  19957. * @param b The second submesh
  19958. * @returns The result of the comparison
  19959. */
  19960. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19961. /**
  19962. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19963. * are rendered front to back (prevent overdraw).
  19964. *
  19965. * @param a The first submesh
  19966. * @param b The second submesh
  19967. * @returns The result of the comparison
  19968. */
  19969. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19970. /**
  19971. * Resets the different lists of submeshes to prepare a new frame.
  19972. */
  19973. prepare(): void;
  19974. dispose(): void;
  19975. /**
  19976. * Inserts the submesh in its correct queue depending on its material.
  19977. * @param subMesh The submesh to dispatch
  19978. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19979. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19980. */
  19981. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19982. dispatchSprites(spriteManager: ISpriteManager): void;
  19983. dispatchParticles(particleSystem: IParticleSystem): void;
  19984. private _renderParticles;
  19985. private _renderSprites;
  19986. }
  19987. }
  19988. declare module "babylonjs/Rendering/renderingManager" {
  19989. import { Nullable } from "babylonjs/types";
  19990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19992. import { SmartArray } from "babylonjs/Misc/smartArray";
  19993. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19994. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19995. import { Material } from "babylonjs/Materials/material";
  19996. import { Scene } from "babylonjs/scene";
  19997. import { Camera } from "babylonjs/Cameras/camera";
  19998. /**
  19999. * Interface describing the different options available in the rendering manager
  20000. * regarding Auto Clear between groups.
  20001. */
  20002. export interface IRenderingManagerAutoClearSetup {
  20003. /**
  20004. * Defines whether or not autoclear is enable.
  20005. */
  20006. autoClear: boolean;
  20007. /**
  20008. * Defines whether or not to autoclear the depth buffer.
  20009. */
  20010. depth: boolean;
  20011. /**
  20012. * Defines whether or not to autoclear the stencil buffer.
  20013. */
  20014. stencil: boolean;
  20015. }
  20016. /**
  20017. * This class is used by the onRenderingGroupObservable
  20018. */
  20019. export class RenderingGroupInfo {
  20020. /**
  20021. * The Scene that being rendered
  20022. */
  20023. scene: Scene;
  20024. /**
  20025. * The camera currently used for the rendering pass
  20026. */
  20027. camera: Nullable<Camera>;
  20028. /**
  20029. * The ID of the renderingGroup being processed
  20030. */
  20031. renderingGroupId: number;
  20032. }
  20033. /**
  20034. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20035. * It is enable to manage the different groups as well as the different necessary sort functions.
  20036. * This should not be used directly aside of the few static configurations
  20037. */
  20038. export class RenderingManager {
  20039. /**
  20040. * The max id used for rendering groups (not included)
  20041. */
  20042. static MAX_RENDERINGGROUPS: number;
  20043. /**
  20044. * The min id used for rendering groups (included)
  20045. */
  20046. static MIN_RENDERINGGROUPS: number;
  20047. /**
  20048. * Used to globally prevent autoclearing scenes.
  20049. */
  20050. static AUTOCLEAR: boolean;
  20051. /**
  20052. * @hidden
  20053. */
  20054. _useSceneAutoClearSetup: boolean;
  20055. private _scene;
  20056. private _renderingGroups;
  20057. private _depthStencilBufferAlreadyCleaned;
  20058. private _autoClearDepthStencil;
  20059. private _customOpaqueSortCompareFn;
  20060. private _customAlphaTestSortCompareFn;
  20061. private _customTransparentSortCompareFn;
  20062. private _renderingGroupInfo;
  20063. /**
  20064. * Instantiates a new rendering group for a particular scene
  20065. * @param scene Defines the scene the groups belongs to
  20066. */
  20067. constructor(scene: Scene);
  20068. private _clearDepthStencilBuffer;
  20069. /**
  20070. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20071. * @hidden
  20072. */
  20073. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20074. /**
  20075. * Resets the different information of the group to prepare a new frame
  20076. * @hidden
  20077. */
  20078. reset(): void;
  20079. /**
  20080. * Dispose and release the group and its associated resources.
  20081. * @hidden
  20082. */
  20083. dispose(): void;
  20084. /**
  20085. * Clear the info related to rendering groups preventing retention points during dispose.
  20086. */
  20087. freeRenderingGroups(): void;
  20088. private _prepareRenderingGroup;
  20089. /**
  20090. * Add a sprite manager to the rendering manager in order to render it this frame.
  20091. * @param spriteManager Define the sprite manager to render
  20092. */
  20093. dispatchSprites(spriteManager: ISpriteManager): void;
  20094. /**
  20095. * Add a particle system to the rendering manager in order to render it this frame.
  20096. * @param particleSystem Define the particle system to render
  20097. */
  20098. dispatchParticles(particleSystem: IParticleSystem): void;
  20099. /**
  20100. * Add a submesh to the manager in order to render it this frame
  20101. * @param subMesh The submesh to dispatch
  20102. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20103. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20104. */
  20105. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20106. /**
  20107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20108. * This allowed control for front to back rendering or reversly depending of the special needs.
  20109. *
  20110. * @param renderingGroupId The rendering group id corresponding to its index
  20111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20114. */
  20115. 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;
  20116. /**
  20117. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20118. *
  20119. * @param renderingGroupId The rendering group id corresponding to its index
  20120. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20121. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20122. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20123. */
  20124. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20125. /**
  20126. * Gets the current auto clear configuration for one rendering group of the rendering
  20127. * manager.
  20128. * @param index the rendering group index to get the information for
  20129. * @returns The auto clear setup for the requested rendering group
  20130. */
  20131. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20132. }
  20133. }
  20134. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20135. import { Observable } from "babylonjs/Misc/observable";
  20136. import { SmartArray } from "babylonjs/Misc/smartArray";
  20137. import { Nullable } from "babylonjs/types";
  20138. import { Camera } from "babylonjs/Cameras/camera";
  20139. import { Scene } from "babylonjs/scene";
  20140. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20141. import { Color4 } from "babylonjs/Maths/math.color";
  20142. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20146. import { Texture } from "babylonjs/Materials/Textures/texture";
  20147. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20148. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20149. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20150. import { Engine } from "babylonjs/Engines/engine";
  20151. /**
  20152. * This Helps creating a texture that will be created from a camera in your scene.
  20153. * It is basically a dynamic texture that could be used to create special effects for instance.
  20154. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20155. */
  20156. export class RenderTargetTexture extends Texture {
  20157. isCube: boolean;
  20158. /**
  20159. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20160. */
  20161. static readonly REFRESHRATE_RENDER_ONCE: number;
  20162. /**
  20163. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20164. */
  20165. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20166. /**
  20167. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20168. * the central point of your effect and can save a lot of performances.
  20169. */
  20170. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20171. /**
  20172. * Use this predicate to dynamically define the list of mesh you want to render.
  20173. * If set, the renderList property will be overwritten.
  20174. */
  20175. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20176. private _renderList;
  20177. /**
  20178. * Use this list to define the list of mesh you want to render.
  20179. */
  20180. renderList: Nullable<Array<AbstractMesh>>;
  20181. private _hookArray;
  20182. /**
  20183. * Define if particles should be rendered in your texture.
  20184. */
  20185. renderParticles: boolean;
  20186. /**
  20187. * Define if sprites should be rendered in your texture.
  20188. */
  20189. renderSprites: boolean;
  20190. /**
  20191. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20192. */
  20193. coordinatesMode: number;
  20194. /**
  20195. * Define the camera used to render the texture.
  20196. */
  20197. activeCamera: Nullable<Camera>;
  20198. /**
  20199. * Override the render function of the texture with your own one.
  20200. */
  20201. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20202. /**
  20203. * Define if camera post processes should be use while rendering the texture.
  20204. */
  20205. useCameraPostProcesses: boolean;
  20206. /**
  20207. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20208. */
  20209. ignoreCameraViewport: boolean;
  20210. private _postProcessManager;
  20211. private _postProcesses;
  20212. private _resizeObserver;
  20213. /**
  20214. * An event triggered when the texture is unbind.
  20215. */
  20216. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20217. /**
  20218. * An event triggered when the texture is unbind.
  20219. */
  20220. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20221. private _onAfterUnbindObserver;
  20222. /**
  20223. * Set a after unbind callback in the texture.
  20224. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20225. */
  20226. onAfterUnbind: () => void;
  20227. /**
  20228. * An event triggered before rendering the texture
  20229. */
  20230. onBeforeRenderObservable: Observable<number>;
  20231. private _onBeforeRenderObserver;
  20232. /**
  20233. * Set a before render callback in the texture.
  20234. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20235. */
  20236. onBeforeRender: (faceIndex: number) => void;
  20237. /**
  20238. * An event triggered after rendering the texture
  20239. */
  20240. onAfterRenderObservable: Observable<number>;
  20241. private _onAfterRenderObserver;
  20242. /**
  20243. * Set a after render callback in the texture.
  20244. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20245. */
  20246. onAfterRender: (faceIndex: number) => void;
  20247. /**
  20248. * An event triggered after the texture clear
  20249. */
  20250. onClearObservable: Observable<Engine>;
  20251. private _onClearObserver;
  20252. /**
  20253. * Set a clear callback in the texture.
  20254. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20255. */
  20256. onClear: (Engine: Engine) => void;
  20257. /**
  20258. * An event triggered when the texture is resized.
  20259. */
  20260. onResizeObservable: Observable<RenderTargetTexture>;
  20261. /**
  20262. * Define the clear color of the Render Target if it should be different from the scene.
  20263. */
  20264. clearColor: Color4;
  20265. protected _size: number | {
  20266. width: number;
  20267. height: number;
  20268. };
  20269. protected _initialSizeParameter: number | {
  20270. width: number;
  20271. height: number;
  20272. } | {
  20273. ratio: number;
  20274. };
  20275. protected _sizeRatio: Nullable<number>;
  20276. /** @hidden */
  20277. _generateMipMaps: boolean;
  20278. protected _renderingManager: RenderingManager;
  20279. /** @hidden */
  20280. _waitingRenderList: string[];
  20281. protected _doNotChangeAspectRatio: boolean;
  20282. protected _currentRefreshId: number;
  20283. protected _refreshRate: number;
  20284. protected _textureMatrix: Matrix;
  20285. protected _samples: number;
  20286. protected _renderTargetOptions: RenderTargetCreationOptions;
  20287. /**
  20288. * Gets render target creation options that were used.
  20289. */
  20290. readonly renderTargetOptions: RenderTargetCreationOptions;
  20291. protected _engine: Engine;
  20292. protected _onRatioRescale(): void;
  20293. /**
  20294. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20295. * It must define where the camera used to render the texture is set
  20296. */
  20297. boundingBoxPosition: Vector3;
  20298. private _boundingBoxSize;
  20299. /**
  20300. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20301. * When defined, the cubemap will switch to local mode
  20302. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20303. * @example https://www.babylonjs-playground.com/#RNASML
  20304. */
  20305. boundingBoxSize: Vector3;
  20306. /**
  20307. * In case the RTT has been created with a depth texture, get the associated
  20308. * depth texture.
  20309. * Otherwise, return null.
  20310. */
  20311. depthStencilTexture: Nullable<InternalTexture>;
  20312. /**
  20313. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20314. * or used a shadow, depth texture...
  20315. * @param name The friendly name of the texture
  20316. * @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)
  20317. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20318. * @param generateMipMaps True if mip maps need to be generated after render.
  20319. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20320. * @param type The type of the buffer in the RTT (int, half float, float...)
  20321. * @param isCube True if a cube texture needs to be created
  20322. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20323. * @param generateDepthBuffer True to generate a depth buffer
  20324. * @param generateStencilBuffer True to generate a stencil buffer
  20325. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20326. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20327. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20328. */
  20329. constructor(name: string, size: number | {
  20330. width: number;
  20331. height: number;
  20332. } | {
  20333. ratio: number;
  20334. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20335. /**
  20336. * Creates a depth stencil texture.
  20337. * This is only available in WebGL 2 or with the depth texture extension available.
  20338. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20339. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20340. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20341. */
  20342. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20343. private _processSizeParameter;
  20344. /**
  20345. * Define the number of samples to use in case of MSAA.
  20346. * It defaults to one meaning no MSAA has been enabled.
  20347. */
  20348. samples: number;
  20349. /**
  20350. * Resets the refresh counter of the texture and start bak from scratch.
  20351. * Could be useful to regenerate the texture if it is setup to render only once.
  20352. */
  20353. resetRefreshCounter(): void;
  20354. /**
  20355. * Define the refresh rate of the texture or the rendering frequency.
  20356. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20357. */
  20358. refreshRate: number;
  20359. /**
  20360. * Adds a post process to the render target rendering passes.
  20361. * @param postProcess define the post process to add
  20362. */
  20363. addPostProcess(postProcess: PostProcess): void;
  20364. /**
  20365. * Clear all the post processes attached to the render target
  20366. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20367. */
  20368. clearPostProcesses(dispose?: boolean): void;
  20369. /**
  20370. * Remove one of the post process from the list of attached post processes to the texture
  20371. * @param postProcess define the post process to remove from the list
  20372. */
  20373. removePostProcess(postProcess: PostProcess): void;
  20374. /** @hidden */
  20375. _shouldRender(): boolean;
  20376. /**
  20377. * Gets the actual render size of the texture.
  20378. * @returns the width of the render size
  20379. */
  20380. getRenderSize(): number;
  20381. /**
  20382. * Gets the actual render width of the texture.
  20383. * @returns the width of the render size
  20384. */
  20385. getRenderWidth(): number;
  20386. /**
  20387. * Gets the actual render height of the texture.
  20388. * @returns the height of the render size
  20389. */
  20390. getRenderHeight(): number;
  20391. /**
  20392. * Get if the texture can be rescaled or not.
  20393. */
  20394. readonly canRescale: boolean;
  20395. /**
  20396. * Resize the texture using a ratio.
  20397. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20398. */
  20399. scale(ratio: number): void;
  20400. /**
  20401. * Get the texture reflection matrix used to rotate/transform the reflection.
  20402. * @returns the reflection matrix
  20403. */
  20404. getReflectionTextureMatrix(): Matrix;
  20405. /**
  20406. * Resize the texture to a new desired size.
  20407. * Be carrefull as it will recreate all the data in the new texture.
  20408. * @param size Define the new size. It can be:
  20409. * - a number for squared texture,
  20410. * - an object containing { width: number, height: number }
  20411. * - or an object containing a ratio { ratio: number }
  20412. */
  20413. resize(size: number | {
  20414. width: number;
  20415. height: number;
  20416. } | {
  20417. ratio: number;
  20418. }): void;
  20419. /**
  20420. * Renders all the objects from the render list into the texture.
  20421. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20422. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20423. */
  20424. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20425. private _bestReflectionRenderTargetDimension;
  20426. /**
  20427. * @hidden
  20428. * @param faceIndex face index to bind to if this is a cubetexture
  20429. */
  20430. _bindFrameBuffer(faceIndex?: number): void;
  20431. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20432. private renderToTarget;
  20433. /**
  20434. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20435. * This allowed control for front to back rendering or reversly depending of the special needs.
  20436. *
  20437. * @param renderingGroupId The rendering group id corresponding to its index
  20438. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20439. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20440. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20441. */
  20442. 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;
  20443. /**
  20444. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20445. *
  20446. * @param renderingGroupId The rendering group id corresponding to its index
  20447. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20448. */
  20449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20450. /**
  20451. * Clones the texture.
  20452. * @returns the cloned texture
  20453. */
  20454. clone(): RenderTargetTexture;
  20455. /**
  20456. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20457. * @returns The JSON representation of the texture
  20458. */
  20459. serialize(): any;
  20460. /**
  20461. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20462. */
  20463. disposeFramebufferObjects(): void;
  20464. /**
  20465. * Dispose the texture and release its associated resources.
  20466. */
  20467. dispose(): void;
  20468. /** @hidden */
  20469. _rebuild(): void;
  20470. /**
  20471. * Clear the info related to rendering groups preventing retention point in material dispose.
  20472. */
  20473. freeRenderingGroups(): void;
  20474. /**
  20475. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20476. * @returns the view count
  20477. */
  20478. getViewCount(): number;
  20479. }
  20480. }
  20481. declare module "babylonjs/Materials/material" {
  20482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20483. import { SmartArray } from "babylonjs/Misc/smartArray";
  20484. import { Observable } from "babylonjs/Misc/observable";
  20485. import { Nullable } from "babylonjs/types";
  20486. import { Scene } from "babylonjs/scene";
  20487. import { Matrix } from "babylonjs/Maths/math.vector";
  20488. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20490. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20491. import { Effect } from "babylonjs/Materials/effect";
  20492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20494. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20495. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20496. import { Mesh } from "babylonjs/Meshes/mesh";
  20497. import { Animation } from "babylonjs/Animations/animation";
  20498. /**
  20499. * Base class for the main features of a material in Babylon.js
  20500. */
  20501. export class Material implements IAnimatable {
  20502. /**
  20503. * Returns the triangle fill mode
  20504. */
  20505. static readonly TriangleFillMode: number;
  20506. /**
  20507. * Returns the wireframe mode
  20508. */
  20509. static readonly WireFrameFillMode: number;
  20510. /**
  20511. * Returns the point fill mode
  20512. */
  20513. static readonly PointFillMode: number;
  20514. /**
  20515. * Returns the point list draw mode
  20516. */
  20517. static readonly PointListDrawMode: number;
  20518. /**
  20519. * Returns the line list draw mode
  20520. */
  20521. static readonly LineListDrawMode: number;
  20522. /**
  20523. * Returns the line loop draw mode
  20524. */
  20525. static readonly LineLoopDrawMode: number;
  20526. /**
  20527. * Returns the line strip draw mode
  20528. */
  20529. static readonly LineStripDrawMode: number;
  20530. /**
  20531. * Returns the triangle strip draw mode
  20532. */
  20533. static readonly TriangleStripDrawMode: number;
  20534. /**
  20535. * Returns the triangle fan draw mode
  20536. */
  20537. static readonly TriangleFanDrawMode: number;
  20538. /**
  20539. * Stores the clock-wise side orientation
  20540. */
  20541. static readonly ClockWiseSideOrientation: number;
  20542. /**
  20543. * Stores the counter clock-wise side orientation
  20544. */
  20545. static readonly CounterClockWiseSideOrientation: number;
  20546. /**
  20547. * The dirty texture flag value
  20548. */
  20549. static readonly TextureDirtyFlag: number;
  20550. /**
  20551. * The dirty light flag value
  20552. */
  20553. static readonly LightDirtyFlag: number;
  20554. /**
  20555. * The dirty fresnel flag value
  20556. */
  20557. static readonly FresnelDirtyFlag: number;
  20558. /**
  20559. * The dirty attribute flag value
  20560. */
  20561. static readonly AttributesDirtyFlag: number;
  20562. /**
  20563. * The dirty misc flag value
  20564. */
  20565. static readonly MiscDirtyFlag: number;
  20566. /**
  20567. * The all dirty flag value
  20568. */
  20569. static readonly AllDirtyFlag: number;
  20570. /**
  20571. * The ID of the material
  20572. */
  20573. id: string;
  20574. /**
  20575. * Gets or sets the unique id of the material
  20576. */
  20577. uniqueId: number;
  20578. /**
  20579. * The name of the material
  20580. */
  20581. name: string;
  20582. /**
  20583. * Gets or sets user defined metadata
  20584. */
  20585. metadata: any;
  20586. /**
  20587. * For internal use only. Please do not use.
  20588. */
  20589. reservedDataStore: any;
  20590. /**
  20591. * Specifies if the ready state should be checked on each call
  20592. */
  20593. checkReadyOnEveryCall: boolean;
  20594. /**
  20595. * Specifies if the ready state should be checked once
  20596. */
  20597. checkReadyOnlyOnce: boolean;
  20598. /**
  20599. * The state of the material
  20600. */
  20601. state: string;
  20602. /**
  20603. * The alpha value of the material
  20604. */
  20605. protected _alpha: number;
  20606. /**
  20607. * List of inspectable custom properties (used by the Inspector)
  20608. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20609. */
  20610. inspectableCustomProperties: IInspectable[];
  20611. /**
  20612. * Sets the alpha value of the material
  20613. */
  20614. /**
  20615. * Gets the alpha value of the material
  20616. */
  20617. alpha: number;
  20618. /**
  20619. * Specifies if back face culling is enabled
  20620. */
  20621. protected _backFaceCulling: boolean;
  20622. /**
  20623. * Sets the back-face culling state
  20624. */
  20625. /**
  20626. * Gets the back-face culling state
  20627. */
  20628. backFaceCulling: boolean;
  20629. /**
  20630. * Stores the value for side orientation
  20631. */
  20632. sideOrientation: number;
  20633. /**
  20634. * Callback triggered when the material is compiled
  20635. */
  20636. onCompiled: Nullable<(effect: Effect) => void>;
  20637. /**
  20638. * Callback triggered when an error occurs
  20639. */
  20640. onError: Nullable<(effect: Effect, errors: string) => void>;
  20641. /**
  20642. * Callback triggered to get the render target textures
  20643. */
  20644. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20645. /**
  20646. * Gets a boolean indicating that current material needs to register RTT
  20647. */
  20648. readonly hasRenderTargetTextures: boolean;
  20649. /**
  20650. * Specifies if the material should be serialized
  20651. */
  20652. doNotSerialize: boolean;
  20653. /**
  20654. * @hidden
  20655. */
  20656. _storeEffectOnSubMeshes: boolean;
  20657. /**
  20658. * Stores the animations for the material
  20659. */
  20660. animations: Nullable<Array<Animation>>;
  20661. /**
  20662. * An event triggered when the material is disposed
  20663. */
  20664. onDisposeObservable: Observable<Material>;
  20665. /**
  20666. * An observer which watches for dispose events
  20667. */
  20668. private _onDisposeObserver;
  20669. private _onUnBindObservable;
  20670. /**
  20671. * Called during a dispose event
  20672. */
  20673. onDispose: () => void;
  20674. private _onBindObservable;
  20675. /**
  20676. * An event triggered when the material is bound
  20677. */
  20678. readonly onBindObservable: Observable<AbstractMesh>;
  20679. /**
  20680. * An observer which watches for bind events
  20681. */
  20682. private _onBindObserver;
  20683. /**
  20684. * Called during a bind event
  20685. */
  20686. onBind: (Mesh: AbstractMesh) => void;
  20687. /**
  20688. * An event triggered when the material is unbound
  20689. */
  20690. readonly onUnBindObservable: Observable<Material>;
  20691. /**
  20692. * Stores the value of the alpha mode
  20693. */
  20694. private _alphaMode;
  20695. /**
  20696. * Sets the value of the alpha mode.
  20697. *
  20698. * | Value | Type | Description |
  20699. * | --- | --- | --- |
  20700. * | 0 | ALPHA_DISABLE | |
  20701. * | 1 | ALPHA_ADD | |
  20702. * | 2 | ALPHA_COMBINE | |
  20703. * | 3 | ALPHA_SUBTRACT | |
  20704. * | 4 | ALPHA_MULTIPLY | |
  20705. * | 5 | ALPHA_MAXIMIZED | |
  20706. * | 6 | ALPHA_ONEONE | |
  20707. * | 7 | ALPHA_PREMULTIPLIED | |
  20708. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20709. * | 9 | ALPHA_INTERPOLATE | |
  20710. * | 10 | ALPHA_SCREENMODE | |
  20711. *
  20712. */
  20713. /**
  20714. * Gets the value of the alpha mode
  20715. */
  20716. alphaMode: number;
  20717. /**
  20718. * Stores the state of the need depth pre-pass value
  20719. */
  20720. private _needDepthPrePass;
  20721. /**
  20722. * Sets the need depth pre-pass value
  20723. */
  20724. /**
  20725. * Gets the depth pre-pass value
  20726. */
  20727. needDepthPrePass: boolean;
  20728. /**
  20729. * Specifies if depth writing should be disabled
  20730. */
  20731. disableDepthWrite: boolean;
  20732. /**
  20733. * Specifies if depth writing should be forced
  20734. */
  20735. forceDepthWrite: boolean;
  20736. /**
  20737. * Specifies if there should be a separate pass for culling
  20738. */
  20739. separateCullingPass: boolean;
  20740. /**
  20741. * Stores the state specifing if fog should be enabled
  20742. */
  20743. private _fogEnabled;
  20744. /**
  20745. * Sets the state for enabling fog
  20746. */
  20747. /**
  20748. * Gets the value of the fog enabled state
  20749. */
  20750. fogEnabled: boolean;
  20751. /**
  20752. * Stores the size of points
  20753. */
  20754. pointSize: number;
  20755. /**
  20756. * Stores the z offset value
  20757. */
  20758. zOffset: number;
  20759. /**
  20760. * Gets a value specifying if wireframe mode is enabled
  20761. */
  20762. /**
  20763. * Sets the state of wireframe mode
  20764. */
  20765. wireframe: boolean;
  20766. /**
  20767. * Gets the value specifying if point clouds are enabled
  20768. */
  20769. /**
  20770. * Sets the state of point cloud mode
  20771. */
  20772. pointsCloud: boolean;
  20773. /**
  20774. * Gets the material fill mode
  20775. */
  20776. /**
  20777. * Sets the material fill mode
  20778. */
  20779. fillMode: number;
  20780. /**
  20781. * @hidden
  20782. * Stores the effects for the material
  20783. */
  20784. _effect: Nullable<Effect>;
  20785. /**
  20786. * @hidden
  20787. * Specifies if the material was previously ready
  20788. */
  20789. _wasPreviouslyReady: boolean;
  20790. /**
  20791. * Specifies if uniform buffers should be used
  20792. */
  20793. private _useUBO;
  20794. /**
  20795. * Stores a reference to the scene
  20796. */
  20797. private _scene;
  20798. /**
  20799. * Stores the fill mode state
  20800. */
  20801. private _fillMode;
  20802. /**
  20803. * Specifies if the depth write state should be cached
  20804. */
  20805. private _cachedDepthWriteState;
  20806. /**
  20807. * Stores the uniform buffer
  20808. */
  20809. protected _uniformBuffer: UniformBuffer;
  20810. /** @hidden */
  20811. _indexInSceneMaterialArray: number;
  20812. /** @hidden */
  20813. meshMap: Nullable<{
  20814. [id: string]: AbstractMesh | undefined;
  20815. }>;
  20816. /**
  20817. * Creates a material instance
  20818. * @param name defines the name of the material
  20819. * @param scene defines the scene to reference
  20820. * @param doNotAdd specifies if the material should be added to the scene
  20821. */
  20822. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20823. /**
  20824. * Returns a string representation of the current material
  20825. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20826. * @returns a string with material information
  20827. */
  20828. toString(fullDetails?: boolean): string;
  20829. /**
  20830. * Gets the class name of the material
  20831. * @returns a string with the class name of the material
  20832. */
  20833. getClassName(): string;
  20834. /**
  20835. * Specifies if updates for the material been locked
  20836. */
  20837. readonly isFrozen: boolean;
  20838. /**
  20839. * Locks updates for the material
  20840. */
  20841. freeze(): void;
  20842. /**
  20843. * Unlocks updates for the material
  20844. */
  20845. unfreeze(): void;
  20846. /**
  20847. * Specifies if the material is ready to be used
  20848. * @param mesh defines the mesh to check
  20849. * @param useInstances specifies if instances should be used
  20850. * @returns a boolean indicating if the material is ready to be used
  20851. */
  20852. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20853. /**
  20854. * Specifies that the submesh is ready to be used
  20855. * @param mesh defines the mesh to check
  20856. * @param subMesh defines which submesh to check
  20857. * @param useInstances specifies that instances should be used
  20858. * @returns a boolean indicating that the submesh is ready or not
  20859. */
  20860. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20861. /**
  20862. * Returns the material effect
  20863. * @returns the effect associated with the material
  20864. */
  20865. getEffect(): Nullable<Effect>;
  20866. /**
  20867. * Returns the current scene
  20868. * @returns a Scene
  20869. */
  20870. getScene(): Scene;
  20871. /**
  20872. * Specifies if the material will require alpha blending
  20873. * @returns a boolean specifying if alpha blending is needed
  20874. */
  20875. needAlphaBlending(): boolean;
  20876. /**
  20877. * Specifies if the mesh will require alpha blending
  20878. * @param mesh defines the mesh to check
  20879. * @returns a boolean specifying if alpha blending is needed for the mesh
  20880. */
  20881. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20882. /**
  20883. * Specifies if this material should be rendered in alpha test mode
  20884. * @returns a boolean specifying if an alpha test is needed.
  20885. */
  20886. needAlphaTesting(): boolean;
  20887. /**
  20888. * Gets the texture used for the alpha test
  20889. * @returns the texture to use for alpha testing
  20890. */
  20891. getAlphaTestTexture(): Nullable<BaseTexture>;
  20892. /**
  20893. * Marks the material to indicate that it needs to be re-calculated
  20894. */
  20895. markDirty(): void;
  20896. /** @hidden */
  20897. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20898. /**
  20899. * Binds the material to the mesh
  20900. * @param world defines the world transformation matrix
  20901. * @param mesh defines the mesh to bind the material to
  20902. */
  20903. bind(world: Matrix, mesh?: Mesh): void;
  20904. /**
  20905. * Binds the submesh to the material
  20906. * @param world defines the world transformation matrix
  20907. * @param mesh defines the mesh containing the submesh
  20908. * @param subMesh defines the submesh to bind the material to
  20909. */
  20910. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20911. /**
  20912. * Binds the world matrix to the material
  20913. * @param world defines the world transformation matrix
  20914. */
  20915. bindOnlyWorldMatrix(world: Matrix): void;
  20916. /**
  20917. * Binds the scene's uniform buffer to the effect.
  20918. * @param effect defines the effect to bind to the scene uniform buffer
  20919. * @param sceneUbo defines the uniform buffer storing scene data
  20920. */
  20921. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20922. /**
  20923. * Binds the view matrix to the effect
  20924. * @param effect defines the effect to bind the view matrix to
  20925. */
  20926. bindView(effect: Effect): void;
  20927. /**
  20928. * Binds the view projection matrix to the effect
  20929. * @param effect defines the effect to bind the view projection matrix to
  20930. */
  20931. bindViewProjection(effect: Effect): void;
  20932. /**
  20933. * Specifies if material alpha testing should be turned on for the mesh
  20934. * @param mesh defines the mesh to check
  20935. */
  20936. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20937. /**
  20938. * Processes to execute after binding the material to a mesh
  20939. * @param mesh defines the rendered mesh
  20940. */
  20941. protected _afterBind(mesh?: Mesh): void;
  20942. /**
  20943. * Unbinds the material from the mesh
  20944. */
  20945. unbind(): void;
  20946. /**
  20947. * Gets the active textures from the material
  20948. * @returns an array of textures
  20949. */
  20950. getActiveTextures(): BaseTexture[];
  20951. /**
  20952. * Specifies if the material uses a texture
  20953. * @param texture defines the texture to check against the material
  20954. * @returns a boolean specifying if the material uses the texture
  20955. */
  20956. hasTexture(texture: BaseTexture): boolean;
  20957. /**
  20958. * Makes a duplicate of the material, and gives it a new name
  20959. * @param name defines the new name for the duplicated material
  20960. * @returns the cloned material
  20961. */
  20962. clone(name: string): Nullable<Material>;
  20963. /**
  20964. * Gets the meshes bound to the material
  20965. * @returns an array of meshes bound to the material
  20966. */
  20967. getBindedMeshes(): AbstractMesh[];
  20968. /**
  20969. * Force shader compilation
  20970. * @param mesh defines the mesh associated with this material
  20971. * @param onCompiled defines a function to execute once the material is compiled
  20972. * @param options defines the options to configure the compilation
  20973. */
  20974. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20975. clipPlane: boolean;
  20976. }>): void;
  20977. /**
  20978. * Force shader compilation
  20979. * @param mesh defines the mesh that will use this material
  20980. * @param options defines additional options for compiling the shaders
  20981. * @returns a promise that resolves when the compilation completes
  20982. */
  20983. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20984. clipPlane: boolean;
  20985. }>): Promise<void>;
  20986. private static readonly _AllDirtyCallBack;
  20987. private static readonly _ImageProcessingDirtyCallBack;
  20988. private static readonly _TextureDirtyCallBack;
  20989. private static readonly _FresnelDirtyCallBack;
  20990. private static readonly _MiscDirtyCallBack;
  20991. private static readonly _LightsDirtyCallBack;
  20992. private static readonly _AttributeDirtyCallBack;
  20993. private static _FresnelAndMiscDirtyCallBack;
  20994. private static _TextureAndMiscDirtyCallBack;
  20995. private static readonly _DirtyCallbackArray;
  20996. private static readonly _RunDirtyCallBacks;
  20997. /**
  20998. * Marks a define in the material to indicate that it needs to be re-computed
  20999. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21000. */
  21001. markAsDirty(flag: number): void;
  21002. /**
  21003. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21004. * @param func defines a function which checks material defines against the submeshes
  21005. */
  21006. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21007. /**
  21008. * Indicates that we need to re-calculated for all submeshes
  21009. */
  21010. protected _markAllSubMeshesAsAllDirty(): void;
  21011. /**
  21012. * Indicates that image processing needs to be re-calculated for all submeshes
  21013. */
  21014. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21015. /**
  21016. * Indicates that textures need to be re-calculated for all submeshes
  21017. */
  21018. protected _markAllSubMeshesAsTexturesDirty(): void;
  21019. /**
  21020. * Indicates that fresnel needs to be re-calculated for all submeshes
  21021. */
  21022. protected _markAllSubMeshesAsFresnelDirty(): void;
  21023. /**
  21024. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21025. */
  21026. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21027. /**
  21028. * Indicates that lights need to be re-calculated for all submeshes
  21029. */
  21030. protected _markAllSubMeshesAsLightsDirty(): void;
  21031. /**
  21032. * Indicates that attributes need to be re-calculated for all submeshes
  21033. */
  21034. protected _markAllSubMeshesAsAttributesDirty(): void;
  21035. /**
  21036. * Indicates that misc needs to be re-calculated for all submeshes
  21037. */
  21038. protected _markAllSubMeshesAsMiscDirty(): void;
  21039. /**
  21040. * Indicates that textures and misc need to be re-calculated for all submeshes
  21041. */
  21042. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21043. /**
  21044. * Disposes the material
  21045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21048. */
  21049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21050. /** @hidden */
  21051. private releaseVertexArrayObject;
  21052. /**
  21053. * Serializes this material
  21054. * @returns the serialized material object
  21055. */
  21056. serialize(): any;
  21057. /**
  21058. * Creates a material from parsed material data
  21059. * @param parsedMaterial defines parsed material data
  21060. * @param scene defines the hosting scene
  21061. * @param rootUrl defines the root URL to use to load textures
  21062. * @returns a new material
  21063. */
  21064. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21065. }
  21066. }
  21067. declare module "babylonjs/Materials/multiMaterial" {
  21068. import { Nullable } from "babylonjs/types";
  21069. import { Scene } from "babylonjs/scene";
  21070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21071. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21072. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21073. import { Material } from "babylonjs/Materials/material";
  21074. /**
  21075. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21076. * separate meshes. This can be use to improve performances.
  21077. * @see http://doc.babylonjs.com/how_to/multi_materials
  21078. */
  21079. export class MultiMaterial extends Material {
  21080. private _subMaterials;
  21081. /**
  21082. * Gets or Sets the list of Materials used within the multi material.
  21083. * They need to be ordered according to the submeshes order in the associated mesh
  21084. */
  21085. subMaterials: Nullable<Material>[];
  21086. /**
  21087. * Function used to align with Node.getChildren()
  21088. * @returns the list of Materials used within the multi material
  21089. */
  21090. getChildren(): Nullable<Material>[];
  21091. /**
  21092. * Instantiates a new Multi Material
  21093. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21094. * separate meshes. This can be use to improve performances.
  21095. * @see http://doc.babylonjs.com/how_to/multi_materials
  21096. * @param name Define the name in the scene
  21097. * @param scene Define the scene the material belongs to
  21098. */
  21099. constructor(name: string, scene: Scene);
  21100. private _hookArray;
  21101. /**
  21102. * Get one of the submaterial by its index in the submaterials array
  21103. * @param index The index to look the sub material at
  21104. * @returns The Material if the index has been defined
  21105. */
  21106. getSubMaterial(index: number): Nullable<Material>;
  21107. /**
  21108. * Get the list of active textures for the whole sub materials list.
  21109. * @returns All the textures that will be used during the rendering
  21110. */
  21111. getActiveTextures(): BaseTexture[];
  21112. /**
  21113. * Gets the current class name of the material e.g. "MultiMaterial"
  21114. * Mainly use in serialization.
  21115. * @returns the class name
  21116. */
  21117. getClassName(): string;
  21118. /**
  21119. * Checks if the material is ready to render the requested sub mesh
  21120. * @param mesh Define the mesh the submesh belongs to
  21121. * @param subMesh Define the sub mesh to look readyness for
  21122. * @param useInstances Define whether or not the material is used with instances
  21123. * @returns true if ready, otherwise false
  21124. */
  21125. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21126. /**
  21127. * Clones the current material and its related sub materials
  21128. * @param name Define the name of the newly cloned material
  21129. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21130. * @returns the cloned material
  21131. */
  21132. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21133. /**
  21134. * Serializes the materials into a JSON representation.
  21135. * @returns the JSON representation
  21136. */
  21137. serialize(): any;
  21138. /**
  21139. * Dispose the material and release its associated resources
  21140. * @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)
  21141. * @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)
  21142. * @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)
  21143. */
  21144. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21145. /**
  21146. * Creates a MultiMaterial from parsed MultiMaterial data.
  21147. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21148. * @param scene defines the hosting scene
  21149. * @returns a new MultiMaterial
  21150. */
  21151. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21152. }
  21153. }
  21154. declare module "babylonjs/Meshes/subMesh" {
  21155. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21157. import { Engine } from "babylonjs/Engines/engine";
  21158. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21159. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21160. import { Effect } from "babylonjs/Materials/effect";
  21161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21162. import { Plane } from "babylonjs/Maths/math.plane";
  21163. import { Collider } from "babylonjs/Collisions/collider";
  21164. import { Material } from "babylonjs/Materials/material";
  21165. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21167. import { Mesh } from "babylonjs/Meshes/mesh";
  21168. import { Ray } from "babylonjs/Culling/ray";
  21169. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21170. /**
  21171. * Base class for submeshes
  21172. */
  21173. export class BaseSubMesh {
  21174. /** @hidden */
  21175. _materialDefines: Nullable<MaterialDefines>;
  21176. /** @hidden */
  21177. _materialEffect: Nullable<Effect>;
  21178. /**
  21179. * Gets associated effect
  21180. */
  21181. readonly effect: Nullable<Effect>;
  21182. /**
  21183. * Sets associated effect (effect used to render this submesh)
  21184. * @param effect defines the effect to associate with
  21185. * @param defines defines the set of defines used to compile this effect
  21186. */
  21187. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21188. }
  21189. /**
  21190. * Defines a subdivision inside a mesh
  21191. */
  21192. export class SubMesh extends BaseSubMesh implements ICullable {
  21193. /** the material index to use */
  21194. materialIndex: number;
  21195. /** vertex index start */
  21196. verticesStart: number;
  21197. /** vertices count */
  21198. verticesCount: number;
  21199. /** index start */
  21200. indexStart: number;
  21201. /** indices count */
  21202. indexCount: number;
  21203. /** @hidden */
  21204. _linesIndexCount: number;
  21205. private _mesh;
  21206. private _renderingMesh;
  21207. private _boundingInfo;
  21208. private _linesIndexBuffer;
  21209. /** @hidden */
  21210. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21211. /** @hidden */
  21212. _trianglePlanes: Plane[];
  21213. /** @hidden */
  21214. _lastColliderTransformMatrix: Nullable<Matrix>;
  21215. /** @hidden */
  21216. _renderId: number;
  21217. /** @hidden */
  21218. _alphaIndex: number;
  21219. /** @hidden */
  21220. _distanceToCamera: number;
  21221. /** @hidden */
  21222. _id: number;
  21223. private _currentMaterial;
  21224. /**
  21225. * Add a new submesh to a mesh
  21226. * @param materialIndex defines the material index to use
  21227. * @param verticesStart defines vertex index start
  21228. * @param verticesCount defines vertices count
  21229. * @param indexStart defines index start
  21230. * @param indexCount defines indices count
  21231. * @param mesh defines the parent mesh
  21232. * @param renderingMesh defines an optional rendering mesh
  21233. * @param createBoundingBox defines if bounding box should be created for this submesh
  21234. * @returns the new submesh
  21235. */
  21236. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21237. /**
  21238. * Creates a new submesh
  21239. * @param materialIndex defines the material index to use
  21240. * @param verticesStart defines vertex index start
  21241. * @param verticesCount defines vertices count
  21242. * @param indexStart defines index start
  21243. * @param indexCount defines indices count
  21244. * @param mesh defines the parent mesh
  21245. * @param renderingMesh defines an optional rendering mesh
  21246. * @param createBoundingBox defines if bounding box should be created for this submesh
  21247. */
  21248. constructor(
  21249. /** the material index to use */
  21250. materialIndex: number,
  21251. /** vertex index start */
  21252. verticesStart: number,
  21253. /** vertices count */
  21254. verticesCount: number,
  21255. /** index start */
  21256. indexStart: number,
  21257. /** indices count */
  21258. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21259. /**
  21260. * Returns true if this submesh covers the entire parent mesh
  21261. * @ignorenaming
  21262. */
  21263. readonly IsGlobal: boolean;
  21264. /**
  21265. * Returns the submesh BoudingInfo object
  21266. * @returns current bounding info (or mesh's one if the submesh is global)
  21267. */
  21268. getBoundingInfo(): BoundingInfo;
  21269. /**
  21270. * Sets the submesh BoundingInfo
  21271. * @param boundingInfo defines the new bounding info to use
  21272. * @returns the SubMesh
  21273. */
  21274. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21275. /**
  21276. * Returns the mesh of the current submesh
  21277. * @return the parent mesh
  21278. */
  21279. getMesh(): AbstractMesh;
  21280. /**
  21281. * Returns the rendering mesh of the submesh
  21282. * @returns the rendering mesh (could be different from parent mesh)
  21283. */
  21284. getRenderingMesh(): Mesh;
  21285. /**
  21286. * Returns the submesh material
  21287. * @returns null or the current material
  21288. */
  21289. getMaterial(): Nullable<Material>;
  21290. /**
  21291. * Sets a new updated BoundingInfo object to the submesh
  21292. * @param data defines an optional position array to use to determine the bounding info
  21293. * @returns the SubMesh
  21294. */
  21295. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21296. /** @hidden */
  21297. _checkCollision(collider: Collider): boolean;
  21298. /**
  21299. * Updates the submesh BoundingInfo
  21300. * @param world defines the world matrix to use to update the bounding info
  21301. * @returns the submesh
  21302. */
  21303. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21304. /**
  21305. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21306. * @param frustumPlanes defines the frustum planes
  21307. * @returns true if the submesh is intersecting with the frustum
  21308. */
  21309. isInFrustum(frustumPlanes: Plane[]): boolean;
  21310. /**
  21311. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21312. * @param frustumPlanes defines the frustum planes
  21313. * @returns true if the submesh is inside the frustum
  21314. */
  21315. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21316. /**
  21317. * Renders the submesh
  21318. * @param enableAlphaMode defines if alpha needs to be used
  21319. * @returns the submesh
  21320. */
  21321. render(enableAlphaMode: boolean): SubMesh;
  21322. /**
  21323. * @hidden
  21324. */
  21325. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21326. /**
  21327. * Checks if the submesh intersects with a ray
  21328. * @param ray defines the ray to test
  21329. * @returns true is the passed ray intersects the submesh bounding box
  21330. */
  21331. canIntersects(ray: Ray): boolean;
  21332. /**
  21333. * Intersects current submesh with a ray
  21334. * @param ray defines the ray to test
  21335. * @param positions defines mesh's positions array
  21336. * @param indices defines mesh's indices array
  21337. * @param fastCheck defines if only bounding info should be used
  21338. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21339. * @returns intersection info or null if no intersection
  21340. */
  21341. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21342. /** @hidden */
  21343. private _intersectLines;
  21344. /** @hidden */
  21345. private _intersectUnIndexedLines;
  21346. /** @hidden */
  21347. private _intersectTriangles;
  21348. /** @hidden */
  21349. private _intersectUnIndexedTriangles;
  21350. /** @hidden */
  21351. _rebuild(): void;
  21352. /**
  21353. * Creates a new submesh from the passed mesh
  21354. * @param newMesh defines the new hosting mesh
  21355. * @param newRenderingMesh defines an optional rendering mesh
  21356. * @returns the new submesh
  21357. */
  21358. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21359. /**
  21360. * Release associated resources
  21361. */
  21362. dispose(): void;
  21363. /**
  21364. * Gets the class name
  21365. * @returns the string "SubMesh".
  21366. */
  21367. getClassName(): string;
  21368. /**
  21369. * Creates a new submesh from indices data
  21370. * @param materialIndex the index of the main mesh material
  21371. * @param startIndex the index where to start the copy in the mesh indices array
  21372. * @param indexCount the number of indices to copy then from the startIndex
  21373. * @param mesh the main mesh to create the submesh from
  21374. * @param renderingMesh the optional rendering mesh
  21375. * @returns a new submesh
  21376. */
  21377. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21378. }
  21379. }
  21380. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21381. /**
  21382. * Class used to represent data loading progression
  21383. */
  21384. export class SceneLoaderFlags {
  21385. private static _ForceFullSceneLoadingForIncremental;
  21386. private static _ShowLoadingScreen;
  21387. private static _CleanBoneMatrixWeights;
  21388. private static _loggingLevel;
  21389. /**
  21390. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21391. */
  21392. static ForceFullSceneLoadingForIncremental: boolean;
  21393. /**
  21394. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21395. */
  21396. static ShowLoadingScreen: boolean;
  21397. /**
  21398. * Defines the current logging level (while loading the scene)
  21399. * @ignorenaming
  21400. */
  21401. static loggingLevel: number;
  21402. /**
  21403. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21404. */
  21405. static CleanBoneMatrixWeights: boolean;
  21406. }
  21407. }
  21408. declare module "babylonjs/Meshes/geometry" {
  21409. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21410. import { Scene } from "babylonjs/scene";
  21411. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21412. import { Engine } from "babylonjs/Engines/engine";
  21413. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21414. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21415. import { Effect } from "babylonjs/Materials/effect";
  21416. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21417. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21418. import { Mesh } from "babylonjs/Meshes/mesh";
  21419. /**
  21420. * Class used to store geometry data (vertex buffers + index buffer)
  21421. */
  21422. export class Geometry implements IGetSetVerticesData {
  21423. /**
  21424. * Gets or sets the ID of the geometry
  21425. */
  21426. id: string;
  21427. /**
  21428. * Gets or sets the unique ID of the geometry
  21429. */
  21430. uniqueId: number;
  21431. /**
  21432. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21433. */
  21434. delayLoadState: number;
  21435. /**
  21436. * Gets the file containing the data to load when running in delay load state
  21437. */
  21438. delayLoadingFile: Nullable<string>;
  21439. /**
  21440. * Callback called when the geometry is updated
  21441. */
  21442. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21443. private _scene;
  21444. private _engine;
  21445. private _meshes;
  21446. private _totalVertices;
  21447. /** @hidden */
  21448. _indices: IndicesArray;
  21449. /** @hidden */
  21450. _vertexBuffers: {
  21451. [key: string]: VertexBuffer;
  21452. };
  21453. private _isDisposed;
  21454. private _extend;
  21455. private _boundingBias;
  21456. /** @hidden */
  21457. _delayInfo: Array<string>;
  21458. private _indexBuffer;
  21459. private _indexBufferIsUpdatable;
  21460. /** @hidden */
  21461. _boundingInfo: Nullable<BoundingInfo>;
  21462. /** @hidden */
  21463. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21464. /** @hidden */
  21465. _softwareSkinningFrameId: number;
  21466. private _vertexArrayObjects;
  21467. private _updatable;
  21468. /** @hidden */
  21469. _positions: Nullable<Vector3[]>;
  21470. /**
  21471. * 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
  21472. */
  21473. /**
  21474. * 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
  21475. */
  21476. boundingBias: Vector2;
  21477. /**
  21478. * Static function used to attach a new empty geometry to a mesh
  21479. * @param mesh defines the mesh to attach the geometry to
  21480. * @returns the new Geometry
  21481. */
  21482. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21483. /**
  21484. * Creates a new geometry
  21485. * @param id defines the unique ID
  21486. * @param scene defines the hosting scene
  21487. * @param vertexData defines the VertexData used to get geometry data
  21488. * @param updatable defines if geometry must be updatable (false by default)
  21489. * @param mesh defines the mesh that will be associated with the geometry
  21490. */
  21491. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21492. /**
  21493. * Gets the current extend of the geometry
  21494. */
  21495. readonly extend: {
  21496. minimum: Vector3;
  21497. maximum: Vector3;
  21498. };
  21499. /**
  21500. * Gets the hosting scene
  21501. * @returns the hosting Scene
  21502. */
  21503. getScene(): Scene;
  21504. /**
  21505. * Gets the hosting engine
  21506. * @returns the hosting Engine
  21507. */
  21508. getEngine(): Engine;
  21509. /**
  21510. * Defines if the geometry is ready to use
  21511. * @returns true if the geometry is ready to be used
  21512. */
  21513. isReady(): boolean;
  21514. /**
  21515. * Gets a value indicating that the geometry should not be serialized
  21516. */
  21517. readonly doNotSerialize: boolean;
  21518. /** @hidden */
  21519. _rebuild(): void;
  21520. /**
  21521. * Affects all geometry data in one call
  21522. * @param vertexData defines the geometry data
  21523. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21524. */
  21525. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21526. /**
  21527. * Set specific vertex data
  21528. * @param kind defines the data kind (Position, normal, etc...)
  21529. * @param data defines the vertex data to use
  21530. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21531. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21532. */
  21533. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21534. /**
  21535. * Removes a specific vertex data
  21536. * @param kind defines the data kind (Position, normal, etc...)
  21537. */
  21538. removeVerticesData(kind: string): void;
  21539. /**
  21540. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21541. * @param buffer defines the vertex buffer to use
  21542. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21543. */
  21544. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21545. /**
  21546. * Update a specific vertex buffer
  21547. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21548. * It will do nothing if the buffer is not updatable
  21549. * @param kind defines the data kind (Position, normal, etc...)
  21550. * @param data defines the data to use
  21551. * @param offset defines the offset in the target buffer where to store the data
  21552. * @param useBytes set to true if the offset is in bytes
  21553. */
  21554. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21555. /**
  21556. * Update a specific vertex buffer
  21557. * This function will create a new buffer if the current one is not updatable
  21558. * @param kind defines the data kind (Position, normal, etc...)
  21559. * @param data defines the data to use
  21560. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21561. */
  21562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21563. private _updateBoundingInfo;
  21564. /** @hidden */
  21565. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21566. /**
  21567. * Gets total number of vertices
  21568. * @returns the total number of vertices
  21569. */
  21570. getTotalVertices(): number;
  21571. /**
  21572. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21573. * @param kind defines the data kind (Position, normal, etc...)
  21574. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21575. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21576. * @returns a float array containing vertex data
  21577. */
  21578. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21579. /**
  21580. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21581. * @param kind defines the data kind (Position, normal, etc...)
  21582. * @returns true if the vertex buffer with the specified kind is updatable
  21583. */
  21584. isVertexBufferUpdatable(kind: string): boolean;
  21585. /**
  21586. * Gets a specific vertex buffer
  21587. * @param kind defines the data kind (Position, normal, etc...)
  21588. * @returns a VertexBuffer
  21589. */
  21590. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21591. /**
  21592. * Returns all vertex buffers
  21593. * @return an object holding all vertex buffers indexed by kind
  21594. */
  21595. getVertexBuffers(): Nullable<{
  21596. [key: string]: VertexBuffer;
  21597. }>;
  21598. /**
  21599. * Gets a boolean indicating if specific vertex buffer is present
  21600. * @param kind defines the data kind (Position, normal, etc...)
  21601. * @returns true if data is present
  21602. */
  21603. isVerticesDataPresent(kind: string): boolean;
  21604. /**
  21605. * Gets a list of all attached data kinds (Position, normal, etc...)
  21606. * @returns a list of string containing all kinds
  21607. */
  21608. getVerticesDataKinds(): string[];
  21609. /**
  21610. * Update index buffer
  21611. * @param indices defines the indices to store in the index buffer
  21612. * @param offset defines the offset in the target buffer where to store the data
  21613. * @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)
  21614. */
  21615. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21616. /**
  21617. * Creates a new index buffer
  21618. * @param indices defines the indices to store in the index buffer
  21619. * @param totalVertices defines the total number of vertices (could be null)
  21620. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21621. */
  21622. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21623. /**
  21624. * Return the total number of indices
  21625. * @returns the total number of indices
  21626. */
  21627. getTotalIndices(): number;
  21628. /**
  21629. * Gets the index buffer array
  21630. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21631. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21632. * @returns the index buffer array
  21633. */
  21634. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21635. /**
  21636. * Gets the index buffer
  21637. * @return the index buffer
  21638. */
  21639. getIndexBuffer(): Nullable<DataBuffer>;
  21640. /** @hidden */
  21641. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21642. /**
  21643. * Release the associated resources for a specific mesh
  21644. * @param mesh defines the source mesh
  21645. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21646. */
  21647. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21648. /**
  21649. * Apply current geometry to a given mesh
  21650. * @param mesh defines the mesh to apply geometry to
  21651. */
  21652. applyToMesh(mesh: Mesh): void;
  21653. private _updateExtend;
  21654. private _applyToMesh;
  21655. private notifyUpdate;
  21656. /**
  21657. * Load the geometry if it was flagged as delay loaded
  21658. * @param scene defines the hosting scene
  21659. * @param onLoaded defines a callback called when the geometry is loaded
  21660. */
  21661. load(scene: Scene, onLoaded?: () => void): void;
  21662. private _queueLoad;
  21663. /**
  21664. * Invert the geometry to move from a right handed system to a left handed one.
  21665. */
  21666. toLeftHanded(): void;
  21667. /** @hidden */
  21668. _resetPointsArrayCache(): void;
  21669. /** @hidden */
  21670. _generatePointsArray(): boolean;
  21671. /**
  21672. * Gets a value indicating if the geometry is disposed
  21673. * @returns true if the geometry was disposed
  21674. */
  21675. isDisposed(): boolean;
  21676. private _disposeVertexArrayObjects;
  21677. /**
  21678. * Free all associated resources
  21679. */
  21680. dispose(): void;
  21681. /**
  21682. * Clone the current geometry into a new geometry
  21683. * @param id defines the unique ID of the new geometry
  21684. * @returns a new geometry object
  21685. */
  21686. copy(id: string): Geometry;
  21687. /**
  21688. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21689. * @return a JSON representation of the current geometry data (without the vertices data)
  21690. */
  21691. serialize(): any;
  21692. private toNumberArray;
  21693. /**
  21694. * Serialize all vertices data into a JSON oject
  21695. * @returns a JSON representation of the current geometry data
  21696. */
  21697. serializeVerticeData(): any;
  21698. /**
  21699. * Extracts a clone of a mesh geometry
  21700. * @param mesh defines the source mesh
  21701. * @param id defines the unique ID of the new geometry object
  21702. * @returns the new geometry object
  21703. */
  21704. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21705. /**
  21706. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21707. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21708. * Be aware Math.random() could cause collisions, but:
  21709. * "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"
  21710. * @returns a string containing a new GUID
  21711. */
  21712. static RandomId(): string;
  21713. /** @hidden */
  21714. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21715. private static _CleanMatricesWeights;
  21716. /**
  21717. * Create a new geometry from persisted data (Using .babylon file format)
  21718. * @param parsedVertexData defines the persisted data
  21719. * @param scene defines the hosting scene
  21720. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21721. * @returns the new geometry object
  21722. */
  21723. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21724. }
  21725. }
  21726. declare module "babylonjs/Meshes/mesh.vertexData" {
  21727. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21728. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21729. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21730. import { Geometry } from "babylonjs/Meshes/geometry";
  21731. import { Mesh } from "babylonjs/Meshes/mesh";
  21732. /**
  21733. * Define an interface for all classes that will get and set the data on vertices
  21734. */
  21735. export interface IGetSetVerticesData {
  21736. /**
  21737. * Gets a boolean indicating if specific vertex data is present
  21738. * @param kind defines the vertex data kind to use
  21739. * @returns true is data kind is present
  21740. */
  21741. isVerticesDataPresent(kind: string): boolean;
  21742. /**
  21743. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21744. * @param kind defines the data kind (Position, normal, etc...)
  21745. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21746. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21747. * @returns a float array containing vertex data
  21748. */
  21749. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21750. /**
  21751. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21752. * @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.
  21753. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21754. * @returns the indices array or an empty array if the mesh has no geometry
  21755. */
  21756. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21757. /**
  21758. * Set specific vertex data
  21759. * @param kind defines the data kind (Position, normal, etc...)
  21760. * @param data defines the vertex data to use
  21761. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21762. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21763. */
  21764. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21765. /**
  21766. * Update a specific associated vertex buffer
  21767. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21768. * - VertexBuffer.PositionKind
  21769. * - VertexBuffer.UVKind
  21770. * - VertexBuffer.UV2Kind
  21771. * - VertexBuffer.UV3Kind
  21772. * - VertexBuffer.UV4Kind
  21773. * - VertexBuffer.UV5Kind
  21774. * - VertexBuffer.UV6Kind
  21775. * - VertexBuffer.ColorKind
  21776. * - VertexBuffer.MatricesIndicesKind
  21777. * - VertexBuffer.MatricesIndicesExtraKind
  21778. * - VertexBuffer.MatricesWeightsKind
  21779. * - VertexBuffer.MatricesWeightsExtraKind
  21780. * @param data defines the data source
  21781. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21782. * @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)
  21783. */
  21784. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21785. /**
  21786. * Creates a new index buffer
  21787. * @param indices defines the indices to store in the index buffer
  21788. * @param totalVertices defines the total number of vertices (could be null)
  21789. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21790. */
  21791. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21792. }
  21793. /**
  21794. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21795. */
  21796. export class VertexData {
  21797. /**
  21798. * Mesh side orientation : usually the external or front surface
  21799. */
  21800. static readonly FRONTSIDE: number;
  21801. /**
  21802. * Mesh side orientation : usually the internal or back surface
  21803. */
  21804. static readonly BACKSIDE: number;
  21805. /**
  21806. * Mesh side orientation : both internal and external or front and back surfaces
  21807. */
  21808. static readonly DOUBLESIDE: number;
  21809. /**
  21810. * Mesh side orientation : by default, `FRONTSIDE`
  21811. */
  21812. static readonly DEFAULTSIDE: number;
  21813. /**
  21814. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21815. */
  21816. positions: Nullable<FloatArray>;
  21817. /**
  21818. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21819. */
  21820. normals: Nullable<FloatArray>;
  21821. /**
  21822. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21823. */
  21824. tangents: Nullable<FloatArray>;
  21825. /**
  21826. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21827. */
  21828. uvs: Nullable<FloatArray>;
  21829. /**
  21830. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21831. */
  21832. uvs2: Nullable<FloatArray>;
  21833. /**
  21834. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21835. */
  21836. uvs3: Nullable<FloatArray>;
  21837. /**
  21838. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21839. */
  21840. uvs4: Nullable<FloatArray>;
  21841. /**
  21842. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21843. */
  21844. uvs5: Nullable<FloatArray>;
  21845. /**
  21846. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21847. */
  21848. uvs6: Nullable<FloatArray>;
  21849. /**
  21850. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21851. */
  21852. colors: Nullable<FloatArray>;
  21853. /**
  21854. * 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).
  21855. */
  21856. matricesIndices: Nullable<FloatArray>;
  21857. /**
  21858. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21859. */
  21860. matricesWeights: Nullable<FloatArray>;
  21861. /**
  21862. * An array extending the number of possible indices
  21863. */
  21864. matricesIndicesExtra: Nullable<FloatArray>;
  21865. /**
  21866. * An array extending the number of possible weights when the number of indices is extended
  21867. */
  21868. matricesWeightsExtra: Nullable<FloatArray>;
  21869. /**
  21870. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21871. */
  21872. indices: Nullable<IndicesArray>;
  21873. /**
  21874. * Uses the passed data array to set the set the values for the specified kind of data
  21875. * @param data a linear array of floating numbers
  21876. * @param kind the type of data that is being set, eg positions, colors etc
  21877. */
  21878. set(data: FloatArray, kind: string): void;
  21879. /**
  21880. * Associates the vertexData to the passed Mesh.
  21881. * Sets it as updatable or not (default `false`)
  21882. * @param mesh the mesh the vertexData is applied to
  21883. * @param updatable when used and having the value true allows new data to update the vertexData
  21884. * @returns the VertexData
  21885. */
  21886. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21887. /**
  21888. * Associates the vertexData to the passed Geometry.
  21889. * Sets it as updatable or not (default `false`)
  21890. * @param geometry the geometry the vertexData is applied to
  21891. * @param updatable when used and having the value true allows new data to update the vertexData
  21892. * @returns VertexData
  21893. */
  21894. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21895. /**
  21896. * Updates the associated mesh
  21897. * @param mesh the mesh to be updated
  21898. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21899. * @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
  21900. * @returns VertexData
  21901. */
  21902. updateMesh(mesh: Mesh): VertexData;
  21903. /**
  21904. * Updates the associated geometry
  21905. * @param geometry the geometry to be updated
  21906. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21907. * @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
  21908. * @returns VertexData.
  21909. */
  21910. updateGeometry(geometry: Geometry): VertexData;
  21911. private _applyTo;
  21912. private _update;
  21913. /**
  21914. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21915. * @param matrix the transforming matrix
  21916. * @returns the VertexData
  21917. */
  21918. transform(matrix: Matrix): VertexData;
  21919. /**
  21920. * Merges the passed VertexData into the current one
  21921. * @param other the VertexData to be merged into the current one
  21922. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21923. * @returns the modified VertexData
  21924. */
  21925. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21926. private _mergeElement;
  21927. private _validate;
  21928. /**
  21929. * Serializes the VertexData
  21930. * @returns a serialized object
  21931. */
  21932. serialize(): any;
  21933. /**
  21934. * Extracts the vertexData from a mesh
  21935. * @param mesh the mesh from which to extract the VertexData
  21936. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21937. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21938. * @returns the object VertexData associated to the passed mesh
  21939. */
  21940. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21941. /**
  21942. * Extracts the vertexData from the geometry
  21943. * @param geometry the geometry from which to extract the VertexData
  21944. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21945. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21946. * @returns the object VertexData associated to the passed mesh
  21947. */
  21948. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21949. private static _ExtractFrom;
  21950. /**
  21951. * Creates the VertexData for a Ribbon
  21952. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21953. * * pathArray array of paths, each of which an array of successive Vector3
  21954. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21955. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21956. * * 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
  21957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21958. * * 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)
  21959. * * 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)
  21960. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21961. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21962. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21963. * @returns the VertexData of the ribbon
  21964. */
  21965. static CreateRibbon(options: {
  21966. pathArray: Vector3[][];
  21967. closeArray?: boolean;
  21968. closePath?: boolean;
  21969. offset?: number;
  21970. sideOrientation?: number;
  21971. frontUVs?: Vector4;
  21972. backUVs?: Vector4;
  21973. invertUV?: boolean;
  21974. uvs?: Vector2[];
  21975. colors?: Color4[];
  21976. }): VertexData;
  21977. /**
  21978. * Creates the VertexData for a box
  21979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21980. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21981. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21982. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21983. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21984. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21985. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21986. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21987. * * 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)
  21988. * * 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)
  21989. * @returns the VertexData of the box
  21990. */
  21991. static CreateBox(options: {
  21992. size?: number;
  21993. width?: number;
  21994. height?: number;
  21995. depth?: number;
  21996. faceUV?: Vector4[];
  21997. faceColors?: Color4[];
  21998. sideOrientation?: number;
  21999. frontUVs?: Vector4;
  22000. backUVs?: Vector4;
  22001. }): VertexData;
  22002. /**
  22003. * Creates the VertexData for a tiled box
  22004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22005. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22006. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22007. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22009. * @returns the VertexData of the box
  22010. */
  22011. static CreateTiledBox(options: {
  22012. pattern?: number;
  22013. width?: number;
  22014. height?: number;
  22015. depth?: number;
  22016. tileSize?: number;
  22017. tileWidth?: number;
  22018. tileHeight?: number;
  22019. alignHorizontal?: number;
  22020. alignVertical?: number;
  22021. faceUV?: Vector4[];
  22022. faceColors?: Color4[];
  22023. sideOrientation?: number;
  22024. }): VertexData;
  22025. /**
  22026. * Creates the VertexData for a tiled plane
  22027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22028. * * pattern a limited pattern arrangement depending on the number
  22029. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22030. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22031. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22033. * * 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)
  22034. * * 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)
  22035. * @returns the VertexData of the tiled plane
  22036. */
  22037. static CreateTiledPlane(options: {
  22038. pattern?: number;
  22039. tileSize?: number;
  22040. tileWidth?: number;
  22041. tileHeight?: number;
  22042. size?: number;
  22043. width?: number;
  22044. height?: number;
  22045. alignHorizontal?: number;
  22046. alignVertical?: number;
  22047. sideOrientation?: number;
  22048. frontUVs?: Vector4;
  22049. backUVs?: Vector4;
  22050. }): VertexData;
  22051. /**
  22052. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22053. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22054. * * segments sets the number of horizontal strips optional, default 32
  22055. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22056. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22057. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22058. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22059. * * 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
  22060. * * 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
  22061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22062. * * 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)
  22063. * * 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)
  22064. * @returns the VertexData of the ellipsoid
  22065. */
  22066. static CreateSphere(options: {
  22067. segments?: number;
  22068. diameter?: number;
  22069. diameterX?: number;
  22070. diameterY?: number;
  22071. diameterZ?: number;
  22072. arc?: number;
  22073. slice?: number;
  22074. sideOrientation?: number;
  22075. frontUVs?: Vector4;
  22076. backUVs?: Vector4;
  22077. }): VertexData;
  22078. /**
  22079. * Creates the VertexData for a cylinder, cone or prism
  22080. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22081. * * height sets the height (y direction) of the cylinder, optional, default 2
  22082. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22083. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22084. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22085. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22086. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22087. * * 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
  22088. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22089. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22090. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22091. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22093. * * 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)
  22094. * * 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)
  22095. * @returns the VertexData of the cylinder, cone or prism
  22096. */
  22097. static CreateCylinder(options: {
  22098. height?: number;
  22099. diameterTop?: number;
  22100. diameterBottom?: number;
  22101. diameter?: number;
  22102. tessellation?: number;
  22103. subdivisions?: number;
  22104. arc?: number;
  22105. faceColors?: Color4[];
  22106. faceUV?: Vector4[];
  22107. hasRings?: boolean;
  22108. enclose?: boolean;
  22109. sideOrientation?: number;
  22110. frontUVs?: Vector4;
  22111. backUVs?: Vector4;
  22112. }): VertexData;
  22113. /**
  22114. * Creates the VertexData for a torus
  22115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22116. * * diameter the diameter of the torus, optional default 1
  22117. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22118. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22120. * * 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)
  22121. * * 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)
  22122. * @returns the VertexData of the torus
  22123. */
  22124. static CreateTorus(options: {
  22125. diameter?: number;
  22126. thickness?: number;
  22127. tessellation?: number;
  22128. sideOrientation?: number;
  22129. frontUVs?: Vector4;
  22130. backUVs?: Vector4;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData of the LineSystem
  22134. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22135. * - lines an array of lines, each line being an array of successive Vector3
  22136. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22137. * @returns the VertexData of the LineSystem
  22138. */
  22139. static CreateLineSystem(options: {
  22140. lines: Vector3[][];
  22141. colors?: Nullable<Color4[][]>;
  22142. }): VertexData;
  22143. /**
  22144. * Create the VertexData for a DashedLines
  22145. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22146. * - points an array successive Vector3
  22147. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22148. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22149. * - dashNb the intended total number of dashes, optional, default 200
  22150. * @returns the VertexData for the DashedLines
  22151. */
  22152. static CreateDashedLines(options: {
  22153. points: Vector3[];
  22154. dashSize?: number;
  22155. gapSize?: number;
  22156. dashNb?: number;
  22157. }): VertexData;
  22158. /**
  22159. * Creates the VertexData for a Ground
  22160. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22161. * - width the width (x direction) of the ground, optional, default 1
  22162. * - height the height (z direction) of the ground, optional, default 1
  22163. * - subdivisions the number of subdivisions per side, optional, default 1
  22164. * @returns the VertexData of the Ground
  22165. */
  22166. static CreateGround(options: {
  22167. width?: number;
  22168. height?: number;
  22169. subdivisions?: number;
  22170. subdivisionsX?: number;
  22171. subdivisionsY?: number;
  22172. }): VertexData;
  22173. /**
  22174. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22175. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22176. * * xmin the ground minimum X coordinate, optional, default -1
  22177. * * zmin the ground minimum Z coordinate, optional, default -1
  22178. * * xmax the ground maximum X coordinate, optional, default 1
  22179. * * zmax the ground maximum Z coordinate, optional, default 1
  22180. * * 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}
  22181. * * 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}
  22182. * @returns the VertexData of the TiledGround
  22183. */
  22184. static CreateTiledGround(options: {
  22185. xmin: number;
  22186. zmin: number;
  22187. xmax: number;
  22188. zmax: number;
  22189. subdivisions?: {
  22190. w: number;
  22191. h: number;
  22192. };
  22193. precision?: {
  22194. w: number;
  22195. h: number;
  22196. };
  22197. }): VertexData;
  22198. /**
  22199. * Creates the VertexData of the Ground designed from a heightmap
  22200. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22201. * * width the width (x direction) of the ground
  22202. * * height the height (z direction) of the ground
  22203. * * subdivisions the number of subdivisions per side
  22204. * * minHeight the minimum altitude on the ground, optional, default 0
  22205. * * maxHeight the maximum altitude on the ground, optional default 1
  22206. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22207. * * buffer the array holding the image color data
  22208. * * bufferWidth the width of image
  22209. * * bufferHeight the height of image
  22210. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22211. * @returns the VertexData of the Ground designed from a heightmap
  22212. */
  22213. static CreateGroundFromHeightMap(options: {
  22214. width: number;
  22215. height: number;
  22216. subdivisions: number;
  22217. minHeight: number;
  22218. maxHeight: number;
  22219. colorFilter: Color3;
  22220. buffer: Uint8Array;
  22221. bufferWidth: number;
  22222. bufferHeight: number;
  22223. alphaFilter: number;
  22224. }): VertexData;
  22225. /**
  22226. * Creates the VertexData for a Plane
  22227. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22228. * * size sets the width and height of the plane to the value of size, optional default 1
  22229. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22230. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22232. * * 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)
  22233. * * 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)
  22234. * @returns the VertexData of the box
  22235. */
  22236. static CreatePlane(options: {
  22237. size?: number;
  22238. width?: number;
  22239. height?: number;
  22240. sideOrientation?: number;
  22241. frontUVs?: Vector4;
  22242. backUVs?: Vector4;
  22243. }): VertexData;
  22244. /**
  22245. * Creates the VertexData of the Disc or regular Polygon
  22246. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22247. * * radius the radius of the disc, optional default 0.5
  22248. * * tessellation the number of polygon sides, optional, default 64
  22249. * * 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
  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 box
  22254. */
  22255. static CreateDisc(options: {
  22256. radius?: number;
  22257. tessellation?: number;
  22258. arc?: number;
  22259. sideOrientation?: number;
  22260. frontUVs?: Vector4;
  22261. backUVs?: Vector4;
  22262. }): VertexData;
  22263. /**
  22264. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22265. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22266. * @param polygon a mesh built from polygonTriangulation.build()
  22267. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22268. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22269. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22270. * @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)
  22271. * @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)
  22272. * @returns the VertexData of the Polygon
  22273. */
  22274. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22275. /**
  22276. * Creates the VertexData of the IcoSphere
  22277. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22278. * * radius the radius of the IcoSphere, optional default 1
  22279. * * radiusX allows stretching in the x direction, optional, default radius
  22280. * * radiusY allows stretching in the y direction, optional, default radius
  22281. * * radiusZ allows stretching in the z direction, optional, default radius
  22282. * * flat when true creates a flat shaded mesh, optional, default true
  22283. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22284. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22285. * * 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)
  22286. * * 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)
  22287. * @returns the VertexData of the IcoSphere
  22288. */
  22289. static CreateIcoSphere(options: {
  22290. radius?: number;
  22291. radiusX?: number;
  22292. radiusY?: number;
  22293. radiusZ?: number;
  22294. flat?: boolean;
  22295. subdivisions?: number;
  22296. sideOrientation?: number;
  22297. frontUVs?: Vector4;
  22298. backUVs?: Vector4;
  22299. }): VertexData;
  22300. /**
  22301. * Creates the VertexData for a Polyhedron
  22302. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22303. * * type provided types are:
  22304. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22305. * * 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)
  22306. * * size the size of the IcoSphere, optional default 1
  22307. * * sizeX allows stretching in the x direction, optional, default size
  22308. * * sizeY allows stretching in the y direction, optional, default size
  22309. * * sizeZ allows stretching in the z direction, optional, default size
  22310. * * 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
  22311. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22312. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22313. * * flat when true creates a flat shaded mesh, optional, default true
  22314. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22316. * * 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)
  22317. * * 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)
  22318. * @returns the VertexData of the Polyhedron
  22319. */
  22320. static CreatePolyhedron(options: {
  22321. type?: number;
  22322. size?: number;
  22323. sizeX?: number;
  22324. sizeY?: number;
  22325. sizeZ?: number;
  22326. custom?: any;
  22327. faceUV?: Vector4[];
  22328. faceColors?: Color4[];
  22329. flat?: boolean;
  22330. sideOrientation?: number;
  22331. frontUVs?: Vector4;
  22332. backUVs?: Vector4;
  22333. }): VertexData;
  22334. /**
  22335. * Creates the VertexData for a TorusKnot
  22336. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22337. * * radius the radius of the torus knot, optional, default 2
  22338. * * tube the thickness of the tube, optional, default 0.5
  22339. * * radialSegments the number of sides on each tube segments, optional, default 32
  22340. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22341. * * p the number of windings around the z axis, optional, default 2
  22342. * * q the number of windings around the x axis, optional, default 3
  22343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22344. * * 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)
  22345. * * 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)
  22346. * @returns the VertexData of the Torus Knot
  22347. */
  22348. static CreateTorusKnot(options: {
  22349. radius?: number;
  22350. tube?: number;
  22351. radialSegments?: number;
  22352. tubularSegments?: number;
  22353. p?: number;
  22354. q?: number;
  22355. sideOrientation?: number;
  22356. frontUVs?: Vector4;
  22357. backUVs?: Vector4;
  22358. }): VertexData;
  22359. /**
  22360. * Compute normals for given positions and indices
  22361. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22362. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22363. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22364. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22365. * * facetNormals : optional array of facet normals (vector3)
  22366. * * facetPositions : optional array of facet positions (vector3)
  22367. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22368. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22369. * * bInfo : optional bounding info, required for facetPartitioning computation
  22370. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22371. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22372. * * useRightHandedSystem: optional boolean to for right handed system computation
  22373. * * depthSort : optional boolean to enable the facet depth sort computation
  22374. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22375. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22376. */
  22377. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22378. facetNormals?: any;
  22379. facetPositions?: any;
  22380. facetPartitioning?: any;
  22381. ratio?: number;
  22382. bInfo?: any;
  22383. bbSize?: Vector3;
  22384. subDiv?: any;
  22385. useRightHandedSystem?: boolean;
  22386. depthSort?: boolean;
  22387. distanceTo?: Vector3;
  22388. depthSortedFacets?: any;
  22389. }): void;
  22390. /** @hidden */
  22391. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22392. /**
  22393. * Applies VertexData created from the imported parameters to the geometry
  22394. * @param parsedVertexData the parsed data from an imported file
  22395. * @param geometry the geometry to apply the VertexData to
  22396. */
  22397. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22398. }
  22399. }
  22400. declare module "babylonjs/Morph/morphTarget" {
  22401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22402. import { Observable } from "babylonjs/Misc/observable";
  22403. import { Nullable, FloatArray } from "babylonjs/types";
  22404. import { Scene } from "babylonjs/scene";
  22405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22406. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22407. /**
  22408. * Defines a target to use with MorphTargetManager
  22409. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22410. */
  22411. export class MorphTarget implements IAnimatable {
  22412. /** defines the name of the target */
  22413. name: string;
  22414. /**
  22415. * Gets or sets the list of animations
  22416. */
  22417. animations: import("babylonjs/Animations/animation").Animation[];
  22418. private _scene;
  22419. private _positions;
  22420. private _normals;
  22421. private _tangents;
  22422. private _uvs;
  22423. private _influence;
  22424. /**
  22425. * Observable raised when the influence changes
  22426. */
  22427. onInfluenceChanged: Observable<boolean>;
  22428. /** @hidden */
  22429. _onDataLayoutChanged: Observable<void>;
  22430. /**
  22431. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22432. */
  22433. influence: number;
  22434. /**
  22435. * Gets or sets the id of the morph Target
  22436. */
  22437. id: string;
  22438. private _animationPropertiesOverride;
  22439. /**
  22440. * Gets or sets the animation properties override
  22441. */
  22442. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22443. /**
  22444. * Creates a new MorphTarget
  22445. * @param name defines the name of the target
  22446. * @param influence defines the influence to use
  22447. * @param scene defines the scene the morphtarget belongs to
  22448. */
  22449. constructor(
  22450. /** defines the name of the target */
  22451. name: string, influence?: number, scene?: Nullable<Scene>);
  22452. /**
  22453. * Gets a boolean defining if the target contains position data
  22454. */
  22455. readonly hasPositions: boolean;
  22456. /**
  22457. * Gets a boolean defining if the target contains normal data
  22458. */
  22459. readonly hasNormals: boolean;
  22460. /**
  22461. * Gets a boolean defining if the target contains tangent data
  22462. */
  22463. readonly hasTangents: boolean;
  22464. /**
  22465. * Gets a boolean defining if the target contains texture coordinates data
  22466. */
  22467. readonly hasUVs: boolean;
  22468. /**
  22469. * Affects position data to this target
  22470. * @param data defines the position data to use
  22471. */
  22472. setPositions(data: Nullable<FloatArray>): void;
  22473. /**
  22474. * Gets the position data stored in this target
  22475. * @returns a FloatArray containing the position data (or null if not present)
  22476. */
  22477. getPositions(): Nullable<FloatArray>;
  22478. /**
  22479. * Affects normal data to this target
  22480. * @param data defines the normal data to use
  22481. */
  22482. setNormals(data: Nullable<FloatArray>): void;
  22483. /**
  22484. * Gets the normal data stored in this target
  22485. * @returns a FloatArray containing the normal data (or null if not present)
  22486. */
  22487. getNormals(): Nullable<FloatArray>;
  22488. /**
  22489. * Affects tangent data to this target
  22490. * @param data defines the tangent data to use
  22491. */
  22492. setTangents(data: Nullable<FloatArray>): void;
  22493. /**
  22494. * Gets the tangent data stored in this target
  22495. * @returns a FloatArray containing the tangent data (or null if not present)
  22496. */
  22497. getTangents(): Nullable<FloatArray>;
  22498. /**
  22499. * Affects texture coordinates data to this target
  22500. * @param data defines the texture coordinates data to use
  22501. */
  22502. setUVs(data: Nullable<FloatArray>): void;
  22503. /**
  22504. * Gets the texture coordinates data stored in this target
  22505. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22506. */
  22507. getUVs(): Nullable<FloatArray>;
  22508. /**
  22509. * Serializes the current target into a Serialization object
  22510. * @returns the serialized object
  22511. */
  22512. serialize(): any;
  22513. /**
  22514. * Returns the string "MorphTarget"
  22515. * @returns "MorphTarget"
  22516. */
  22517. getClassName(): string;
  22518. /**
  22519. * Creates a new target from serialized data
  22520. * @param serializationObject defines the serialized data to use
  22521. * @returns a new MorphTarget
  22522. */
  22523. static Parse(serializationObject: any): MorphTarget;
  22524. /**
  22525. * Creates a MorphTarget from mesh data
  22526. * @param mesh defines the source mesh
  22527. * @param name defines the name to use for the new target
  22528. * @param influence defines the influence to attach to the target
  22529. * @returns a new MorphTarget
  22530. */
  22531. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22532. }
  22533. }
  22534. declare module "babylonjs/Morph/morphTargetManager" {
  22535. import { Nullable } from "babylonjs/types";
  22536. import { Scene } from "babylonjs/scene";
  22537. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22538. /**
  22539. * This class is used to deform meshes using morphing between different targets
  22540. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22541. */
  22542. export class MorphTargetManager {
  22543. private _targets;
  22544. private _targetInfluenceChangedObservers;
  22545. private _targetDataLayoutChangedObservers;
  22546. private _activeTargets;
  22547. private _scene;
  22548. private _influences;
  22549. private _supportsNormals;
  22550. private _supportsTangents;
  22551. private _supportsUVs;
  22552. private _vertexCount;
  22553. private _uniqueId;
  22554. private _tempInfluences;
  22555. /**
  22556. * Gets or sets a boolean indicating if normals must be morphed
  22557. */
  22558. enableNormalMorphing: boolean;
  22559. /**
  22560. * Gets or sets a boolean indicating if tangents must be morphed
  22561. */
  22562. enableTangentMorphing: boolean;
  22563. /**
  22564. * Gets or sets a boolean indicating if UV must be morphed
  22565. */
  22566. enableUVMorphing: boolean;
  22567. /**
  22568. * Creates a new MorphTargetManager
  22569. * @param scene defines the current scene
  22570. */
  22571. constructor(scene?: Nullable<Scene>);
  22572. /**
  22573. * Gets the unique ID of this manager
  22574. */
  22575. readonly uniqueId: number;
  22576. /**
  22577. * Gets the number of vertices handled by this manager
  22578. */
  22579. readonly vertexCount: number;
  22580. /**
  22581. * Gets a boolean indicating if this manager supports morphing of normals
  22582. */
  22583. readonly supportsNormals: boolean;
  22584. /**
  22585. * Gets a boolean indicating if this manager supports morphing of tangents
  22586. */
  22587. readonly supportsTangents: boolean;
  22588. /**
  22589. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22590. */
  22591. readonly supportsUVs: boolean;
  22592. /**
  22593. * Gets the number of targets stored in this manager
  22594. */
  22595. readonly numTargets: number;
  22596. /**
  22597. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22598. */
  22599. readonly numInfluencers: number;
  22600. /**
  22601. * Gets the list of influences (one per target)
  22602. */
  22603. readonly influences: Float32Array;
  22604. /**
  22605. * Gets the active target at specified index. An active target is a target with an influence > 0
  22606. * @param index defines the index to check
  22607. * @returns the requested target
  22608. */
  22609. getActiveTarget(index: number): MorphTarget;
  22610. /**
  22611. * Gets the target at specified index
  22612. * @param index defines the index to check
  22613. * @returns the requested target
  22614. */
  22615. getTarget(index: number): MorphTarget;
  22616. /**
  22617. * Add a new target to this manager
  22618. * @param target defines the target to add
  22619. */
  22620. addTarget(target: MorphTarget): void;
  22621. /**
  22622. * Removes a target from the manager
  22623. * @param target defines the target to remove
  22624. */
  22625. removeTarget(target: MorphTarget): void;
  22626. /**
  22627. * Serializes the current manager into a Serialization object
  22628. * @returns the serialized object
  22629. */
  22630. serialize(): any;
  22631. private _syncActiveTargets;
  22632. /**
  22633. * Syncrhonize the targets with all the meshes using this morph target manager
  22634. */
  22635. synchronize(): void;
  22636. /**
  22637. * Creates a new MorphTargetManager from serialized data
  22638. * @param serializationObject defines the serialized data
  22639. * @param scene defines the hosting scene
  22640. * @returns the new MorphTargetManager
  22641. */
  22642. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22643. }
  22644. }
  22645. declare module "babylonjs/Meshes/meshLODLevel" {
  22646. import { Mesh } from "babylonjs/Meshes/mesh";
  22647. import { Nullable } from "babylonjs/types";
  22648. /**
  22649. * Class used to represent a specific level of detail of a mesh
  22650. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22651. */
  22652. export class MeshLODLevel {
  22653. /** Defines the distance where this level should star being displayed */
  22654. distance: number;
  22655. /** Defines the mesh to use to render this level */
  22656. mesh: Nullable<Mesh>;
  22657. /**
  22658. * Creates a new LOD level
  22659. * @param distance defines the distance where this level should star being displayed
  22660. * @param mesh defines the mesh to use to render this level
  22661. */
  22662. constructor(
  22663. /** Defines the distance where this level should star being displayed */
  22664. distance: number,
  22665. /** Defines the mesh to use to render this level */
  22666. mesh: Nullable<Mesh>);
  22667. }
  22668. }
  22669. declare module "babylonjs/Meshes/groundMesh" {
  22670. import { Scene } from "babylonjs/scene";
  22671. import { Vector3 } from "babylonjs/Maths/math.vector";
  22672. import { Mesh } from "babylonjs/Meshes/mesh";
  22673. /**
  22674. * Mesh representing the gorund
  22675. */
  22676. export class GroundMesh extends Mesh {
  22677. /** If octree should be generated */
  22678. generateOctree: boolean;
  22679. private _heightQuads;
  22680. /** @hidden */
  22681. _subdivisionsX: number;
  22682. /** @hidden */
  22683. _subdivisionsY: number;
  22684. /** @hidden */
  22685. _width: number;
  22686. /** @hidden */
  22687. _height: number;
  22688. /** @hidden */
  22689. _minX: number;
  22690. /** @hidden */
  22691. _maxX: number;
  22692. /** @hidden */
  22693. _minZ: number;
  22694. /** @hidden */
  22695. _maxZ: number;
  22696. constructor(name: string, scene: Scene);
  22697. /**
  22698. * "GroundMesh"
  22699. * @returns "GroundMesh"
  22700. */
  22701. getClassName(): string;
  22702. /**
  22703. * The minimum of x and y subdivisions
  22704. */
  22705. readonly subdivisions: number;
  22706. /**
  22707. * X subdivisions
  22708. */
  22709. readonly subdivisionsX: number;
  22710. /**
  22711. * Y subdivisions
  22712. */
  22713. readonly subdivisionsY: number;
  22714. /**
  22715. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22716. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22717. * @param chunksCount the number of subdivisions for x and y
  22718. * @param octreeBlocksSize (Default: 32)
  22719. */
  22720. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22721. /**
  22722. * Returns a height (y) value in the Worl system :
  22723. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22724. * @param x x coordinate
  22725. * @param z z coordinate
  22726. * @returns the ground y position if (x, z) are outside the ground surface.
  22727. */
  22728. getHeightAtCoordinates(x: number, z: number): number;
  22729. /**
  22730. * Returns a normalized vector (Vector3) orthogonal to the ground
  22731. * at the ground coordinates (x, z) expressed in the World system.
  22732. * @param x x coordinate
  22733. * @param z z coordinate
  22734. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22735. */
  22736. getNormalAtCoordinates(x: number, z: number): Vector3;
  22737. /**
  22738. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22739. * at the ground coordinates (x, z) expressed in the World system.
  22740. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22741. * @param x x coordinate
  22742. * @param z z coordinate
  22743. * @param ref vector to store the result
  22744. * @returns the GroundMesh.
  22745. */
  22746. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22747. /**
  22748. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22749. * if the ground has been updated.
  22750. * This can be used in the render loop.
  22751. * @returns the GroundMesh.
  22752. */
  22753. updateCoordinateHeights(): GroundMesh;
  22754. private _getFacetAt;
  22755. private _initHeightQuads;
  22756. private _computeHeightQuads;
  22757. /**
  22758. * Serializes this ground mesh
  22759. * @param serializationObject object to write serialization to
  22760. */
  22761. serialize(serializationObject: any): void;
  22762. /**
  22763. * Parses a serialized ground mesh
  22764. * @param parsedMesh the serialized mesh
  22765. * @param scene the scene to create the ground mesh in
  22766. * @returns the created ground mesh
  22767. */
  22768. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22769. }
  22770. }
  22771. declare module "babylonjs/Physics/physicsJoint" {
  22772. import { Vector3 } from "babylonjs/Maths/math.vector";
  22773. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22774. /**
  22775. * Interface for Physics-Joint data
  22776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22777. */
  22778. export interface PhysicsJointData {
  22779. /**
  22780. * The main pivot of the joint
  22781. */
  22782. mainPivot?: Vector3;
  22783. /**
  22784. * The connected pivot of the joint
  22785. */
  22786. connectedPivot?: Vector3;
  22787. /**
  22788. * The main axis of the joint
  22789. */
  22790. mainAxis?: Vector3;
  22791. /**
  22792. * The connected axis of the joint
  22793. */
  22794. connectedAxis?: Vector3;
  22795. /**
  22796. * The collision of the joint
  22797. */
  22798. collision?: boolean;
  22799. /**
  22800. * Native Oimo/Cannon/Energy data
  22801. */
  22802. nativeParams?: any;
  22803. }
  22804. /**
  22805. * This is a holder class for the physics joint created by the physics plugin
  22806. * It holds a set of functions to control the underlying joint
  22807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22808. */
  22809. export class PhysicsJoint {
  22810. /**
  22811. * The type of the physics joint
  22812. */
  22813. type: number;
  22814. /**
  22815. * The data for the physics joint
  22816. */
  22817. jointData: PhysicsJointData;
  22818. private _physicsJoint;
  22819. protected _physicsPlugin: IPhysicsEnginePlugin;
  22820. /**
  22821. * Initializes the physics joint
  22822. * @param type The type of the physics joint
  22823. * @param jointData The data for the physics joint
  22824. */
  22825. constructor(
  22826. /**
  22827. * The type of the physics joint
  22828. */
  22829. type: number,
  22830. /**
  22831. * The data for the physics joint
  22832. */
  22833. jointData: PhysicsJointData);
  22834. /**
  22835. * Gets the physics joint
  22836. */
  22837. /**
  22838. * Sets the physics joint
  22839. */
  22840. physicsJoint: any;
  22841. /**
  22842. * Sets the physics plugin
  22843. */
  22844. physicsPlugin: IPhysicsEnginePlugin;
  22845. /**
  22846. * Execute a function that is physics-plugin specific.
  22847. * @param {Function} func the function that will be executed.
  22848. * It accepts two parameters: the physics world and the physics joint
  22849. */
  22850. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22851. /**
  22852. * Distance-Joint type
  22853. */
  22854. static DistanceJoint: number;
  22855. /**
  22856. * Hinge-Joint type
  22857. */
  22858. static HingeJoint: number;
  22859. /**
  22860. * Ball-and-Socket joint type
  22861. */
  22862. static BallAndSocketJoint: number;
  22863. /**
  22864. * Wheel-Joint type
  22865. */
  22866. static WheelJoint: number;
  22867. /**
  22868. * Slider-Joint type
  22869. */
  22870. static SliderJoint: number;
  22871. /**
  22872. * Prismatic-Joint type
  22873. */
  22874. static PrismaticJoint: number;
  22875. /**
  22876. * Universal-Joint type
  22877. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22878. */
  22879. static UniversalJoint: number;
  22880. /**
  22881. * Hinge-Joint 2 type
  22882. */
  22883. static Hinge2Joint: number;
  22884. /**
  22885. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22886. */
  22887. static PointToPointJoint: number;
  22888. /**
  22889. * Spring-Joint type
  22890. */
  22891. static SpringJoint: number;
  22892. /**
  22893. * Lock-Joint type
  22894. */
  22895. static LockJoint: number;
  22896. }
  22897. /**
  22898. * A class representing a physics distance joint
  22899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22900. */
  22901. export class DistanceJoint extends PhysicsJoint {
  22902. /**
  22903. *
  22904. * @param jointData The data for the Distance-Joint
  22905. */
  22906. constructor(jointData: DistanceJointData);
  22907. /**
  22908. * Update the predefined distance.
  22909. * @param maxDistance The maximum preferred distance
  22910. * @param minDistance The minimum preferred distance
  22911. */
  22912. updateDistance(maxDistance: number, minDistance?: number): void;
  22913. }
  22914. /**
  22915. * Represents a Motor-Enabled Joint
  22916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22917. */
  22918. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22919. /**
  22920. * Initializes the Motor-Enabled Joint
  22921. * @param type The type of the joint
  22922. * @param jointData The physica joint data for the joint
  22923. */
  22924. constructor(type: number, jointData: PhysicsJointData);
  22925. /**
  22926. * Set the motor values.
  22927. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22928. * @param force the force to apply
  22929. * @param maxForce max force for this motor.
  22930. */
  22931. setMotor(force?: number, maxForce?: number): void;
  22932. /**
  22933. * Set the motor's limits.
  22934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22935. * @param upperLimit The upper limit of the motor
  22936. * @param lowerLimit The lower limit of the motor
  22937. */
  22938. setLimit(upperLimit: number, lowerLimit?: number): void;
  22939. }
  22940. /**
  22941. * This class represents a single physics Hinge-Joint
  22942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22943. */
  22944. export class HingeJoint extends MotorEnabledJoint {
  22945. /**
  22946. * Initializes the Hinge-Joint
  22947. * @param jointData The joint data for the Hinge-Joint
  22948. */
  22949. constructor(jointData: PhysicsJointData);
  22950. /**
  22951. * Set the motor values.
  22952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22953. * @param {number} force the force to apply
  22954. * @param {number} maxForce max force for this motor.
  22955. */
  22956. setMotor(force?: number, maxForce?: number): void;
  22957. /**
  22958. * Set the motor's limits.
  22959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22960. * @param upperLimit The upper limit of the motor
  22961. * @param lowerLimit The lower limit of the motor
  22962. */
  22963. setLimit(upperLimit: number, lowerLimit?: number): void;
  22964. }
  22965. /**
  22966. * This class represents a dual hinge physics joint (same as wheel joint)
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export class Hinge2Joint extends MotorEnabledJoint {
  22970. /**
  22971. * Initializes the Hinge2-Joint
  22972. * @param jointData The joint data for the Hinge2-Joint
  22973. */
  22974. constructor(jointData: PhysicsJointData);
  22975. /**
  22976. * Set the motor values.
  22977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22978. * @param {number} targetSpeed the speed the motor is to reach
  22979. * @param {number} maxForce max force for this motor.
  22980. * @param {motorIndex} the motor's index, 0 or 1.
  22981. */
  22982. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22983. /**
  22984. * Set the motor limits.
  22985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22986. * @param {number} upperLimit the upper limit
  22987. * @param {number} lowerLimit lower limit
  22988. * @param {motorIndex} the motor's index, 0 or 1.
  22989. */
  22990. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22991. }
  22992. /**
  22993. * Interface for a motor enabled joint
  22994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22995. */
  22996. export interface IMotorEnabledJoint {
  22997. /**
  22998. * Physics joint
  22999. */
  23000. physicsJoint: any;
  23001. /**
  23002. * Sets the motor of the motor-enabled joint
  23003. * @param force The force of the motor
  23004. * @param maxForce The maximum force of the motor
  23005. * @param motorIndex The index of the motor
  23006. */
  23007. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23008. /**
  23009. * Sets the limit of the motor
  23010. * @param upperLimit The upper limit of the motor
  23011. * @param lowerLimit The lower limit of the motor
  23012. * @param motorIndex The index of the motor
  23013. */
  23014. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23015. }
  23016. /**
  23017. * Joint data for a Distance-Joint
  23018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23019. */
  23020. export interface DistanceJointData extends PhysicsJointData {
  23021. /**
  23022. * Max distance the 2 joint objects can be apart
  23023. */
  23024. maxDistance: number;
  23025. }
  23026. /**
  23027. * Joint data from a spring joint
  23028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23029. */
  23030. export interface SpringJointData extends PhysicsJointData {
  23031. /**
  23032. * Length of the spring
  23033. */
  23034. length: number;
  23035. /**
  23036. * Stiffness of the spring
  23037. */
  23038. stiffness: number;
  23039. /**
  23040. * Damping of the spring
  23041. */
  23042. damping: number;
  23043. /** this callback will be called when applying the force to the impostors. */
  23044. forceApplicationCallback: () => void;
  23045. }
  23046. }
  23047. declare module "babylonjs/Physics/physicsRaycastResult" {
  23048. import { Vector3 } from "babylonjs/Maths/math.vector";
  23049. /**
  23050. * Holds the data for the raycast result
  23051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23052. */
  23053. export class PhysicsRaycastResult {
  23054. private _hasHit;
  23055. private _hitDistance;
  23056. private _hitNormalWorld;
  23057. private _hitPointWorld;
  23058. private _rayFromWorld;
  23059. private _rayToWorld;
  23060. /**
  23061. * Gets if there was a hit
  23062. */
  23063. readonly hasHit: boolean;
  23064. /**
  23065. * Gets the distance from the hit
  23066. */
  23067. readonly hitDistance: number;
  23068. /**
  23069. * Gets the hit normal/direction in the world
  23070. */
  23071. readonly hitNormalWorld: Vector3;
  23072. /**
  23073. * Gets the hit point in the world
  23074. */
  23075. readonly hitPointWorld: Vector3;
  23076. /**
  23077. * Gets the ray "start point" of the ray in the world
  23078. */
  23079. readonly rayFromWorld: Vector3;
  23080. /**
  23081. * Gets the ray "end point" of the ray in the world
  23082. */
  23083. readonly rayToWorld: Vector3;
  23084. /**
  23085. * Sets the hit data (normal & point in world space)
  23086. * @param hitNormalWorld defines the normal in world space
  23087. * @param hitPointWorld defines the point in world space
  23088. */
  23089. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23090. /**
  23091. * Sets the distance from the start point to the hit point
  23092. * @param distance
  23093. */
  23094. setHitDistance(distance: number): void;
  23095. /**
  23096. * Calculates the distance manually
  23097. */
  23098. calculateHitDistance(): void;
  23099. /**
  23100. * Resets all the values to default
  23101. * @param from The from point on world space
  23102. * @param to The to point on world space
  23103. */
  23104. reset(from?: Vector3, to?: Vector3): void;
  23105. }
  23106. /**
  23107. * Interface for the size containing width and height
  23108. */
  23109. interface IXYZ {
  23110. /**
  23111. * X
  23112. */
  23113. x: number;
  23114. /**
  23115. * Y
  23116. */
  23117. y: number;
  23118. /**
  23119. * Z
  23120. */
  23121. z: number;
  23122. }
  23123. }
  23124. declare module "babylonjs/Physics/IPhysicsEngine" {
  23125. import { Nullable } from "babylonjs/types";
  23126. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23128. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23129. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23130. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23131. /**
  23132. * Interface used to describe a physics joint
  23133. */
  23134. export interface PhysicsImpostorJoint {
  23135. /** Defines the main impostor to which the joint is linked */
  23136. mainImpostor: PhysicsImpostor;
  23137. /** Defines the impostor that is connected to the main impostor using this joint */
  23138. connectedImpostor: PhysicsImpostor;
  23139. /** Defines the joint itself */
  23140. joint: PhysicsJoint;
  23141. }
  23142. /** @hidden */
  23143. export interface IPhysicsEnginePlugin {
  23144. world: any;
  23145. name: string;
  23146. setGravity(gravity: Vector3): void;
  23147. setTimeStep(timeStep: number): void;
  23148. getTimeStep(): number;
  23149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23150. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23151. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23152. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23153. removePhysicsBody(impostor: PhysicsImpostor): void;
  23154. generateJoint(joint: PhysicsImpostorJoint): void;
  23155. removeJoint(joint: PhysicsImpostorJoint): void;
  23156. isSupported(): boolean;
  23157. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23159. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23160. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23161. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23162. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23163. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23164. getBodyMass(impostor: PhysicsImpostor): number;
  23165. getBodyFriction(impostor: PhysicsImpostor): number;
  23166. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23167. getBodyRestitution(impostor: PhysicsImpostor): number;
  23168. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23169. getBodyPressure?(impostor: PhysicsImpostor): number;
  23170. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23171. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23172. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23173. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23174. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23175. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23176. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23177. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23178. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23179. sleepBody(impostor: PhysicsImpostor): void;
  23180. wakeUpBody(impostor: PhysicsImpostor): void;
  23181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23182. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23183. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23184. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23185. getRadius(impostor: PhysicsImpostor): number;
  23186. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23188. dispose(): void;
  23189. }
  23190. /**
  23191. * Interface used to define a physics engine
  23192. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23193. */
  23194. export interface IPhysicsEngine {
  23195. /**
  23196. * Gets the gravity vector used by the simulation
  23197. */
  23198. gravity: Vector3;
  23199. /**
  23200. * Sets the gravity vector used by the simulation
  23201. * @param gravity defines the gravity vector to use
  23202. */
  23203. setGravity(gravity: Vector3): void;
  23204. /**
  23205. * Set the time step of the physics engine.
  23206. * Default is 1/60.
  23207. * To slow it down, enter 1/600 for example.
  23208. * To speed it up, 1/30
  23209. * @param newTimeStep the new timestep to apply to this world.
  23210. */
  23211. setTimeStep(newTimeStep: number): void;
  23212. /**
  23213. * Get the time step of the physics engine.
  23214. * @returns the current time step
  23215. */
  23216. getTimeStep(): number;
  23217. /**
  23218. * Release all resources
  23219. */
  23220. dispose(): void;
  23221. /**
  23222. * Gets the name of the current physics plugin
  23223. * @returns the name of the plugin
  23224. */
  23225. getPhysicsPluginName(): string;
  23226. /**
  23227. * Adding a new impostor for the impostor tracking.
  23228. * This will be done by the impostor itself.
  23229. * @param impostor the impostor to add
  23230. */
  23231. addImpostor(impostor: PhysicsImpostor): void;
  23232. /**
  23233. * Remove an impostor from the engine.
  23234. * This impostor and its mesh will not longer be updated by the physics engine.
  23235. * @param impostor the impostor to remove
  23236. */
  23237. removeImpostor(impostor: PhysicsImpostor): void;
  23238. /**
  23239. * Add a joint to the physics engine
  23240. * @param mainImpostor defines the main impostor to which the joint is added.
  23241. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23242. * @param joint defines the joint that will connect both impostors.
  23243. */
  23244. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23245. /**
  23246. * Removes a joint from the simulation
  23247. * @param mainImpostor defines the impostor used with the joint
  23248. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23249. * @param joint defines the joint to remove
  23250. */
  23251. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23252. /**
  23253. * Gets the current plugin used to run the simulation
  23254. * @returns current plugin
  23255. */
  23256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23257. /**
  23258. * Gets the list of physic impostors
  23259. * @returns an array of PhysicsImpostor
  23260. */
  23261. getImpostors(): Array<PhysicsImpostor>;
  23262. /**
  23263. * Gets the impostor for a physics enabled object
  23264. * @param object defines the object impersonated by the impostor
  23265. * @returns the PhysicsImpostor or null if not found
  23266. */
  23267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23268. /**
  23269. * Gets the impostor for a physics body object
  23270. * @param body defines physics body used by the impostor
  23271. * @returns the PhysicsImpostor or null if not found
  23272. */
  23273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23274. /**
  23275. * Does a raycast in the physics world
  23276. * @param from when should the ray start?
  23277. * @param to when should the ray end?
  23278. * @returns PhysicsRaycastResult
  23279. */
  23280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23281. /**
  23282. * Called by the scene. No need to call it.
  23283. * @param delta defines the timespam between frames
  23284. */
  23285. _step(delta: number): void;
  23286. }
  23287. }
  23288. declare module "babylonjs/Physics/physicsImpostor" {
  23289. import { Nullable, IndicesArray } from "babylonjs/types";
  23290. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23293. import { Scene } from "babylonjs/scene";
  23294. import { Bone } from "babylonjs/Bones/bone";
  23295. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23296. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23297. import { Space } from "babylonjs/Maths/math.axis";
  23298. /**
  23299. * The interface for the physics imposter parameters
  23300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23301. */
  23302. export interface PhysicsImpostorParameters {
  23303. /**
  23304. * The mass of the physics imposter
  23305. */
  23306. mass: number;
  23307. /**
  23308. * The friction of the physics imposter
  23309. */
  23310. friction?: number;
  23311. /**
  23312. * The coefficient of restitution of the physics imposter
  23313. */
  23314. restitution?: number;
  23315. /**
  23316. * The native options of the physics imposter
  23317. */
  23318. nativeOptions?: any;
  23319. /**
  23320. * Specifies if the parent should be ignored
  23321. */
  23322. ignoreParent?: boolean;
  23323. /**
  23324. * Specifies if bi-directional transformations should be disabled
  23325. */
  23326. disableBidirectionalTransformation?: boolean;
  23327. /**
  23328. * The pressure inside the physics imposter, soft object only
  23329. */
  23330. pressure?: number;
  23331. /**
  23332. * The stiffness the physics imposter, soft object only
  23333. */
  23334. stiffness?: number;
  23335. /**
  23336. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23337. */
  23338. velocityIterations?: number;
  23339. /**
  23340. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23341. */
  23342. positionIterations?: number;
  23343. /**
  23344. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23345. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23346. * Add to fix multiple points
  23347. */
  23348. fixedPoints?: number;
  23349. /**
  23350. * The collision margin around a soft object
  23351. */
  23352. margin?: number;
  23353. /**
  23354. * The collision margin around a soft object
  23355. */
  23356. damping?: number;
  23357. /**
  23358. * The path for a rope based on an extrusion
  23359. */
  23360. path?: any;
  23361. /**
  23362. * The shape of an extrusion used for a rope based on an extrusion
  23363. */
  23364. shape?: any;
  23365. }
  23366. /**
  23367. * Interface for a physics-enabled object
  23368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23369. */
  23370. export interface IPhysicsEnabledObject {
  23371. /**
  23372. * The position of the physics-enabled object
  23373. */
  23374. position: Vector3;
  23375. /**
  23376. * The rotation of the physics-enabled object
  23377. */
  23378. rotationQuaternion: Nullable<Quaternion>;
  23379. /**
  23380. * The scale of the physics-enabled object
  23381. */
  23382. scaling: Vector3;
  23383. /**
  23384. * The rotation of the physics-enabled object
  23385. */
  23386. rotation?: Vector3;
  23387. /**
  23388. * The parent of the physics-enabled object
  23389. */
  23390. parent?: any;
  23391. /**
  23392. * The bounding info of the physics-enabled object
  23393. * @returns The bounding info of the physics-enabled object
  23394. */
  23395. getBoundingInfo(): BoundingInfo;
  23396. /**
  23397. * Computes the world matrix
  23398. * @param force Specifies if the world matrix should be computed by force
  23399. * @returns A world matrix
  23400. */
  23401. computeWorldMatrix(force: boolean): Matrix;
  23402. /**
  23403. * Gets the world matrix
  23404. * @returns A world matrix
  23405. */
  23406. getWorldMatrix?(): Matrix;
  23407. /**
  23408. * Gets the child meshes
  23409. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23410. * @returns An array of abstract meshes
  23411. */
  23412. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23413. /**
  23414. * Gets the vertex data
  23415. * @param kind The type of vertex data
  23416. * @returns A nullable array of numbers, or a float32 array
  23417. */
  23418. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23419. /**
  23420. * Gets the indices from the mesh
  23421. * @returns A nullable array of index arrays
  23422. */
  23423. getIndices?(): Nullable<IndicesArray>;
  23424. /**
  23425. * Gets the scene from the mesh
  23426. * @returns the indices array or null
  23427. */
  23428. getScene?(): Scene;
  23429. /**
  23430. * Gets the absolute position from the mesh
  23431. * @returns the absolute position
  23432. */
  23433. getAbsolutePosition(): Vector3;
  23434. /**
  23435. * Gets the absolute pivot point from the mesh
  23436. * @returns the absolute pivot point
  23437. */
  23438. getAbsolutePivotPoint(): Vector3;
  23439. /**
  23440. * Rotates the mesh
  23441. * @param axis The axis of rotation
  23442. * @param amount The amount of rotation
  23443. * @param space The space of the rotation
  23444. * @returns The rotation transform node
  23445. */
  23446. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23447. /**
  23448. * Translates the mesh
  23449. * @param axis The axis of translation
  23450. * @param distance The distance of translation
  23451. * @param space The space of the translation
  23452. * @returns The transform node
  23453. */
  23454. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23455. /**
  23456. * Sets the absolute position of the mesh
  23457. * @param absolutePosition The absolute position of the mesh
  23458. * @returns The transform node
  23459. */
  23460. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23461. /**
  23462. * Gets the class name of the mesh
  23463. * @returns The class name
  23464. */
  23465. getClassName(): string;
  23466. }
  23467. /**
  23468. * Represents a physics imposter
  23469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23470. */
  23471. export class PhysicsImpostor {
  23472. /**
  23473. * The physics-enabled object used as the physics imposter
  23474. */
  23475. object: IPhysicsEnabledObject;
  23476. /**
  23477. * The type of the physics imposter
  23478. */
  23479. type: number;
  23480. private _options;
  23481. private _scene?;
  23482. /**
  23483. * The default object size of the imposter
  23484. */
  23485. static DEFAULT_OBJECT_SIZE: Vector3;
  23486. /**
  23487. * The identity quaternion of the imposter
  23488. */
  23489. static IDENTITY_QUATERNION: Quaternion;
  23490. /** @hidden */
  23491. _pluginData: any;
  23492. private _physicsEngine;
  23493. private _physicsBody;
  23494. private _bodyUpdateRequired;
  23495. private _onBeforePhysicsStepCallbacks;
  23496. private _onAfterPhysicsStepCallbacks;
  23497. /** @hidden */
  23498. _onPhysicsCollideCallbacks: Array<{
  23499. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23500. otherImpostors: Array<PhysicsImpostor>;
  23501. }>;
  23502. private _deltaPosition;
  23503. private _deltaRotation;
  23504. private _deltaRotationConjugated;
  23505. /** @hidden */
  23506. _isFromLine: boolean;
  23507. private _parent;
  23508. private _isDisposed;
  23509. private static _tmpVecs;
  23510. private static _tmpQuat;
  23511. /**
  23512. * Specifies if the physics imposter is disposed
  23513. */
  23514. readonly isDisposed: boolean;
  23515. /**
  23516. * Gets the mass of the physics imposter
  23517. */
  23518. mass: number;
  23519. /**
  23520. * Gets the coefficient of friction
  23521. */
  23522. /**
  23523. * Sets the coefficient of friction
  23524. */
  23525. friction: number;
  23526. /**
  23527. * Gets the coefficient of restitution
  23528. */
  23529. /**
  23530. * Sets the coefficient of restitution
  23531. */
  23532. restitution: number;
  23533. /**
  23534. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23535. */
  23536. /**
  23537. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23538. */
  23539. pressure: number;
  23540. /**
  23541. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23542. */
  23543. /**
  23544. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23545. */
  23546. stiffness: number;
  23547. /**
  23548. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23549. */
  23550. /**
  23551. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23552. */
  23553. velocityIterations: number;
  23554. /**
  23555. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23556. */
  23557. /**
  23558. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23559. */
  23560. positionIterations: number;
  23561. /**
  23562. * The unique id of the physics imposter
  23563. * set by the physics engine when adding this impostor to the array
  23564. */
  23565. uniqueId: number;
  23566. /**
  23567. * @hidden
  23568. */
  23569. soft: boolean;
  23570. /**
  23571. * @hidden
  23572. */
  23573. segments: number;
  23574. private _joints;
  23575. /**
  23576. * Initializes the physics imposter
  23577. * @param object The physics-enabled object used as the physics imposter
  23578. * @param type The type of the physics imposter
  23579. * @param _options The options for the physics imposter
  23580. * @param _scene The Babylon scene
  23581. */
  23582. constructor(
  23583. /**
  23584. * The physics-enabled object used as the physics imposter
  23585. */
  23586. object: IPhysicsEnabledObject,
  23587. /**
  23588. * The type of the physics imposter
  23589. */
  23590. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23591. /**
  23592. * This function will completly initialize this impostor.
  23593. * It will create a new body - but only if this mesh has no parent.
  23594. * If it has, this impostor will not be used other than to define the impostor
  23595. * of the child mesh.
  23596. * @hidden
  23597. */
  23598. _init(): void;
  23599. private _getPhysicsParent;
  23600. /**
  23601. * Should a new body be generated.
  23602. * @returns boolean specifying if body initialization is required
  23603. */
  23604. isBodyInitRequired(): boolean;
  23605. /**
  23606. * Sets the updated scaling
  23607. * @param updated Specifies if the scaling is updated
  23608. */
  23609. setScalingUpdated(): void;
  23610. /**
  23611. * Force a regeneration of this or the parent's impostor's body.
  23612. * Use under cautious - This will remove all joints already implemented.
  23613. */
  23614. forceUpdate(): void;
  23615. /**
  23616. * Gets the body that holds this impostor. Either its own, or its parent.
  23617. */
  23618. /**
  23619. * Set the physics body. Used mainly by the physics engine/plugin
  23620. */
  23621. physicsBody: any;
  23622. /**
  23623. * Get the parent of the physics imposter
  23624. * @returns Physics imposter or null
  23625. */
  23626. /**
  23627. * Sets the parent of the physics imposter
  23628. */
  23629. parent: Nullable<PhysicsImpostor>;
  23630. /**
  23631. * Resets the update flags
  23632. */
  23633. resetUpdateFlags(): void;
  23634. /**
  23635. * Gets the object extend size
  23636. * @returns the object extend size
  23637. */
  23638. getObjectExtendSize(): Vector3;
  23639. /**
  23640. * Gets the object center
  23641. * @returns The object center
  23642. */
  23643. getObjectCenter(): Vector3;
  23644. /**
  23645. * Get a specific parametes from the options parameter
  23646. * @param paramName The object parameter name
  23647. * @returns The object parameter
  23648. */
  23649. getParam(paramName: string): any;
  23650. /**
  23651. * Sets a specific parameter in the options given to the physics plugin
  23652. * @param paramName The parameter name
  23653. * @param value The value of the parameter
  23654. */
  23655. setParam(paramName: string, value: number): void;
  23656. /**
  23657. * Specifically change the body's mass option. Won't recreate the physics body object
  23658. * @param mass The mass of the physics imposter
  23659. */
  23660. setMass(mass: number): void;
  23661. /**
  23662. * Gets the linear velocity
  23663. * @returns linear velocity or null
  23664. */
  23665. getLinearVelocity(): Nullable<Vector3>;
  23666. /**
  23667. * Sets the linear velocity
  23668. * @param velocity linear velocity or null
  23669. */
  23670. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23671. /**
  23672. * Gets the angular velocity
  23673. * @returns angular velocity or null
  23674. */
  23675. getAngularVelocity(): Nullable<Vector3>;
  23676. /**
  23677. * Sets the angular velocity
  23678. * @param velocity The velocity or null
  23679. */
  23680. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23681. /**
  23682. * Execute a function with the physics plugin native code
  23683. * Provide a function the will have two variables - the world object and the physics body object
  23684. * @param func The function to execute with the physics plugin native code
  23685. */
  23686. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23687. /**
  23688. * Register a function that will be executed before the physics world is stepping forward
  23689. * @param func The function to execute before the physics world is stepped forward
  23690. */
  23691. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23692. /**
  23693. * Unregister a function that will be executed before the physics world is stepping forward
  23694. * @param func The function to execute before the physics world is stepped forward
  23695. */
  23696. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23697. /**
  23698. * Register a function that will be executed after the physics step
  23699. * @param func The function to execute after physics step
  23700. */
  23701. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23702. /**
  23703. * Unregisters a function that will be executed after the physics step
  23704. * @param func The function to execute after physics step
  23705. */
  23706. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23707. /**
  23708. * register a function that will be executed when this impostor collides against a different body
  23709. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23710. * @param func Callback that is executed on collision
  23711. */
  23712. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23713. /**
  23714. * Unregisters the physics imposter on contact
  23715. * @param collideAgainst The physics object to collide against
  23716. * @param func Callback to execute on collision
  23717. */
  23718. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23719. private _tmpQuat;
  23720. private _tmpQuat2;
  23721. /**
  23722. * Get the parent rotation
  23723. * @returns The parent rotation
  23724. */
  23725. getParentsRotation(): Quaternion;
  23726. /**
  23727. * this function is executed by the physics engine.
  23728. */
  23729. beforeStep: () => void;
  23730. /**
  23731. * this function is executed by the physics engine
  23732. */
  23733. afterStep: () => void;
  23734. /**
  23735. * Legacy collision detection event support
  23736. */
  23737. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23738. /**
  23739. * event and body object due to cannon's event-based architecture.
  23740. */
  23741. onCollide: (e: {
  23742. body: any;
  23743. }) => void;
  23744. /**
  23745. * Apply a force
  23746. * @param force The force to apply
  23747. * @param contactPoint The contact point for the force
  23748. * @returns The physics imposter
  23749. */
  23750. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23751. /**
  23752. * Apply an impulse
  23753. * @param force The impulse force
  23754. * @param contactPoint The contact point for the impulse force
  23755. * @returns The physics imposter
  23756. */
  23757. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23758. /**
  23759. * A help function to create a joint
  23760. * @param otherImpostor A physics imposter used to create a joint
  23761. * @param jointType The type of joint
  23762. * @param jointData The data for the joint
  23763. * @returns The physics imposter
  23764. */
  23765. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23766. /**
  23767. * Add a joint to this impostor with a different impostor
  23768. * @param otherImpostor A physics imposter used to add a joint
  23769. * @param joint The joint to add
  23770. * @returns The physics imposter
  23771. */
  23772. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23773. /**
  23774. * Add an anchor to a cloth impostor
  23775. * @param otherImpostor rigid impostor to anchor to
  23776. * @param width ratio across width from 0 to 1
  23777. * @param height ratio up height from 0 to 1
  23778. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23779. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23780. * @returns impostor the soft imposter
  23781. */
  23782. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23783. /**
  23784. * Add a hook to a rope impostor
  23785. * @param otherImpostor rigid impostor to anchor to
  23786. * @param length ratio across rope from 0 to 1
  23787. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23788. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23789. * @returns impostor the rope imposter
  23790. */
  23791. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23792. /**
  23793. * Will keep this body still, in a sleep mode.
  23794. * @returns the physics imposter
  23795. */
  23796. sleep(): PhysicsImpostor;
  23797. /**
  23798. * Wake the body up.
  23799. * @returns The physics imposter
  23800. */
  23801. wakeUp(): PhysicsImpostor;
  23802. /**
  23803. * Clones the physics imposter
  23804. * @param newObject The physics imposter clones to this physics-enabled object
  23805. * @returns A nullable physics imposter
  23806. */
  23807. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23808. /**
  23809. * Disposes the physics imposter
  23810. */
  23811. dispose(): void;
  23812. /**
  23813. * Sets the delta position
  23814. * @param position The delta position amount
  23815. */
  23816. setDeltaPosition(position: Vector3): void;
  23817. /**
  23818. * Sets the delta rotation
  23819. * @param rotation The delta rotation amount
  23820. */
  23821. setDeltaRotation(rotation: Quaternion): void;
  23822. /**
  23823. * Gets the box size of the physics imposter and stores the result in the input parameter
  23824. * @param result Stores the box size
  23825. * @returns The physics imposter
  23826. */
  23827. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23828. /**
  23829. * Gets the radius of the physics imposter
  23830. * @returns Radius of the physics imposter
  23831. */
  23832. getRadius(): number;
  23833. /**
  23834. * Sync a bone with this impostor
  23835. * @param bone The bone to sync to the impostor.
  23836. * @param boneMesh The mesh that the bone is influencing.
  23837. * @param jointPivot The pivot of the joint / bone in local space.
  23838. * @param distToJoint Optional distance from the impostor to the joint.
  23839. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23840. */
  23841. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23842. /**
  23843. * Sync impostor to a bone
  23844. * @param bone The bone that the impostor will be synced to.
  23845. * @param boneMesh The mesh that the bone is influencing.
  23846. * @param jointPivot The pivot of the joint / bone in local space.
  23847. * @param distToJoint Optional distance from the impostor to the joint.
  23848. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23849. * @param boneAxis Optional vector3 axis the bone is aligned with
  23850. */
  23851. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23852. /**
  23853. * No-Imposter type
  23854. */
  23855. static NoImpostor: number;
  23856. /**
  23857. * Sphere-Imposter type
  23858. */
  23859. static SphereImpostor: number;
  23860. /**
  23861. * Box-Imposter type
  23862. */
  23863. static BoxImpostor: number;
  23864. /**
  23865. * Plane-Imposter type
  23866. */
  23867. static PlaneImpostor: number;
  23868. /**
  23869. * Mesh-imposter type
  23870. */
  23871. static MeshImpostor: number;
  23872. /**
  23873. * Capsule-Impostor type (Ammo.js plugin only)
  23874. */
  23875. static CapsuleImpostor: number;
  23876. /**
  23877. * Cylinder-Imposter type
  23878. */
  23879. static CylinderImpostor: number;
  23880. /**
  23881. * Particle-Imposter type
  23882. */
  23883. static ParticleImpostor: number;
  23884. /**
  23885. * Heightmap-Imposter type
  23886. */
  23887. static HeightmapImpostor: number;
  23888. /**
  23889. * ConvexHull-Impostor type (Ammo.js plugin only)
  23890. */
  23891. static ConvexHullImpostor: number;
  23892. /**
  23893. * Rope-Imposter type
  23894. */
  23895. static RopeImpostor: number;
  23896. /**
  23897. * Cloth-Imposter type
  23898. */
  23899. static ClothImpostor: number;
  23900. /**
  23901. * Softbody-Imposter type
  23902. */
  23903. static SoftbodyImpostor: number;
  23904. }
  23905. }
  23906. declare module "babylonjs/Meshes/mesh" {
  23907. import { Observable } from "babylonjs/Misc/observable";
  23908. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23909. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23910. import { Camera } from "babylonjs/Cameras/camera";
  23911. import { Scene } from "babylonjs/scene";
  23912. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23913. import { Color4 } from "babylonjs/Maths/math.color";
  23914. import { Engine } from "babylonjs/Engines/engine";
  23915. import { Node } from "babylonjs/node";
  23916. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23917. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23918. import { Buffer } from "babylonjs/Meshes/buffer";
  23919. import { Geometry } from "babylonjs/Meshes/geometry";
  23920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23922. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23923. import { Effect } from "babylonjs/Materials/effect";
  23924. import { Material } from "babylonjs/Materials/material";
  23925. import { Skeleton } from "babylonjs/Bones/skeleton";
  23926. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23927. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23928. import { Path3D } from "babylonjs/Maths/math.path";
  23929. import { Plane } from "babylonjs/Maths/math.plane";
  23930. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23931. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23932. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23933. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23934. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23935. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23936. /**
  23937. * @hidden
  23938. **/
  23939. export class _CreationDataStorage {
  23940. closePath?: boolean;
  23941. closeArray?: boolean;
  23942. idx: number[];
  23943. dashSize: number;
  23944. gapSize: number;
  23945. path3D: Path3D;
  23946. pathArray: Vector3[][];
  23947. arc: number;
  23948. radius: number;
  23949. cap: number;
  23950. tessellation: number;
  23951. }
  23952. /**
  23953. * @hidden
  23954. **/
  23955. class _InstanceDataStorage {
  23956. visibleInstances: any;
  23957. batchCache: _InstancesBatch;
  23958. instancesBufferSize: number;
  23959. instancesBuffer: Nullable<Buffer>;
  23960. instancesData: Float32Array;
  23961. overridenInstanceCount: number;
  23962. isFrozen: boolean;
  23963. previousBatch: Nullable<_InstancesBatch>;
  23964. hardwareInstancedRendering: boolean;
  23965. sideOrientation: number;
  23966. }
  23967. /**
  23968. * @hidden
  23969. **/
  23970. export class _InstancesBatch {
  23971. mustReturn: boolean;
  23972. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23973. renderSelf: boolean[];
  23974. hardwareInstancedRendering: boolean[];
  23975. }
  23976. /**
  23977. * Class used to represent renderable models
  23978. */
  23979. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23980. /**
  23981. * Mesh side orientation : usually the external or front surface
  23982. */
  23983. static readonly FRONTSIDE: number;
  23984. /**
  23985. * Mesh side orientation : usually the internal or back surface
  23986. */
  23987. static readonly BACKSIDE: number;
  23988. /**
  23989. * Mesh side orientation : both internal and external or front and back surfaces
  23990. */
  23991. static readonly DOUBLESIDE: number;
  23992. /**
  23993. * Mesh side orientation : by default, `FRONTSIDE`
  23994. */
  23995. static readonly DEFAULTSIDE: number;
  23996. /**
  23997. * Mesh cap setting : no cap
  23998. */
  23999. static readonly NO_CAP: number;
  24000. /**
  24001. * Mesh cap setting : one cap at the beginning of the mesh
  24002. */
  24003. static readonly CAP_START: number;
  24004. /**
  24005. * Mesh cap setting : one cap at the end of the mesh
  24006. */
  24007. static readonly CAP_END: number;
  24008. /**
  24009. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24010. */
  24011. static readonly CAP_ALL: number;
  24012. /**
  24013. * Mesh pattern setting : no flip or rotate
  24014. */
  24015. static readonly NO_FLIP: number;
  24016. /**
  24017. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24018. */
  24019. static readonly FLIP_TILE: number;
  24020. /**
  24021. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24022. */
  24023. static readonly ROTATE_TILE: number;
  24024. /**
  24025. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24026. */
  24027. static readonly FLIP_ROW: number;
  24028. /**
  24029. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24030. */
  24031. static readonly ROTATE_ROW: number;
  24032. /**
  24033. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24034. */
  24035. static readonly FLIP_N_ROTATE_TILE: number;
  24036. /**
  24037. * Mesh pattern setting : rotate pattern and rotate
  24038. */
  24039. static readonly FLIP_N_ROTATE_ROW: number;
  24040. /**
  24041. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24042. */
  24043. static readonly CENTER: number;
  24044. /**
  24045. * Mesh tile positioning : part tiles on left
  24046. */
  24047. static readonly LEFT: number;
  24048. /**
  24049. * Mesh tile positioning : part tiles on right
  24050. */
  24051. static readonly RIGHT: number;
  24052. /**
  24053. * Mesh tile positioning : part tiles on top
  24054. */
  24055. static readonly TOP: number;
  24056. /**
  24057. * Mesh tile positioning : part tiles on bottom
  24058. */
  24059. static readonly BOTTOM: number;
  24060. /**
  24061. * Gets the default side orientation.
  24062. * @param orientation the orientation to value to attempt to get
  24063. * @returns the default orientation
  24064. * @hidden
  24065. */
  24066. static _GetDefaultSideOrientation(orientation?: number): number;
  24067. private _internalMeshDataInfo;
  24068. /**
  24069. * An event triggered before rendering the mesh
  24070. */
  24071. readonly onBeforeRenderObservable: Observable<Mesh>;
  24072. /**
  24073. * An event triggered before binding the mesh
  24074. */
  24075. readonly onBeforeBindObservable: Observable<Mesh>;
  24076. /**
  24077. * An event triggered after rendering the mesh
  24078. */
  24079. readonly onAfterRenderObservable: Observable<Mesh>;
  24080. /**
  24081. * An event triggered before drawing the mesh
  24082. */
  24083. readonly onBeforeDrawObservable: Observable<Mesh>;
  24084. private _onBeforeDrawObserver;
  24085. /**
  24086. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24087. */
  24088. onBeforeDraw: () => void;
  24089. readonly hasInstances: boolean;
  24090. /**
  24091. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24092. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24093. */
  24094. delayLoadState: number;
  24095. /**
  24096. * Gets the list of instances created from this mesh
  24097. * it is not supposed to be modified manually.
  24098. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24100. */
  24101. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24102. /**
  24103. * Gets the file containing delay loading data for this mesh
  24104. */
  24105. delayLoadingFile: string;
  24106. /** @hidden */
  24107. _binaryInfo: any;
  24108. /**
  24109. * User defined function used to change how LOD level selection is done
  24110. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24111. */
  24112. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24113. /**
  24114. * Gets or sets the morph target manager
  24115. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24116. */
  24117. morphTargetManager: Nullable<MorphTargetManager>;
  24118. /** @hidden */
  24119. _creationDataStorage: Nullable<_CreationDataStorage>;
  24120. /** @hidden */
  24121. _geometry: Nullable<Geometry>;
  24122. /** @hidden */
  24123. _delayInfo: Array<string>;
  24124. /** @hidden */
  24125. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24126. /** @hidden */
  24127. _instanceDataStorage: _InstanceDataStorage;
  24128. private _effectiveMaterial;
  24129. /** @hidden */
  24130. _shouldGenerateFlatShading: boolean;
  24131. /** @hidden */
  24132. _originalBuilderSideOrientation: number;
  24133. /**
  24134. * Use this property to change the original side orientation defined at construction time
  24135. */
  24136. overrideMaterialSideOrientation: Nullable<number>;
  24137. /**
  24138. * Gets the source mesh (the one used to clone this one from)
  24139. */
  24140. readonly source: Nullable<Mesh>;
  24141. /**
  24142. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24143. */
  24144. isUnIndexed: boolean;
  24145. /**
  24146. * @constructor
  24147. * @param name The value used by scene.getMeshByName() to do a lookup.
  24148. * @param scene The scene to add this mesh to.
  24149. * @param parent The parent of this mesh, if it has one
  24150. * @param source An optional Mesh from which geometry is shared, cloned.
  24151. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24152. * When false, achieved by calling a clone(), also passing False.
  24153. * This will make creation of children, recursive.
  24154. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24155. */
  24156. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24157. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24158. /**
  24159. * Gets the class name
  24160. * @returns the string "Mesh".
  24161. */
  24162. getClassName(): string;
  24163. /** @hidden */
  24164. readonly _isMesh: boolean;
  24165. /**
  24166. * Returns a description of this mesh
  24167. * @param fullDetails define if full details about this mesh must be used
  24168. * @returns a descriptive string representing this mesh
  24169. */
  24170. toString(fullDetails?: boolean): string;
  24171. /** @hidden */
  24172. _unBindEffect(): void;
  24173. /**
  24174. * Gets a boolean indicating if this mesh has LOD
  24175. */
  24176. readonly hasLODLevels: boolean;
  24177. /**
  24178. * Gets the list of MeshLODLevel associated with the current mesh
  24179. * @returns an array of MeshLODLevel
  24180. */
  24181. getLODLevels(): MeshLODLevel[];
  24182. private _sortLODLevels;
  24183. /**
  24184. * Add a mesh as LOD level triggered at the given distance.
  24185. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24186. * @param distance The distance from the center of the object to show this level
  24187. * @param mesh The mesh to be added as LOD level (can be null)
  24188. * @return This mesh (for chaining)
  24189. */
  24190. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24191. /**
  24192. * Returns the LOD level mesh at the passed distance or null if not found.
  24193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24194. * @param distance The distance from the center of the object to show this level
  24195. * @returns a Mesh or `null`
  24196. */
  24197. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24198. /**
  24199. * Remove a mesh from the LOD array
  24200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24201. * @param mesh defines the mesh to be removed
  24202. * @return This mesh (for chaining)
  24203. */
  24204. removeLODLevel(mesh: Mesh): Mesh;
  24205. /**
  24206. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24208. * @param camera defines the camera to use to compute distance
  24209. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24210. * @return This mesh (for chaining)
  24211. */
  24212. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24213. /**
  24214. * Gets the mesh internal Geometry object
  24215. */
  24216. readonly geometry: Nullable<Geometry>;
  24217. /**
  24218. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24219. * @returns the total number of vertices
  24220. */
  24221. getTotalVertices(): number;
  24222. /**
  24223. * Returns the content of an associated vertex buffer
  24224. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24225. * - VertexBuffer.PositionKind
  24226. * - VertexBuffer.UVKind
  24227. * - VertexBuffer.UV2Kind
  24228. * - VertexBuffer.UV3Kind
  24229. * - VertexBuffer.UV4Kind
  24230. * - VertexBuffer.UV5Kind
  24231. * - VertexBuffer.UV6Kind
  24232. * - VertexBuffer.ColorKind
  24233. * - VertexBuffer.MatricesIndicesKind
  24234. * - VertexBuffer.MatricesIndicesExtraKind
  24235. * - VertexBuffer.MatricesWeightsKind
  24236. * - VertexBuffer.MatricesWeightsExtraKind
  24237. * @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
  24238. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24239. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24240. */
  24241. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24242. /**
  24243. * Returns the mesh VertexBuffer object from the requested `kind`
  24244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24245. * - VertexBuffer.PositionKind
  24246. * - VertexBuffer.NormalKind
  24247. * - VertexBuffer.UVKind
  24248. * - VertexBuffer.UV2Kind
  24249. * - VertexBuffer.UV3Kind
  24250. * - VertexBuffer.UV4Kind
  24251. * - VertexBuffer.UV5Kind
  24252. * - VertexBuffer.UV6Kind
  24253. * - VertexBuffer.ColorKind
  24254. * - VertexBuffer.MatricesIndicesKind
  24255. * - VertexBuffer.MatricesIndicesExtraKind
  24256. * - VertexBuffer.MatricesWeightsKind
  24257. * - VertexBuffer.MatricesWeightsExtraKind
  24258. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24259. */
  24260. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24261. /**
  24262. * Tests if a specific vertex buffer is associated with this mesh
  24263. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24264. * - VertexBuffer.PositionKind
  24265. * - VertexBuffer.NormalKind
  24266. * - VertexBuffer.UVKind
  24267. * - VertexBuffer.UV2Kind
  24268. * - VertexBuffer.UV3Kind
  24269. * - VertexBuffer.UV4Kind
  24270. * - VertexBuffer.UV5Kind
  24271. * - VertexBuffer.UV6Kind
  24272. * - VertexBuffer.ColorKind
  24273. * - VertexBuffer.MatricesIndicesKind
  24274. * - VertexBuffer.MatricesIndicesExtraKind
  24275. * - VertexBuffer.MatricesWeightsKind
  24276. * - VertexBuffer.MatricesWeightsExtraKind
  24277. * @returns a boolean
  24278. */
  24279. isVerticesDataPresent(kind: string): boolean;
  24280. /**
  24281. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24282. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24283. * - VertexBuffer.PositionKind
  24284. * - VertexBuffer.UVKind
  24285. * - VertexBuffer.UV2Kind
  24286. * - VertexBuffer.UV3Kind
  24287. * - VertexBuffer.UV4Kind
  24288. * - VertexBuffer.UV5Kind
  24289. * - VertexBuffer.UV6Kind
  24290. * - VertexBuffer.ColorKind
  24291. * - VertexBuffer.MatricesIndicesKind
  24292. * - VertexBuffer.MatricesIndicesExtraKind
  24293. * - VertexBuffer.MatricesWeightsKind
  24294. * - VertexBuffer.MatricesWeightsExtraKind
  24295. * @returns a boolean
  24296. */
  24297. isVertexBufferUpdatable(kind: string): boolean;
  24298. /**
  24299. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24300. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24301. * - VertexBuffer.PositionKind
  24302. * - VertexBuffer.NormalKind
  24303. * - VertexBuffer.UVKind
  24304. * - VertexBuffer.UV2Kind
  24305. * - VertexBuffer.UV3Kind
  24306. * - VertexBuffer.UV4Kind
  24307. * - VertexBuffer.UV5Kind
  24308. * - VertexBuffer.UV6Kind
  24309. * - VertexBuffer.ColorKind
  24310. * - VertexBuffer.MatricesIndicesKind
  24311. * - VertexBuffer.MatricesIndicesExtraKind
  24312. * - VertexBuffer.MatricesWeightsKind
  24313. * - VertexBuffer.MatricesWeightsExtraKind
  24314. * @returns an array of strings
  24315. */
  24316. getVerticesDataKinds(): string[];
  24317. /**
  24318. * Returns a positive integer : the total number of indices in this mesh geometry.
  24319. * @returns the numner of indices or zero if the mesh has no geometry.
  24320. */
  24321. getTotalIndices(): number;
  24322. /**
  24323. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24324. * @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.
  24325. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24326. * @returns the indices array or an empty array if the mesh has no geometry
  24327. */
  24328. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24329. readonly isBlocked: boolean;
  24330. /**
  24331. * Determine if the current mesh is ready to be rendered
  24332. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24333. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24334. * @returns true if all associated assets are ready (material, textures, shaders)
  24335. */
  24336. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24337. /**
  24338. * 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.
  24339. */
  24340. readonly areNormalsFrozen: boolean;
  24341. /**
  24342. * 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.
  24343. * @returns the current mesh
  24344. */
  24345. freezeNormals(): Mesh;
  24346. /**
  24347. * 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
  24348. * @returns the current mesh
  24349. */
  24350. unfreezeNormals(): Mesh;
  24351. /**
  24352. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24353. */
  24354. overridenInstanceCount: number;
  24355. /** @hidden */
  24356. _preActivate(): Mesh;
  24357. /** @hidden */
  24358. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24359. /** @hidden */
  24360. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24361. /**
  24362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24363. * This means the mesh underlying bounding box and sphere are recomputed.
  24364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24365. * @returns the current mesh
  24366. */
  24367. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24368. /** @hidden */
  24369. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24370. /**
  24371. * This function will subdivide the mesh into multiple submeshes
  24372. * @param count defines the expected number of submeshes
  24373. */
  24374. subdivide(count: number): void;
  24375. /**
  24376. * Copy a FloatArray into a specific associated vertex buffer
  24377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.UVKind
  24380. * - VertexBuffer.UV2Kind
  24381. * - VertexBuffer.UV3Kind
  24382. * - VertexBuffer.UV4Kind
  24383. * - VertexBuffer.UV5Kind
  24384. * - VertexBuffer.UV6Kind
  24385. * - VertexBuffer.ColorKind
  24386. * - VertexBuffer.MatricesIndicesKind
  24387. * - VertexBuffer.MatricesIndicesExtraKind
  24388. * - VertexBuffer.MatricesWeightsKind
  24389. * - VertexBuffer.MatricesWeightsExtraKind
  24390. * @param data defines the data source
  24391. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24392. * @param stride defines the data stride size (can be null)
  24393. * @returns the current mesh
  24394. */
  24395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24396. /**
  24397. * Flags an associated vertex buffer as updatable
  24398. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24399. * - VertexBuffer.PositionKind
  24400. * - VertexBuffer.UVKind
  24401. * - VertexBuffer.UV2Kind
  24402. * - VertexBuffer.UV3Kind
  24403. * - VertexBuffer.UV4Kind
  24404. * - VertexBuffer.UV5Kind
  24405. * - VertexBuffer.UV6Kind
  24406. * - VertexBuffer.ColorKind
  24407. * - VertexBuffer.MatricesIndicesKind
  24408. * - VertexBuffer.MatricesIndicesExtraKind
  24409. * - VertexBuffer.MatricesWeightsKind
  24410. * - VertexBuffer.MatricesWeightsExtraKind
  24411. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24412. */
  24413. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24414. /**
  24415. * Sets the mesh global Vertex Buffer
  24416. * @param buffer defines the buffer to use
  24417. * @returns the current mesh
  24418. */
  24419. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24420. /**
  24421. * Update a specific associated vertex buffer
  24422. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24423. * - VertexBuffer.PositionKind
  24424. * - VertexBuffer.UVKind
  24425. * - VertexBuffer.UV2Kind
  24426. * - VertexBuffer.UV3Kind
  24427. * - VertexBuffer.UV4Kind
  24428. * - VertexBuffer.UV5Kind
  24429. * - VertexBuffer.UV6Kind
  24430. * - VertexBuffer.ColorKind
  24431. * - VertexBuffer.MatricesIndicesKind
  24432. * - VertexBuffer.MatricesIndicesExtraKind
  24433. * - VertexBuffer.MatricesWeightsKind
  24434. * - VertexBuffer.MatricesWeightsExtraKind
  24435. * @param data defines the data source
  24436. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24437. * @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)
  24438. * @returns the current mesh
  24439. */
  24440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24441. /**
  24442. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24443. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24444. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24445. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24446. * @returns the current mesh
  24447. */
  24448. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24449. /**
  24450. * Creates a un-shared specific occurence of the geometry for the mesh.
  24451. * @returns the current mesh
  24452. */
  24453. makeGeometryUnique(): Mesh;
  24454. /**
  24455. * Set the index buffer of this mesh
  24456. * @param indices defines the source data
  24457. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24458. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24459. * @returns the current mesh
  24460. */
  24461. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24462. /**
  24463. * Update the current index buffer
  24464. * @param indices defines the source data
  24465. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24466. * @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)
  24467. * @returns the current mesh
  24468. */
  24469. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24470. /**
  24471. * Invert the geometry to move from a right handed system to a left handed one.
  24472. * @returns the current mesh
  24473. */
  24474. toLeftHanded(): Mesh;
  24475. /** @hidden */
  24476. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24477. /** @hidden */
  24478. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24479. /**
  24480. * Registers for this mesh a javascript function called just before the rendering process
  24481. * @param func defines the function to call before rendering this mesh
  24482. * @returns the current mesh
  24483. */
  24484. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24485. /**
  24486. * Disposes a previously registered javascript function called before the rendering
  24487. * @param func defines the function to remove
  24488. * @returns the current mesh
  24489. */
  24490. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24491. /**
  24492. * Registers for this mesh a javascript function called just after the rendering is complete
  24493. * @param func defines the function to call after rendering this mesh
  24494. * @returns the current mesh
  24495. */
  24496. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24497. /**
  24498. * Disposes a previously registered javascript function called after the rendering.
  24499. * @param func defines the function to remove
  24500. * @returns the current mesh
  24501. */
  24502. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24503. /** @hidden */
  24504. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24505. /** @hidden */
  24506. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24507. /** @hidden */
  24508. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24509. /** @hidden */
  24510. _rebuild(): void;
  24511. /** @hidden */
  24512. _freeze(): void;
  24513. /** @hidden */
  24514. _unFreeze(): void;
  24515. /**
  24516. * 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
  24517. * @param subMesh defines the subMesh to render
  24518. * @param enableAlphaMode defines if alpha mode can be changed
  24519. * @returns the current mesh
  24520. */
  24521. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24522. private _onBeforeDraw;
  24523. /**
  24524. * Renormalize the mesh and patch it up if there are no weights
  24525. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24526. * However in the case of zero weights then we set just a single influence to 1.
  24527. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24528. */
  24529. cleanMatrixWeights(): void;
  24530. private normalizeSkinFourWeights;
  24531. private normalizeSkinWeightsAndExtra;
  24532. /**
  24533. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24534. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24535. * the user know there was an issue with importing the mesh
  24536. * @returns a validation object with skinned, valid and report string
  24537. */
  24538. validateSkinning(): {
  24539. skinned: boolean;
  24540. valid: boolean;
  24541. report: string;
  24542. };
  24543. /** @hidden */
  24544. _checkDelayState(): Mesh;
  24545. private _queueLoad;
  24546. /**
  24547. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24548. * A mesh is in the frustum if its bounding box intersects the frustum
  24549. * @param frustumPlanes defines the frustum to test
  24550. * @returns true if the mesh is in the frustum planes
  24551. */
  24552. isInFrustum(frustumPlanes: Plane[]): boolean;
  24553. /**
  24554. * Sets the mesh material by the material or multiMaterial `id` property
  24555. * @param id is a string identifying the material or the multiMaterial
  24556. * @returns the current mesh
  24557. */
  24558. setMaterialByID(id: string): Mesh;
  24559. /**
  24560. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24561. * @returns an array of IAnimatable
  24562. */
  24563. getAnimatables(): IAnimatable[];
  24564. /**
  24565. * Modifies the mesh geometry according to the passed transformation matrix.
  24566. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24567. * The mesh normals are modified using the same transformation.
  24568. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24569. * @param transform defines the transform matrix to use
  24570. * @see http://doc.babylonjs.com/resources/baking_transformations
  24571. * @returns the current mesh
  24572. */
  24573. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24574. /**
  24575. * Modifies the mesh geometry according to its own current World Matrix.
  24576. * The mesh World Matrix is then reset.
  24577. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24578. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24579. * @see http://doc.babylonjs.com/resources/baking_transformations
  24580. * @returns the current mesh
  24581. */
  24582. bakeCurrentTransformIntoVertices(): Mesh;
  24583. /** @hidden */
  24584. readonly _positions: Nullable<Vector3[]>;
  24585. /** @hidden */
  24586. _resetPointsArrayCache(): Mesh;
  24587. /** @hidden */
  24588. _generatePointsArray(): boolean;
  24589. /**
  24590. * Returns a new Mesh object generated from the current mesh properties.
  24591. * This method must not get confused with createInstance()
  24592. * @param name is a string, the name given to the new mesh
  24593. * @param newParent can be any Node object (default `null`)
  24594. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24595. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24596. * @returns a new mesh
  24597. */
  24598. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24599. /**
  24600. * Releases resources associated with this mesh.
  24601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24603. */
  24604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24605. /**
  24606. * Modifies the mesh geometry according to a displacement map.
  24607. * 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.
  24608. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24609. * @param url is a string, the URL from the image file is to be downloaded.
  24610. * @param minHeight is the lower limit of the displacement.
  24611. * @param maxHeight is the upper limit of the displacement.
  24612. * @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.
  24613. * @param uvOffset is an optional vector2 used to offset UV.
  24614. * @param uvScale is an optional vector2 used to scale UV.
  24615. * @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.
  24616. * @returns the Mesh.
  24617. */
  24618. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24619. /**
  24620. * Modifies the mesh geometry according to a displacementMap buffer.
  24621. * 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.
  24622. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24623. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24624. * @param heightMapWidth is the width of the buffer image.
  24625. * @param heightMapHeight is the height of the buffer image.
  24626. * @param minHeight is the lower limit of the displacement.
  24627. * @param maxHeight is the upper limit of the displacement.
  24628. * @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.
  24629. * @param uvOffset is an optional vector2 used to offset UV.
  24630. * @param uvScale is an optional vector2 used to scale UV.
  24631. * @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.
  24632. * @returns the Mesh.
  24633. */
  24634. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24635. /**
  24636. * Modify the mesh to get a flat shading rendering.
  24637. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24638. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24639. * @returns current mesh
  24640. */
  24641. convertToFlatShadedMesh(): Mesh;
  24642. /**
  24643. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24644. * In other words, more vertices, no more indices and a single bigger VBO.
  24645. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24646. * @returns current mesh
  24647. */
  24648. convertToUnIndexedMesh(): Mesh;
  24649. /**
  24650. * Inverses facet orientations.
  24651. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24652. * @param flipNormals will also inverts the normals
  24653. * @returns current mesh
  24654. */
  24655. flipFaces(flipNormals?: boolean): Mesh;
  24656. /**
  24657. * Increase the number of facets and hence vertices in a mesh
  24658. * Vertex normals are interpolated from existing vertex normals
  24659. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24660. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24661. */
  24662. increaseVertices(numberPerEdge: number): void;
  24663. /**
  24664. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24665. * This will undo any application of covertToFlatShadedMesh
  24666. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24667. */
  24668. forceSharedVertices(): void;
  24669. /** @hidden */
  24670. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24671. /** @hidden */
  24672. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24673. /**
  24674. * Creates a new InstancedMesh object from the mesh model.
  24675. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24676. * @param name defines the name of the new instance
  24677. * @returns a new InstancedMesh
  24678. */
  24679. createInstance(name: string): InstancedMesh;
  24680. /**
  24681. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24682. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24683. * @returns the current mesh
  24684. */
  24685. synchronizeInstances(): Mesh;
  24686. /**
  24687. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24688. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24689. * This should be used together with the simplification to avoid disappearing triangles.
  24690. * @param successCallback an optional success callback to be called after the optimization finished.
  24691. * @returns the current mesh
  24692. */
  24693. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24694. /**
  24695. * Serialize current mesh
  24696. * @param serializationObject defines the object which will receive the serialization data
  24697. */
  24698. serialize(serializationObject: any): void;
  24699. /** @hidden */
  24700. _syncGeometryWithMorphTargetManager(): void;
  24701. /** @hidden */
  24702. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24703. /**
  24704. * Returns a new Mesh object parsed from the source provided.
  24705. * @param parsedMesh is the source
  24706. * @param scene defines the hosting scene
  24707. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24708. * @returns a new Mesh
  24709. */
  24710. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24711. /**
  24712. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24713. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24714. * @param name defines the name of the mesh to create
  24715. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24716. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24717. * @param closePath creates a seam between the first and the last points of each path of the path array
  24718. * @param offset is taken in account only if the `pathArray` is containing a single path
  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. * @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)
  24723. * @returns a new Mesh
  24724. */
  24725. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24726. /**
  24727. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24728. * @param name defines the name of the mesh to create
  24729. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24730. * @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
  24731. * @param scene defines the hosting scene
  24732. * @param updatable defines if the mesh must be flagged as updatable
  24733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24734. * @returns a new Mesh
  24735. */
  24736. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24737. /**
  24738. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24739. * @param name defines the name of the mesh to create
  24740. * @param size sets the size (float) of each box side (default 1)
  24741. * @param scene defines the hosting scene
  24742. * @param updatable defines if the mesh must be flagged as updatable
  24743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24744. * @returns a new Mesh
  24745. */
  24746. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24747. /**
  24748. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24749. * @param name defines the name of the mesh to create
  24750. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24751. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24752. * @param scene defines the hosting scene
  24753. * @param updatable defines if the mesh must be flagged as updatable
  24754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24755. * @returns a new Mesh
  24756. */
  24757. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24758. /**
  24759. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24760. * @param name defines the name of the mesh to create
  24761. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24762. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24763. * @param scene defines the hosting scene
  24764. * @returns a new Mesh
  24765. */
  24766. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24767. /**
  24768. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24769. * @param name defines the name of the mesh to create
  24770. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24771. * @param diameterTop set the top cap diameter (floats, default 1)
  24772. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24773. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24774. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24775. * @param scene defines the hosting scene
  24776. * @param updatable defines if the mesh must be flagged as updatable
  24777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24778. * @returns a new Mesh
  24779. */
  24780. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24781. /**
  24782. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24783. * @param name defines the name of the mesh to create
  24784. * @param diameter sets the diameter size (float) of the torus (default 1)
  24785. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24786. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24787. * @param scene defines the hosting scene
  24788. * @param updatable defines if the mesh must be flagged as updatable
  24789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24790. * @returns a new Mesh
  24791. */
  24792. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24793. /**
  24794. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24795. * @param name defines the name of the mesh to create
  24796. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24797. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24798. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24799. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24800. * @param p the number of windings on X axis (positive integers, default 2)
  24801. * @param q the number of windings on Y axis (positive integers, default 3)
  24802. * @param scene defines the hosting scene
  24803. * @param updatable defines if the mesh must be flagged as updatable
  24804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24805. * @returns a new Mesh
  24806. */
  24807. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24808. /**
  24809. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24810. * @param name defines the name of the mesh to create
  24811. * @param points is an array successive Vector3
  24812. * @param scene defines the hosting scene
  24813. * @param updatable defines if the mesh must be flagged as updatable
  24814. * @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).
  24815. * @returns a new Mesh
  24816. */
  24817. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24818. /**
  24819. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24820. * @param name defines the name of the mesh to create
  24821. * @param points is an array successive Vector3
  24822. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24823. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24824. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24825. * @param scene defines the hosting scene
  24826. * @param updatable defines if the mesh must be flagged as updatable
  24827. * @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)
  24828. * @returns a new Mesh
  24829. */
  24830. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24831. /**
  24832. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24833. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24834. * 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.
  24835. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24836. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24837. * Remember you can only change the shape positions, not their number when updating a polygon.
  24838. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24839. * @param name defines the name of the mesh to create
  24840. * @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
  24841. * @param scene defines the hosting scene
  24842. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  24846. * @returns a new Mesh
  24847. */
  24848. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24849. /**
  24850. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24851. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24852. * @param name defines the name of the mesh to create
  24853. * @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
  24854. * @param depth defines the height of extrusion
  24855. * @param scene defines the hosting scene
  24856. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24857. * @param updatable defines if the mesh must be flagged as updatable
  24858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24859. * @param earcutInjection can be used to inject your own earcut reference
  24860. * @returns a new Mesh
  24861. */
  24862. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24863. /**
  24864. * Creates an extruded shape mesh.
  24865. * 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
  24866. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24867. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24868. * @param name defines the name of the mesh to create
  24869. * @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
  24870. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24871. * @param scale is the value to scale the shape
  24872. * @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
  24873. * @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
  24874. * @param scene defines the hosting scene
  24875. * @param updatable defines if the mesh must be flagged as updatable
  24876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24877. * @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)
  24878. * @returns a new Mesh
  24879. */
  24880. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24881. /**
  24882. * Creates an custom extruded shape mesh.
  24883. * The custom extrusion is a parametric shape.
  24884. * It has no predefined shape. Its final shape will depend on the input parameters.
  24885. * Please consider using the same method from the MeshBuilder class instead
  24886. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24887. * @param name defines the name of the mesh to create
  24888. * @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
  24889. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24890. * @param scaleFunction is a custom Javascript function called on each path point
  24891. * @param rotationFunction is a custom Javascript function called on each path point
  24892. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24893. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24894. * @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
  24895. * @param scene defines the hosting scene
  24896. * @param updatable defines if the mesh must be flagged as updatable
  24897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24898. * @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)
  24899. * @returns a new Mesh
  24900. */
  24901. 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;
  24902. /**
  24903. * Creates lathe mesh.
  24904. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24905. * Please consider using the same method from the MeshBuilder class instead
  24906. * @param name defines the name of the mesh to create
  24907. * @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
  24908. * @param radius is the radius value of the lathe
  24909. * @param tessellation is the side number of the lathe.
  24910. * @param scene defines the hosting scene
  24911. * @param updatable defines if the mesh must be flagged as updatable
  24912. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24913. * @returns a new Mesh
  24914. */
  24915. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24916. /**
  24917. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24918. * @param name defines the name of the mesh to create
  24919. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24920. * @param scene defines the hosting scene
  24921. * @param updatable defines if the mesh must be flagged as updatable
  24922. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24923. * @returns a new Mesh
  24924. */
  24925. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24926. /**
  24927. * Creates a ground mesh.
  24928. * Please consider using the same method from the MeshBuilder class instead
  24929. * @param name defines the name of the mesh to create
  24930. * @param width set the width of the ground
  24931. * @param height set the height of the ground
  24932. * @param subdivisions sets the number of subdivisions per side
  24933. * @param scene defines the hosting scene
  24934. * @param updatable defines if the mesh must be flagged as updatable
  24935. * @returns a new Mesh
  24936. */
  24937. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24938. /**
  24939. * Creates a tiled ground mesh.
  24940. * Please consider using the same method from the MeshBuilder class instead
  24941. * @param name defines the name of the mesh to create
  24942. * @param xmin set the ground minimum X coordinate
  24943. * @param zmin set the ground minimum Y coordinate
  24944. * @param xmax set the ground maximum X coordinate
  24945. * @param zmax set the ground maximum Z coordinate
  24946. * @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
  24947. * @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
  24948. * @param scene defines the hosting scene
  24949. * @param updatable defines if the mesh must be flagged as updatable
  24950. * @returns a new Mesh
  24951. */
  24952. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24953. w: number;
  24954. h: number;
  24955. }, precision: {
  24956. w: number;
  24957. h: number;
  24958. }, scene: Scene, updatable?: boolean): Mesh;
  24959. /**
  24960. * Creates a ground mesh from a height map.
  24961. * Please consider using the same method from the MeshBuilder class instead
  24962. * @see http://doc.babylonjs.com/babylon101/height_map
  24963. * @param name defines the name of the mesh to create
  24964. * @param url sets the URL of the height map image resource
  24965. * @param width set the ground width size
  24966. * @param height set the ground height size
  24967. * @param subdivisions sets the number of subdivision per side
  24968. * @param minHeight is the minimum altitude on the ground
  24969. * @param maxHeight is the maximum altitude on the ground
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24973. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24974. * @returns a new Mesh
  24975. */
  24976. 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;
  24977. /**
  24978. * Creates a tube mesh.
  24979. * The tube is a parametric shape.
  24980. * It has no predefined shape. Its final shape will depend on the input parameters.
  24981. * Please consider using the same method from the MeshBuilder class instead
  24982. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24983. * @param name defines the name of the mesh to create
  24984. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24985. * @param radius sets the tube radius size
  24986. * @param tessellation is the number of sides on the tubular surface
  24987. * @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
  24988. * @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
  24989. * @param scene defines the hosting scene
  24990. * @param updatable defines if the mesh must be flagged as updatable
  24991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24992. * @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)
  24993. * @returns a new Mesh
  24994. */
  24995. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24996. (i: number, distance: number): number;
  24997. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24998. /**
  24999. * Creates a polyhedron mesh.
  25000. * Please consider using the same method from the MeshBuilder class instead.
  25001. * * 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
  25002. * * The parameter `size` (positive float, default 1) sets the polygon size
  25003. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25004. * * 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`
  25005. * * 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
  25006. * * 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)`)
  25007. * * 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
  25008. * * 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
  25009. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25010. * * If you create a double-sided mesh, you can choose what parts of 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
  25011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25012. * @param name defines the name of the mesh to create
  25013. * @param options defines the options used to create the mesh
  25014. * @param scene defines the hosting scene
  25015. * @returns a new Mesh
  25016. */
  25017. static CreatePolyhedron(name: string, options: {
  25018. type?: number;
  25019. size?: number;
  25020. sizeX?: number;
  25021. sizeY?: number;
  25022. sizeZ?: number;
  25023. custom?: any;
  25024. faceUV?: Vector4[];
  25025. faceColors?: Color4[];
  25026. updatable?: boolean;
  25027. sideOrientation?: number;
  25028. }, scene: Scene): Mesh;
  25029. /**
  25030. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25031. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25032. * * 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`)
  25033. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25034. * * 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
  25035. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25036. * * If you create a double-sided mesh, you can choose what parts of 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
  25037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25038. * @param name defines the name of the mesh
  25039. * @param options defines the options used to create the mesh
  25040. * @param scene defines the hosting scene
  25041. * @returns a new Mesh
  25042. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25043. */
  25044. static CreateIcoSphere(name: string, options: {
  25045. radius?: number;
  25046. flat?: boolean;
  25047. subdivisions?: number;
  25048. sideOrientation?: number;
  25049. updatable?: boolean;
  25050. }, scene: Scene): Mesh;
  25051. /**
  25052. * Creates a decal mesh.
  25053. * Please consider using the same method from the MeshBuilder class instead.
  25054. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25055. * @param name defines the name of the mesh
  25056. * @param sourceMesh defines the mesh receiving the decal
  25057. * @param position sets the position of the decal in world coordinates
  25058. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25059. * @param size sets the decal scaling
  25060. * @param angle sets the angle to rotate the decal
  25061. * @returns a new Mesh
  25062. */
  25063. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25064. /**
  25065. * Prepare internal position array for software CPU skinning
  25066. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25067. */
  25068. setPositionsForCPUSkinning(): Float32Array;
  25069. /**
  25070. * Prepare internal normal array for software CPU skinning
  25071. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25072. */
  25073. setNormalsForCPUSkinning(): Float32Array;
  25074. /**
  25075. * Updates the vertex buffer by applying transformation from the bones
  25076. * @param skeleton defines the skeleton to apply to current mesh
  25077. * @returns the current mesh
  25078. */
  25079. applySkeleton(skeleton: Skeleton): Mesh;
  25080. /**
  25081. * 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
  25082. * @param meshes defines the list of meshes to scan
  25083. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25084. */
  25085. static MinMax(meshes: AbstractMesh[]): {
  25086. min: Vector3;
  25087. max: Vector3;
  25088. };
  25089. /**
  25090. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25091. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25092. * @returns a vector3
  25093. */
  25094. static Center(meshesOrMinMaxVector: {
  25095. min: Vector3;
  25096. max: Vector3;
  25097. } | AbstractMesh[]): Vector3;
  25098. /**
  25099. * Merge the array of meshes into a single mesh for performance reasons.
  25100. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25101. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25102. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25103. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25104. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25105. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25106. * @returns a new mesh
  25107. */
  25108. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25109. /** @hidden */
  25110. addInstance(instance: InstancedMesh): void;
  25111. /** @hidden */
  25112. removeInstance(instance: InstancedMesh): void;
  25113. }
  25114. }
  25115. declare module "babylonjs/Cameras/camera" {
  25116. import { SmartArray } from "babylonjs/Misc/smartArray";
  25117. import { Observable } from "babylonjs/Misc/observable";
  25118. import { Nullable } from "babylonjs/types";
  25119. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25120. import { Scene } from "babylonjs/scene";
  25121. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25122. import { Node } from "babylonjs/node";
  25123. import { Mesh } from "babylonjs/Meshes/mesh";
  25124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25125. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25126. import { Viewport } from "babylonjs/Maths/math.viewport";
  25127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25128. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25129. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25130. import { Ray } from "babylonjs/Culling/ray";
  25131. /**
  25132. * This is the base class of all the camera used in the application.
  25133. * @see http://doc.babylonjs.com/features/cameras
  25134. */
  25135. export class Camera extends Node {
  25136. /** @hidden */
  25137. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25138. /**
  25139. * This is the default projection mode used by the cameras.
  25140. * It helps recreating a feeling of perspective and better appreciate depth.
  25141. * This is the best way to simulate real life cameras.
  25142. */
  25143. static readonly PERSPECTIVE_CAMERA: number;
  25144. /**
  25145. * This helps creating camera with an orthographic mode.
  25146. * 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.
  25147. */
  25148. static readonly ORTHOGRAPHIC_CAMERA: number;
  25149. /**
  25150. * This is the default FOV mode for perspective cameras.
  25151. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25152. */
  25153. static readonly FOVMODE_VERTICAL_FIXED: number;
  25154. /**
  25155. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25156. */
  25157. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25158. /**
  25159. * This specifies ther is no need for a camera rig.
  25160. * Basically only one eye is rendered corresponding to the camera.
  25161. */
  25162. static readonly RIG_MODE_NONE: number;
  25163. /**
  25164. * Simulates a camera Rig with one blue eye and one red eye.
  25165. * This can be use with 3d blue and red glasses.
  25166. */
  25167. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25168. /**
  25169. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25170. */
  25171. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25172. /**
  25173. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25174. */
  25175. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25176. /**
  25177. * Defines that both eyes of the camera will be rendered over under each other.
  25178. */
  25179. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25180. /**
  25181. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25182. */
  25183. static readonly RIG_MODE_VR: number;
  25184. /**
  25185. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25186. */
  25187. static readonly RIG_MODE_WEBVR: number;
  25188. /**
  25189. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25190. */
  25191. static readonly RIG_MODE_CUSTOM: number;
  25192. /**
  25193. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25194. */
  25195. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25196. /**
  25197. * Define the input manager associated with the camera.
  25198. */
  25199. inputs: CameraInputsManager<Camera>;
  25200. /** @hidden */
  25201. _position: Vector3;
  25202. /**
  25203. * Define the current local position of the camera in the scene
  25204. */
  25205. position: Vector3;
  25206. /**
  25207. * The vector the camera should consider as up.
  25208. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25209. */
  25210. upVector: Vector3;
  25211. /**
  25212. * Define the current limit on the left side for an orthographic camera
  25213. * In scene unit
  25214. */
  25215. orthoLeft: Nullable<number>;
  25216. /**
  25217. * Define the current limit on the right side for an orthographic camera
  25218. * In scene unit
  25219. */
  25220. orthoRight: Nullable<number>;
  25221. /**
  25222. * Define the current limit on the bottom side for an orthographic camera
  25223. * In scene unit
  25224. */
  25225. orthoBottom: Nullable<number>;
  25226. /**
  25227. * Define the current limit on the top side for an orthographic camera
  25228. * In scene unit
  25229. */
  25230. orthoTop: Nullable<number>;
  25231. /**
  25232. * Field Of View is set in Radians. (default is 0.8)
  25233. */
  25234. fov: number;
  25235. /**
  25236. * Define the minimum distance the camera can see from.
  25237. * This is important to note that the depth buffer are not infinite and the closer it starts
  25238. * the more your scene might encounter depth fighting issue.
  25239. */
  25240. minZ: number;
  25241. /**
  25242. * Define the maximum distance the camera can see to.
  25243. * This is important to note that the depth buffer are not infinite and the further it end
  25244. * the more your scene might encounter depth fighting issue.
  25245. */
  25246. maxZ: number;
  25247. /**
  25248. * Define the default inertia of the camera.
  25249. * This helps giving a smooth feeling to the camera movement.
  25250. */
  25251. inertia: number;
  25252. /**
  25253. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25254. */
  25255. mode: number;
  25256. /**
  25257. * Define wether the camera is intermediate.
  25258. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25259. */
  25260. isIntermediate: boolean;
  25261. /**
  25262. * Define the viewport of the camera.
  25263. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25264. */
  25265. viewport: Viewport;
  25266. /**
  25267. * Restricts the camera to viewing objects with the same layerMask.
  25268. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25269. */
  25270. layerMask: number;
  25271. /**
  25272. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25273. */
  25274. fovMode: number;
  25275. /**
  25276. * Rig mode of the camera.
  25277. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25278. * This is normally controlled byt the camera themselves as internal use.
  25279. */
  25280. cameraRigMode: number;
  25281. /**
  25282. * Defines the distance between both "eyes" in case of a RIG
  25283. */
  25284. interaxialDistance: number;
  25285. /**
  25286. * Defines if stereoscopic rendering is done side by side or over under.
  25287. */
  25288. isStereoscopicSideBySide: boolean;
  25289. /**
  25290. * 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
  25291. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25292. * else in the scene. (Eg. security camera)
  25293. *
  25294. * 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)
  25295. */
  25296. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25297. /**
  25298. * When set, the camera will render to this render target instead of the default canvas
  25299. *
  25300. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25301. */
  25302. outputRenderTarget: Nullable<RenderTargetTexture>;
  25303. /**
  25304. * Observable triggered when the camera view matrix has changed.
  25305. */
  25306. onViewMatrixChangedObservable: Observable<Camera>;
  25307. /**
  25308. * Observable triggered when the camera Projection matrix has changed.
  25309. */
  25310. onProjectionMatrixChangedObservable: Observable<Camera>;
  25311. /**
  25312. * Observable triggered when the inputs have been processed.
  25313. */
  25314. onAfterCheckInputsObservable: Observable<Camera>;
  25315. /**
  25316. * Observable triggered when reset has been called and applied to the camera.
  25317. */
  25318. onRestoreStateObservable: Observable<Camera>;
  25319. /** @hidden */
  25320. _cameraRigParams: any;
  25321. /** @hidden */
  25322. _rigCameras: Camera[];
  25323. /** @hidden */
  25324. _rigPostProcess: Nullable<PostProcess>;
  25325. protected _webvrViewMatrix: Matrix;
  25326. /** @hidden */
  25327. _skipRendering: boolean;
  25328. /** @hidden */
  25329. _projectionMatrix: Matrix;
  25330. /** @hidden */
  25331. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25332. /** @hidden */
  25333. _activeMeshes: SmartArray<AbstractMesh>;
  25334. protected _globalPosition: Vector3;
  25335. /** @hidden */
  25336. _computedViewMatrix: Matrix;
  25337. private _doNotComputeProjectionMatrix;
  25338. private _transformMatrix;
  25339. private _frustumPlanes;
  25340. private _refreshFrustumPlanes;
  25341. private _storedFov;
  25342. private _stateStored;
  25343. /**
  25344. * Instantiates a new camera object.
  25345. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25346. * @see http://doc.babylonjs.com/features/cameras
  25347. * @param name Defines the name of the camera in the scene
  25348. * @param position Defines the position of the camera
  25349. * @param scene Defines the scene the camera belongs too
  25350. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25351. */
  25352. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25353. /**
  25354. * Store current camera state (fov, position, etc..)
  25355. * @returns the camera
  25356. */
  25357. storeState(): Camera;
  25358. /**
  25359. * Restores the camera state values if it has been stored. You must call storeState() first
  25360. */
  25361. protected _restoreStateValues(): boolean;
  25362. /**
  25363. * Restored camera state. You must call storeState() first.
  25364. * @returns true if restored and false otherwise
  25365. */
  25366. restoreState(): boolean;
  25367. /**
  25368. * Gets the class name of the camera.
  25369. * @returns the class name
  25370. */
  25371. getClassName(): string;
  25372. /** @hidden */
  25373. readonly _isCamera: boolean;
  25374. /**
  25375. * Gets a string representation of the camera useful for debug purpose.
  25376. * @param fullDetails Defines that a more verboe level of logging is required
  25377. * @returns the string representation
  25378. */
  25379. toString(fullDetails?: boolean): string;
  25380. /**
  25381. * Gets the current world space position of the camera.
  25382. */
  25383. readonly globalPosition: Vector3;
  25384. /**
  25385. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25386. * @returns the active meshe list
  25387. */
  25388. getActiveMeshes(): SmartArray<AbstractMesh>;
  25389. /**
  25390. * Check wether a mesh is part of the current active mesh list of the camera
  25391. * @param mesh Defines the mesh to check
  25392. * @returns true if active, false otherwise
  25393. */
  25394. isActiveMesh(mesh: Mesh): boolean;
  25395. /**
  25396. * Is this camera ready to be used/rendered
  25397. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25398. * @return true if the camera is ready
  25399. */
  25400. isReady(completeCheck?: boolean): boolean;
  25401. /** @hidden */
  25402. _initCache(): void;
  25403. /** @hidden */
  25404. _updateCache(ignoreParentClass?: boolean): void;
  25405. /** @hidden */
  25406. _isSynchronized(): boolean;
  25407. /** @hidden */
  25408. _isSynchronizedViewMatrix(): boolean;
  25409. /** @hidden */
  25410. _isSynchronizedProjectionMatrix(): boolean;
  25411. /**
  25412. * Attach the input controls to a specific dom element to get the input from.
  25413. * @param element Defines the element the controls should be listened from
  25414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25415. */
  25416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25417. /**
  25418. * Detach the current controls from the specified dom element.
  25419. * @param element Defines the element to stop listening the inputs from
  25420. */
  25421. detachControl(element: HTMLElement): void;
  25422. /**
  25423. * Update the camera state according to the different inputs gathered during the frame.
  25424. */
  25425. update(): void;
  25426. /** @hidden */
  25427. _checkInputs(): void;
  25428. /** @hidden */
  25429. readonly rigCameras: Camera[];
  25430. /**
  25431. * Gets the post process used by the rig cameras
  25432. */
  25433. readonly rigPostProcess: Nullable<PostProcess>;
  25434. /**
  25435. * Internal, gets the first post proces.
  25436. * @returns the first post process to be run on this camera.
  25437. */
  25438. _getFirstPostProcess(): Nullable<PostProcess>;
  25439. private _cascadePostProcessesToRigCams;
  25440. /**
  25441. * Attach a post process to the camera.
  25442. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25443. * @param postProcess The post process to attach to the camera
  25444. * @param insertAt The position of the post process in case several of them are in use in the scene
  25445. * @returns the position the post process has been inserted at
  25446. */
  25447. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25448. /**
  25449. * Detach a post process to the camera.
  25450. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25451. * @param postProcess The post process to detach from the camera
  25452. */
  25453. detachPostProcess(postProcess: PostProcess): void;
  25454. /**
  25455. * Gets the current world matrix of the camera
  25456. */
  25457. getWorldMatrix(): Matrix;
  25458. /** @hidden */
  25459. _getViewMatrix(): Matrix;
  25460. /**
  25461. * Gets the current view matrix of the camera.
  25462. * @param force forces the camera to recompute the matrix without looking at the cached state
  25463. * @returns the view matrix
  25464. */
  25465. getViewMatrix(force?: boolean): Matrix;
  25466. /**
  25467. * Freeze the projection matrix.
  25468. * It will prevent the cache check of the camera projection compute and can speed up perf
  25469. * if no parameter of the camera are meant to change
  25470. * @param projection Defines manually a projection if necessary
  25471. */
  25472. freezeProjectionMatrix(projection?: Matrix): void;
  25473. /**
  25474. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25475. */
  25476. unfreezeProjectionMatrix(): void;
  25477. /**
  25478. * Gets the current projection matrix of the camera.
  25479. * @param force forces the camera to recompute the matrix without looking at the cached state
  25480. * @returns the projection matrix
  25481. */
  25482. getProjectionMatrix(force?: boolean): Matrix;
  25483. /**
  25484. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25485. * @returns a Matrix
  25486. */
  25487. getTransformationMatrix(): Matrix;
  25488. private _updateFrustumPlanes;
  25489. /**
  25490. * Checks if a cullable object (mesh...) is in the camera frustum
  25491. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25492. * @param target The object to check
  25493. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25494. * @returns true if the object is in frustum otherwise false
  25495. */
  25496. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25497. /**
  25498. * Checks if a cullable object (mesh...) is in the camera frustum
  25499. * Unlike isInFrustum this cheks the full bounding box
  25500. * @param target The object to check
  25501. * @returns true if the object is in frustum otherwise false
  25502. */
  25503. isCompletelyInFrustum(target: ICullable): boolean;
  25504. /**
  25505. * Gets a ray in the forward direction from the camera.
  25506. * @param length Defines the length of the ray to create
  25507. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25508. * @param origin Defines the start point of the ray which defaults to the camera position
  25509. * @returns the forward ray
  25510. */
  25511. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25512. /**
  25513. * Releases resources associated with this node.
  25514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25516. */
  25517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25518. /** @hidden */
  25519. _isLeftCamera: boolean;
  25520. /**
  25521. * Gets the left camera of a rig setup in case of Rigged Camera
  25522. */
  25523. readonly isLeftCamera: boolean;
  25524. /** @hidden */
  25525. _isRightCamera: boolean;
  25526. /**
  25527. * Gets the right camera of a rig setup in case of Rigged Camera
  25528. */
  25529. readonly isRightCamera: boolean;
  25530. /**
  25531. * Gets the left camera of a rig setup in case of Rigged Camera
  25532. */
  25533. readonly leftCamera: Nullable<FreeCamera>;
  25534. /**
  25535. * Gets the right camera of a rig setup in case of Rigged Camera
  25536. */
  25537. readonly rightCamera: Nullable<FreeCamera>;
  25538. /**
  25539. * Gets the left camera target of a rig setup in case of Rigged Camera
  25540. * @returns the target position
  25541. */
  25542. getLeftTarget(): Nullable<Vector3>;
  25543. /**
  25544. * Gets the right camera target of a rig setup in case of Rigged Camera
  25545. * @returns the target position
  25546. */
  25547. getRightTarget(): Nullable<Vector3>;
  25548. /**
  25549. * @hidden
  25550. */
  25551. setCameraRigMode(mode: number, rigParams: any): void;
  25552. /** @hidden */
  25553. static _setStereoscopicRigMode(camera: Camera): void;
  25554. /** @hidden */
  25555. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25556. /** @hidden */
  25557. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25558. /** @hidden */
  25559. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25560. /** @hidden */
  25561. _getVRProjectionMatrix(): Matrix;
  25562. protected _updateCameraRotationMatrix(): void;
  25563. protected _updateWebVRCameraRotationMatrix(): void;
  25564. /**
  25565. * This function MUST be overwritten by the different WebVR cameras available.
  25566. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25567. * @hidden
  25568. */
  25569. _getWebVRProjectionMatrix(): Matrix;
  25570. /**
  25571. * This function MUST be overwritten by the different WebVR cameras available.
  25572. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25573. * @hidden
  25574. */
  25575. _getWebVRViewMatrix(): Matrix;
  25576. /** @hidden */
  25577. setCameraRigParameter(name: string, value: any): void;
  25578. /**
  25579. * needs to be overridden by children so sub has required properties to be copied
  25580. * @hidden
  25581. */
  25582. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25583. /**
  25584. * May need to be overridden by children
  25585. * @hidden
  25586. */
  25587. _updateRigCameras(): void;
  25588. /** @hidden */
  25589. _setupInputs(): void;
  25590. /**
  25591. * Serialiaze the camera setup to a json represention
  25592. * @returns the JSON representation
  25593. */
  25594. serialize(): any;
  25595. /**
  25596. * Clones the current camera.
  25597. * @param name The cloned camera name
  25598. * @returns the cloned camera
  25599. */
  25600. clone(name: string): Camera;
  25601. /**
  25602. * Gets the direction of the camera relative to a given local axis.
  25603. * @param localAxis Defines the reference axis to provide a relative direction.
  25604. * @return the direction
  25605. */
  25606. getDirection(localAxis: Vector3): Vector3;
  25607. /**
  25608. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25609. * @param localAxis Defines the reference axis to provide a relative direction.
  25610. * @param result Defines the vector to store the result in
  25611. */
  25612. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25613. /**
  25614. * Gets a camera constructor for a given camera type
  25615. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25616. * @param name The name of the camera the result will be able to instantiate
  25617. * @param scene The scene the result will construct the camera in
  25618. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25619. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25620. * @returns a factory method to construc the camera
  25621. */
  25622. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25623. /**
  25624. * Compute the world matrix of the camera.
  25625. * @returns the camera workd matrix
  25626. */
  25627. computeWorldMatrix(): Matrix;
  25628. /**
  25629. * Parse a JSON and creates the camera from the parsed information
  25630. * @param parsedCamera The JSON to parse
  25631. * @param scene The scene to instantiate the camera in
  25632. * @returns the newly constructed camera
  25633. */
  25634. static Parse(parsedCamera: any, scene: Scene): Camera;
  25635. }
  25636. }
  25637. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25638. import { Nullable } from "babylonjs/types";
  25639. import { Scene } from "babylonjs/scene";
  25640. import { Vector4 } from "babylonjs/Maths/math.vector";
  25641. import { Mesh } from "babylonjs/Meshes/mesh";
  25642. /**
  25643. * Class containing static functions to help procedurally build meshes
  25644. */
  25645. export class DiscBuilder {
  25646. /**
  25647. * Creates a plane polygonal mesh. By default, this is a disc
  25648. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25649. * * 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
  25650. * * 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
  25651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25654. * @param name defines the name of the mesh
  25655. * @param options defines the options used to create the mesh
  25656. * @param scene defines the hosting scene
  25657. * @returns the plane polygonal mesh
  25658. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25659. */
  25660. static CreateDisc(name: string, options: {
  25661. radius?: number;
  25662. tessellation?: number;
  25663. arc?: number;
  25664. updatable?: boolean;
  25665. sideOrientation?: number;
  25666. frontUVs?: Vector4;
  25667. backUVs?: Vector4;
  25668. }, scene?: Nullable<Scene>): Mesh;
  25669. }
  25670. }
  25671. declare module "babylonjs/Particles/solidParticleSystem" {
  25672. import { Vector3 } from "babylonjs/Maths/math.vector";
  25673. import { Mesh } from "babylonjs/Meshes/mesh";
  25674. import { Scene, IDisposable } from "babylonjs/scene";
  25675. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25676. /**
  25677. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25678. *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.
  25679. * The SPS is also a particle system. It provides some methods to manage the particles.
  25680. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25681. *
  25682. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25683. */
  25684. export class SolidParticleSystem implements IDisposable {
  25685. /**
  25686. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25687. * Example : var p = SPS.particles[i];
  25688. */
  25689. particles: SolidParticle[];
  25690. /**
  25691. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25692. */
  25693. nbParticles: number;
  25694. /**
  25695. * If the particles must ever face the camera (default false). Useful for planar particles.
  25696. */
  25697. billboard: boolean;
  25698. /**
  25699. * Recompute normals when adding a shape
  25700. */
  25701. recomputeNormals: boolean;
  25702. /**
  25703. * This a counter ofr your own usage. It's not set by any SPS functions.
  25704. */
  25705. counter: number;
  25706. /**
  25707. * The SPS name. This name is also given to the underlying mesh.
  25708. */
  25709. name: string;
  25710. /**
  25711. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25712. */
  25713. mesh: Mesh;
  25714. /**
  25715. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25716. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25717. */
  25718. vars: any;
  25719. /**
  25720. * This array is populated when the SPS is set as 'pickable'.
  25721. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25722. * Each element of this array is an object `{idx: int, faceId: int}`.
  25723. * `idx` is the picked particle index in the `SPS.particles` array
  25724. * `faceId` is the picked face index counted within this particle.
  25725. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25726. */
  25727. pickedParticles: {
  25728. idx: number;
  25729. faceId: number;
  25730. }[];
  25731. /**
  25732. * This array is populated when `enableDepthSort` is set to true.
  25733. * Each element of this array is an instance of the class DepthSortedParticle.
  25734. */
  25735. depthSortedParticles: DepthSortedParticle[];
  25736. /**
  25737. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25738. * @hidden
  25739. */
  25740. _bSphereOnly: boolean;
  25741. /**
  25742. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25743. * @hidden
  25744. */
  25745. _bSphereRadiusFactor: number;
  25746. private _scene;
  25747. private _positions;
  25748. private _indices;
  25749. private _normals;
  25750. private _colors;
  25751. private _uvs;
  25752. private _indices32;
  25753. private _positions32;
  25754. private _normals32;
  25755. private _fixedNormal32;
  25756. private _colors32;
  25757. private _uvs32;
  25758. private _index;
  25759. private _updatable;
  25760. private _pickable;
  25761. private _isVisibilityBoxLocked;
  25762. private _alwaysVisible;
  25763. private _depthSort;
  25764. private _shapeCounter;
  25765. private _copy;
  25766. private _color;
  25767. private _computeParticleColor;
  25768. private _computeParticleTexture;
  25769. private _computeParticleRotation;
  25770. private _computeParticleVertex;
  25771. private _computeBoundingBox;
  25772. private _depthSortParticles;
  25773. private _camera;
  25774. private _mustUnrotateFixedNormals;
  25775. private _particlesIntersect;
  25776. private _needs32Bits;
  25777. /**
  25778. * Creates a SPS (Solid Particle System) object.
  25779. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25780. * @param scene (Scene) is the scene in which the SPS is added.
  25781. * @param options defines the options of the sps e.g.
  25782. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25783. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25784. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25785. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25786. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25787. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25788. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25789. */
  25790. constructor(name: string, scene: Scene, options?: {
  25791. updatable?: boolean;
  25792. isPickable?: boolean;
  25793. enableDepthSort?: boolean;
  25794. particleIntersection?: boolean;
  25795. boundingSphereOnly?: boolean;
  25796. bSphereRadiusFactor?: number;
  25797. });
  25798. /**
  25799. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25800. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25801. * @returns the created mesh
  25802. */
  25803. buildMesh(): Mesh;
  25804. /**
  25805. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25806. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25807. * Thus the particles generated from `digest()` have their property `position` set yet.
  25808. * @param mesh ( Mesh ) is the mesh to be digested
  25809. * @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
  25810. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25811. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25812. * @returns the current SPS
  25813. */
  25814. digest(mesh: Mesh, options?: {
  25815. facetNb?: number;
  25816. number?: number;
  25817. delta?: number;
  25818. }): SolidParticleSystem;
  25819. private _unrotateFixedNormals;
  25820. private _resetCopy;
  25821. private _meshBuilder;
  25822. private _posToShape;
  25823. private _uvsToShapeUV;
  25824. private _addParticle;
  25825. /**
  25826. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25827. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25828. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25829. * @param nb (positive integer) the number of particles to be created from this model
  25830. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25831. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25832. * @returns the number of shapes in the system
  25833. */
  25834. addShape(mesh: Mesh, nb: number, options?: {
  25835. positionFunction?: any;
  25836. vertexFunction?: any;
  25837. }): number;
  25838. private _rebuildParticle;
  25839. /**
  25840. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25841. * @returns the SPS.
  25842. */
  25843. rebuildMesh(): SolidParticleSystem;
  25844. /**
  25845. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25846. * This method calls `updateParticle()` for each particle of the SPS.
  25847. * For an animated SPS, it is usually called within the render loop.
  25848. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25849. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25850. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25851. * @returns the SPS.
  25852. */
  25853. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25854. /**
  25855. * Disposes the SPS.
  25856. */
  25857. dispose(): void;
  25858. /**
  25859. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25860. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25861. * @returns the SPS.
  25862. */
  25863. refreshVisibleSize(): SolidParticleSystem;
  25864. /**
  25865. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25866. * @param size the size (float) of the visibility box
  25867. * note : this doesn't lock the SPS mesh bounding box.
  25868. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25869. */
  25870. setVisibilityBox(size: number): void;
  25871. /**
  25872. * Gets whether the SPS as always visible or not
  25873. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25874. */
  25875. /**
  25876. * Sets the SPS as always visible or not
  25877. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25878. */
  25879. isAlwaysVisible: boolean;
  25880. /**
  25881. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25882. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25883. */
  25884. /**
  25885. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25887. */
  25888. isVisibilityBoxLocked: boolean;
  25889. /**
  25890. * Tells to `setParticles()` to compute the particle rotations or not.
  25891. * Default value : true. The SPS is faster when it's set to false.
  25892. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25893. */
  25894. /**
  25895. * Gets if `setParticles()` computes the particle rotations or not.
  25896. * Default value : true. The SPS is faster when it's set to false.
  25897. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25898. */
  25899. computeParticleRotation: boolean;
  25900. /**
  25901. * Tells to `setParticles()` to compute the particle colors or not.
  25902. * Default value : true. The SPS is faster when it's set to false.
  25903. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25904. */
  25905. /**
  25906. * Gets if `setParticles()` computes the particle colors or not.
  25907. * Default value : true. The SPS is faster when it's set to false.
  25908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25909. */
  25910. computeParticleColor: boolean;
  25911. /**
  25912. * Gets if `setParticles()` computes the particle textures or not.
  25913. * Default value : true. The SPS is faster when it's set to false.
  25914. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25915. */
  25916. computeParticleTexture: boolean;
  25917. /**
  25918. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25919. * Default value : false. The SPS is faster when it's set to false.
  25920. * Note : the particle custom vertex positions aren't stored values.
  25921. */
  25922. /**
  25923. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25924. * Default value : false. The SPS is faster when it's set to false.
  25925. * Note : the particle custom vertex positions aren't stored values.
  25926. */
  25927. computeParticleVertex: boolean;
  25928. /**
  25929. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25930. */
  25931. /**
  25932. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25933. */
  25934. computeBoundingBox: boolean;
  25935. /**
  25936. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25937. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25938. * Default : `true`
  25939. */
  25940. /**
  25941. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25942. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25943. * Default : `true`
  25944. */
  25945. depthSortParticles: boolean;
  25946. /**
  25947. * This function does nothing. It may be overwritten to set all the particle first values.
  25948. * The SPS doesn't call this function, you may have to call it by your own.
  25949. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25950. */
  25951. initParticles(): void;
  25952. /**
  25953. * This function does nothing. It may be overwritten to recycle a particle.
  25954. * The SPS doesn't call this function, you may have to call it by your own.
  25955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25956. * @param particle The particle to recycle
  25957. * @returns the recycled particle
  25958. */
  25959. recycleParticle(particle: SolidParticle): SolidParticle;
  25960. /**
  25961. * Updates a particle : this function should be overwritten by the user.
  25962. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25963. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25964. * @example : just set a particle position or velocity and recycle conditions
  25965. * @param particle The particle to update
  25966. * @returns the updated particle
  25967. */
  25968. updateParticle(particle: SolidParticle): SolidParticle;
  25969. /**
  25970. * Updates a vertex of a particle : it can be overwritten by the user.
  25971. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25972. * @param particle the current particle
  25973. * @param vertex the current index of the current particle
  25974. * @param pt the index of the current vertex in the particle shape
  25975. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25976. * @example : just set a vertex particle position
  25977. * @returns the updated vertex
  25978. */
  25979. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25980. /**
  25981. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25982. * This does nothing and may be overwritten by the user.
  25983. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25984. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25985. * @param update the boolean update value actually passed to setParticles()
  25986. */
  25987. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25988. /**
  25989. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25990. * This will be passed three parameters.
  25991. * This does nothing and may be overwritten by the user.
  25992. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25993. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25994. * @param update the boolean update value actually passed to setParticles()
  25995. */
  25996. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25997. }
  25998. }
  25999. declare module "babylonjs/Particles/solidParticle" {
  26000. import { Nullable } from "babylonjs/types";
  26001. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26002. import { Color4 } from "babylonjs/Maths/math.color";
  26003. import { Mesh } from "babylonjs/Meshes/mesh";
  26004. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26005. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26006. import { Plane } from "babylonjs/Maths/math.plane";
  26007. /**
  26008. * Represents one particle of a solid particle system.
  26009. */
  26010. export class SolidParticle {
  26011. /**
  26012. * particle global index
  26013. */
  26014. idx: number;
  26015. /**
  26016. * The color of the particle
  26017. */
  26018. color: Nullable<Color4>;
  26019. /**
  26020. * The world space position of the particle.
  26021. */
  26022. position: Vector3;
  26023. /**
  26024. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26025. */
  26026. rotation: Vector3;
  26027. /**
  26028. * The world space rotation quaternion of the particle.
  26029. */
  26030. rotationQuaternion: Nullable<Quaternion>;
  26031. /**
  26032. * The scaling of the particle.
  26033. */
  26034. scaling: Vector3;
  26035. /**
  26036. * The uvs of the particle.
  26037. */
  26038. uvs: Vector4;
  26039. /**
  26040. * The current speed of the particle.
  26041. */
  26042. velocity: Vector3;
  26043. /**
  26044. * The pivot point in the particle local space.
  26045. */
  26046. pivot: Vector3;
  26047. /**
  26048. * Must the particle be translated from its pivot point in its local space ?
  26049. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26050. * Default : false
  26051. */
  26052. translateFromPivot: boolean;
  26053. /**
  26054. * Is the particle active or not ?
  26055. */
  26056. alive: boolean;
  26057. /**
  26058. * Is the particle visible or not ?
  26059. */
  26060. isVisible: boolean;
  26061. /**
  26062. * Index of this particle in the global "positions" array (Internal use)
  26063. * @hidden
  26064. */
  26065. _pos: number;
  26066. /**
  26067. * @hidden Index of this particle in the global "indices" array (Internal use)
  26068. */
  26069. _ind: number;
  26070. /**
  26071. * @hidden ModelShape of this particle (Internal use)
  26072. */
  26073. _model: ModelShape;
  26074. /**
  26075. * ModelShape id of this particle
  26076. */
  26077. shapeId: number;
  26078. /**
  26079. * Index of the particle in its shape id
  26080. */
  26081. idxInShape: number;
  26082. /**
  26083. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26084. */
  26085. _modelBoundingInfo: BoundingInfo;
  26086. /**
  26087. * @hidden Particle BoundingInfo object (Internal use)
  26088. */
  26089. _boundingInfo: BoundingInfo;
  26090. /**
  26091. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26092. */
  26093. _sps: SolidParticleSystem;
  26094. /**
  26095. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26096. */
  26097. _stillInvisible: boolean;
  26098. /**
  26099. * @hidden Last computed particle rotation matrix
  26100. */
  26101. _rotationMatrix: number[];
  26102. /**
  26103. * Parent particle Id, if any.
  26104. * Default null.
  26105. */
  26106. parentId: Nullable<number>;
  26107. /**
  26108. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26109. * The possible values are :
  26110. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26111. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26113. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26114. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26115. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26116. * */
  26117. cullingStrategy: number;
  26118. /**
  26119. * @hidden Internal global position in the SPS.
  26120. */
  26121. _globalPosition: Vector3;
  26122. /**
  26123. * Creates a Solid Particle object.
  26124. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26125. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26126. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26127. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26128. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26129. * @param shapeId (integer) is the model shape identifier in the SPS.
  26130. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26131. * @param sps defines the sps it is associated to
  26132. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26133. */
  26134. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26135. /**
  26136. * Legacy support, changed scale to scaling
  26137. */
  26138. /**
  26139. * Legacy support, changed scale to scaling
  26140. */
  26141. scale: Vector3;
  26142. /**
  26143. * Legacy support, changed quaternion to rotationQuaternion
  26144. */
  26145. /**
  26146. * Legacy support, changed quaternion to rotationQuaternion
  26147. */
  26148. quaternion: Nullable<Quaternion>;
  26149. /**
  26150. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26151. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26152. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26153. * @returns true if it intersects
  26154. */
  26155. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26156. /**
  26157. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26158. * A particle is in the frustum if its bounding box intersects the frustum
  26159. * @param frustumPlanes defines the frustum to test
  26160. * @returns true if the particle is in the frustum planes
  26161. */
  26162. isInFrustum(frustumPlanes: Plane[]): boolean;
  26163. /**
  26164. * get the rotation matrix of the particle
  26165. * @hidden
  26166. */
  26167. getRotationMatrix(m: Matrix): void;
  26168. }
  26169. /**
  26170. * Represents the shape of the model used by one particle of a solid particle system.
  26171. * SPS internal tool, don't use it manually.
  26172. */
  26173. export class ModelShape {
  26174. /**
  26175. * The shape id
  26176. * @hidden
  26177. */
  26178. shapeID: number;
  26179. /**
  26180. * flat array of model positions (internal use)
  26181. * @hidden
  26182. */
  26183. _shape: Vector3[];
  26184. /**
  26185. * flat array of model UVs (internal use)
  26186. * @hidden
  26187. */
  26188. _shapeUV: number[];
  26189. /**
  26190. * length of the shape in the model indices array (internal use)
  26191. * @hidden
  26192. */
  26193. _indicesLength: number;
  26194. /**
  26195. * Custom position function (internal use)
  26196. * @hidden
  26197. */
  26198. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26199. /**
  26200. * Custom vertex function (internal use)
  26201. * @hidden
  26202. */
  26203. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26204. /**
  26205. * 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.
  26206. * SPS internal tool, don't use it manually.
  26207. * @hidden
  26208. */
  26209. 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>);
  26210. }
  26211. /**
  26212. * Represents a Depth Sorted Particle in the solid particle system.
  26213. */
  26214. export class DepthSortedParticle {
  26215. /**
  26216. * Index of the particle in the "indices" array
  26217. */
  26218. ind: number;
  26219. /**
  26220. * Length of the particle shape in the "indices" array
  26221. */
  26222. indicesLength: number;
  26223. /**
  26224. * Squared distance from the particle to the camera
  26225. */
  26226. sqDistance: number;
  26227. }
  26228. }
  26229. declare module "babylonjs/Collisions/meshCollisionData" {
  26230. import { Collider } from "babylonjs/Collisions/collider";
  26231. import { Vector3 } from "babylonjs/Maths/math.vector";
  26232. import { Nullable } from "babylonjs/types";
  26233. import { Observer } from "babylonjs/Misc/observable";
  26234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26235. /**
  26236. * @hidden
  26237. */
  26238. export class _MeshCollisionData {
  26239. _checkCollisions: boolean;
  26240. _collisionMask: number;
  26241. _collisionGroup: number;
  26242. _collider: Nullable<Collider>;
  26243. _oldPositionForCollisions: Vector3;
  26244. _diffPositionForCollisions: Vector3;
  26245. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26246. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26247. }
  26248. }
  26249. declare module "babylonjs/Meshes/abstractMesh" {
  26250. import { Observable } from "babylonjs/Misc/observable";
  26251. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26252. import { Camera } from "babylonjs/Cameras/camera";
  26253. import { Scene, IDisposable } from "babylonjs/scene";
  26254. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26255. import { Node } from "babylonjs/node";
  26256. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26259. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26260. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26261. import { Material } from "babylonjs/Materials/material";
  26262. import { Light } from "babylonjs/Lights/light";
  26263. import { Skeleton } from "babylonjs/Bones/skeleton";
  26264. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26265. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26266. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26267. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26269. import { Plane } from "babylonjs/Maths/math.plane";
  26270. import { Ray } from "babylonjs/Culling/ray";
  26271. import { Collider } from "babylonjs/Collisions/collider";
  26272. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26273. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26274. /** @hidden */
  26275. class _FacetDataStorage {
  26276. facetPositions: Vector3[];
  26277. facetNormals: Vector3[];
  26278. facetPartitioning: number[][];
  26279. facetNb: number;
  26280. partitioningSubdivisions: number;
  26281. partitioningBBoxRatio: number;
  26282. facetDataEnabled: boolean;
  26283. facetParameters: any;
  26284. bbSize: Vector3;
  26285. subDiv: {
  26286. max: number;
  26287. X: number;
  26288. Y: number;
  26289. Z: number;
  26290. };
  26291. facetDepthSort: boolean;
  26292. facetDepthSortEnabled: boolean;
  26293. depthSortedIndices: IndicesArray;
  26294. depthSortedFacets: {
  26295. ind: number;
  26296. sqDistance: number;
  26297. }[];
  26298. facetDepthSortFunction: (f1: {
  26299. ind: number;
  26300. sqDistance: number;
  26301. }, f2: {
  26302. ind: number;
  26303. sqDistance: number;
  26304. }) => number;
  26305. facetDepthSortFrom: Vector3;
  26306. facetDepthSortOrigin: Vector3;
  26307. invertedMatrix: Matrix;
  26308. }
  26309. /**
  26310. * @hidden
  26311. **/
  26312. class _InternalAbstractMeshDataInfo {
  26313. _hasVertexAlpha: boolean;
  26314. _useVertexColors: boolean;
  26315. _numBoneInfluencers: number;
  26316. _applyFog: boolean;
  26317. _receiveShadows: boolean;
  26318. _facetData: _FacetDataStorage;
  26319. _visibility: number;
  26320. _skeleton: Nullable<Skeleton>;
  26321. _layerMask: number;
  26322. _computeBonesUsingShaders: boolean;
  26323. _isActive: boolean;
  26324. _onlyForInstances: boolean;
  26325. _isActiveIntermediate: boolean;
  26326. _onlyForInstancesIntermediate: boolean;
  26327. }
  26328. /**
  26329. * Class used to store all common mesh properties
  26330. */
  26331. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26332. /** No occlusion */
  26333. static OCCLUSION_TYPE_NONE: number;
  26334. /** Occlusion set to optimisitic */
  26335. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26336. /** Occlusion set to strict */
  26337. static OCCLUSION_TYPE_STRICT: number;
  26338. /** Use an accurante occlusion algorithm */
  26339. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26340. /** Use a conservative occlusion algorithm */
  26341. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26342. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26343. * Test order :
  26344. * Is the bounding sphere outside the frustum ?
  26345. * If not, are the bounding box vertices outside the frustum ?
  26346. * It not, then the cullable object is in the frustum.
  26347. */
  26348. static readonly CULLINGSTRATEGY_STANDARD: number;
  26349. /** Culling strategy : Bounding Sphere Only.
  26350. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26351. * It's also less accurate than the standard because some not visible objects can still be selected.
  26352. * Test : is the bounding sphere outside the frustum ?
  26353. * If not, then the cullable object is in the frustum.
  26354. */
  26355. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26356. /** Culling strategy : Optimistic Inclusion.
  26357. * This in an inclusion test first, then the standard exclusion test.
  26358. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26359. * 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.
  26360. * Anyway, it's as accurate as the standard strategy.
  26361. * Test :
  26362. * Is the cullable object bounding sphere center in the frustum ?
  26363. * If not, apply the default culling strategy.
  26364. */
  26365. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26366. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26367. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26368. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26369. * 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.
  26370. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26371. * Test :
  26372. * Is the cullable object bounding sphere center in the frustum ?
  26373. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26374. */
  26375. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26376. /**
  26377. * No billboard
  26378. */
  26379. static readonly BILLBOARDMODE_NONE: number;
  26380. /** Billboard on X axis */
  26381. static readonly BILLBOARDMODE_X: number;
  26382. /** Billboard on Y axis */
  26383. static readonly BILLBOARDMODE_Y: number;
  26384. /** Billboard on Z axis */
  26385. static readonly BILLBOARDMODE_Z: number;
  26386. /** Billboard on all axes */
  26387. static readonly BILLBOARDMODE_ALL: number;
  26388. /** Billboard on using position instead of orientation */
  26389. static readonly BILLBOARDMODE_USE_POSITION: number;
  26390. /** @hidden */
  26391. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26392. /**
  26393. * The culling strategy to use to check whether the mesh must be rendered or not.
  26394. * This value can be changed at any time and will be used on the next render mesh selection.
  26395. * The possible values are :
  26396. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26397. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26398. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26399. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26400. * Please read each static variable documentation to get details about the culling process.
  26401. * */
  26402. cullingStrategy: number;
  26403. /**
  26404. * Gets the number of facets in the mesh
  26405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26406. */
  26407. readonly facetNb: number;
  26408. /**
  26409. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26411. */
  26412. partitioningSubdivisions: number;
  26413. /**
  26414. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26415. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26417. */
  26418. partitioningBBoxRatio: number;
  26419. /**
  26420. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26421. * Works only for updatable meshes.
  26422. * Doesn't work with multi-materials
  26423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26424. */
  26425. mustDepthSortFacets: boolean;
  26426. /**
  26427. * The location (Vector3) where the facet depth sort must be computed from.
  26428. * By default, the active camera position.
  26429. * Used only when facet depth sort is enabled
  26430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26431. */
  26432. facetDepthSortFrom: Vector3;
  26433. /**
  26434. * gets a boolean indicating if facetData is enabled
  26435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26436. */
  26437. readonly isFacetDataEnabled: boolean;
  26438. /** @hidden */
  26439. _updateNonUniformScalingState(value: boolean): boolean;
  26440. /**
  26441. * An event triggered when this mesh collides with another one
  26442. */
  26443. onCollideObservable: Observable<AbstractMesh>;
  26444. /** Set a function to call when this mesh collides with another one */
  26445. onCollide: () => void;
  26446. /**
  26447. * An event triggered when the collision's position changes
  26448. */
  26449. onCollisionPositionChangeObservable: Observable<Vector3>;
  26450. /** Set a function to call when the collision's position changes */
  26451. onCollisionPositionChange: () => void;
  26452. /**
  26453. * An event triggered when material is changed
  26454. */
  26455. onMaterialChangedObservable: Observable<AbstractMesh>;
  26456. /**
  26457. * Gets or sets the orientation for POV movement & rotation
  26458. */
  26459. definedFacingForward: boolean;
  26460. /** @hidden */
  26461. _occlusionQuery: Nullable<WebGLQuery>;
  26462. /** @hidden */
  26463. _renderingGroup: Nullable<RenderingGroup>;
  26464. /**
  26465. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26466. */
  26467. /**
  26468. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26469. */
  26470. visibility: number;
  26471. /** Gets or sets the alpha index used to sort transparent meshes
  26472. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26473. */
  26474. alphaIndex: number;
  26475. /**
  26476. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26477. */
  26478. isVisible: boolean;
  26479. /**
  26480. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26481. */
  26482. isPickable: boolean;
  26483. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26484. showSubMeshesBoundingBox: boolean;
  26485. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26487. */
  26488. isBlocker: boolean;
  26489. /**
  26490. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26491. */
  26492. enablePointerMoveEvents: boolean;
  26493. /**
  26494. * Specifies the rendering group id for this mesh (0 by default)
  26495. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26496. */
  26497. renderingGroupId: number;
  26498. private _material;
  26499. /** Gets or sets current material */
  26500. material: Nullable<Material>;
  26501. /**
  26502. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26503. * @see http://doc.babylonjs.com/babylon101/shadows
  26504. */
  26505. receiveShadows: boolean;
  26506. /** Defines color to use when rendering outline */
  26507. outlineColor: Color3;
  26508. /** Define width to use when rendering outline */
  26509. outlineWidth: number;
  26510. /** Defines color to use when rendering overlay */
  26511. overlayColor: Color3;
  26512. /** Defines alpha to use when rendering overlay */
  26513. overlayAlpha: number;
  26514. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26515. hasVertexAlpha: boolean;
  26516. /** 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) */
  26517. useVertexColors: boolean;
  26518. /**
  26519. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26520. */
  26521. computeBonesUsingShaders: boolean;
  26522. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26523. numBoneInfluencers: number;
  26524. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26525. applyFog: boolean;
  26526. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26527. useOctreeForRenderingSelection: boolean;
  26528. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26529. useOctreeForPicking: boolean;
  26530. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26531. useOctreeForCollisions: boolean;
  26532. /**
  26533. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26534. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26535. */
  26536. layerMask: number;
  26537. /**
  26538. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26539. */
  26540. alwaysSelectAsActiveMesh: boolean;
  26541. /**
  26542. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26543. */
  26544. doNotSyncBoundingInfo: boolean;
  26545. /**
  26546. * Gets or sets the current action manager
  26547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26548. */
  26549. actionManager: Nullable<AbstractActionManager>;
  26550. private _meshCollisionData;
  26551. /**
  26552. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26554. */
  26555. ellipsoid: Vector3;
  26556. /**
  26557. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26558. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26559. */
  26560. ellipsoidOffset: Vector3;
  26561. /**
  26562. * Gets or sets a collision mask used to mask collisions (default is -1).
  26563. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26564. */
  26565. collisionMask: number;
  26566. /**
  26567. * Gets or sets the current collision group mask (-1 by default).
  26568. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26569. */
  26570. collisionGroup: number;
  26571. /**
  26572. * Defines edge width used when edgesRenderer is enabled
  26573. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26574. */
  26575. edgesWidth: number;
  26576. /**
  26577. * Defines edge color used when edgesRenderer is enabled
  26578. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26579. */
  26580. edgesColor: Color4;
  26581. /** @hidden */
  26582. _edgesRenderer: Nullable<IEdgesRenderer>;
  26583. /** @hidden */
  26584. _masterMesh: Nullable<AbstractMesh>;
  26585. /** @hidden */
  26586. _boundingInfo: Nullable<BoundingInfo>;
  26587. /** @hidden */
  26588. _renderId: number;
  26589. /**
  26590. * Gets or sets the list of subMeshes
  26591. * @see http://doc.babylonjs.com/how_to/multi_materials
  26592. */
  26593. subMeshes: SubMesh[];
  26594. /** @hidden */
  26595. _intersectionsInProgress: AbstractMesh[];
  26596. /** @hidden */
  26597. _unIndexed: boolean;
  26598. /** @hidden */
  26599. _lightSources: Light[];
  26600. /** Gets the list of lights affecting that mesh */
  26601. readonly lightSources: Light[];
  26602. /** @hidden */
  26603. readonly _positions: Nullable<Vector3[]>;
  26604. /** @hidden */
  26605. _waitingData: {
  26606. lods: Nullable<any>;
  26607. actions: Nullable<any>;
  26608. freezeWorldMatrix: Nullable<boolean>;
  26609. };
  26610. /** @hidden */
  26611. _bonesTransformMatrices: Nullable<Float32Array>;
  26612. /** @hidden */
  26613. _transformMatrixTexture: Nullable<RawTexture>;
  26614. /**
  26615. * Gets or sets a skeleton to apply skining transformations
  26616. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26617. */
  26618. skeleton: Nullable<Skeleton>;
  26619. /**
  26620. * An event triggered when the mesh is rebuilt.
  26621. */
  26622. onRebuildObservable: Observable<AbstractMesh>;
  26623. /**
  26624. * Creates a new AbstractMesh
  26625. * @param name defines the name of the mesh
  26626. * @param scene defines the hosting scene
  26627. */
  26628. constructor(name: string, scene?: Nullable<Scene>);
  26629. /**
  26630. * Returns the string "AbstractMesh"
  26631. * @returns "AbstractMesh"
  26632. */
  26633. getClassName(): string;
  26634. /**
  26635. * Gets a string representation of the current mesh
  26636. * @param fullDetails defines a boolean indicating if full details must be included
  26637. * @returns a string representation of the current mesh
  26638. */
  26639. toString(fullDetails?: boolean): string;
  26640. /**
  26641. * @hidden
  26642. */
  26643. protected _getEffectiveParent(): Nullable<Node>;
  26644. /** @hidden */
  26645. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26646. /** @hidden */
  26647. _rebuild(): void;
  26648. /** @hidden */
  26649. _resyncLightSources(): void;
  26650. /** @hidden */
  26651. _resyncLighSource(light: Light): void;
  26652. /** @hidden */
  26653. _unBindEffect(): void;
  26654. /** @hidden */
  26655. _removeLightSource(light: Light): void;
  26656. private _markSubMeshesAsDirty;
  26657. /** @hidden */
  26658. _markSubMeshesAsLightDirty(): void;
  26659. /** @hidden */
  26660. _markSubMeshesAsAttributesDirty(): void;
  26661. /** @hidden */
  26662. _markSubMeshesAsMiscDirty(): void;
  26663. /**
  26664. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26665. */
  26666. scaling: Vector3;
  26667. /**
  26668. * Returns true if the mesh is blocked. Implemented by child classes
  26669. */
  26670. readonly isBlocked: boolean;
  26671. /**
  26672. * Returns the mesh itself by default. Implemented by child classes
  26673. * @param camera defines the camera to use to pick the right LOD level
  26674. * @returns the currentAbstractMesh
  26675. */
  26676. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26677. /**
  26678. * Returns 0 by default. Implemented by child classes
  26679. * @returns an integer
  26680. */
  26681. getTotalVertices(): number;
  26682. /**
  26683. * Returns a positive integer : the total number of indices in this mesh geometry.
  26684. * @returns the numner of indices or zero if the mesh has no geometry.
  26685. */
  26686. getTotalIndices(): number;
  26687. /**
  26688. * Returns null by default. Implemented by child classes
  26689. * @returns null
  26690. */
  26691. getIndices(): Nullable<IndicesArray>;
  26692. /**
  26693. * Returns the array of the requested vertex data kind. Implemented by child classes
  26694. * @param kind defines the vertex data kind to use
  26695. * @returns null
  26696. */
  26697. getVerticesData(kind: string): Nullable<FloatArray>;
  26698. /**
  26699. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26700. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26701. * Note that a new underlying VertexBuffer object is created each call.
  26702. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26703. * @param kind defines vertex data kind:
  26704. * * VertexBuffer.PositionKind
  26705. * * VertexBuffer.UVKind
  26706. * * VertexBuffer.UV2Kind
  26707. * * VertexBuffer.UV3Kind
  26708. * * VertexBuffer.UV4Kind
  26709. * * VertexBuffer.UV5Kind
  26710. * * VertexBuffer.UV6Kind
  26711. * * VertexBuffer.ColorKind
  26712. * * VertexBuffer.MatricesIndicesKind
  26713. * * VertexBuffer.MatricesIndicesExtraKind
  26714. * * VertexBuffer.MatricesWeightsKind
  26715. * * VertexBuffer.MatricesWeightsExtraKind
  26716. * @param data defines the data source
  26717. * @param updatable defines if the data must be flagged as updatable (or static)
  26718. * @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
  26719. * @returns the current mesh
  26720. */
  26721. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26722. /**
  26723. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26724. * If the mesh has no geometry, it is simply returned as it is.
  26725. * @param kind defines vertex data kind:
  26726. * * VertexBuffer.PositionKind
  26727. * * VertexBuffer.UVKind
  26728. * * VertexBuffer.UV2Kind
  26729. * * VertexBuffer.UV3Kind
  26730. * * VertexBuffer.UV4Kind
  26731. * * VertexBuffer.UV5Kind
  26732. * * VertexBuffer.UV6Kind
  26733. * * VertexBuffer.ColorKind
  26734. * * VertexBuffer.MatricesIndicesKind
  26735. * * VertexBuffer.MatricesIndicesExtraKind
  26736. * * VertexBuffer.MatricesWeightsKind
  26737. * * VertexBuffer.MatricesWeightsExtraKind
  26738. * @param data defines the data source
  26739. * @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
  26740. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26741. * @returns the current mesh
  26742. */
  26743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26744. /**
  26745. * Sets the mesh indices,
  26746. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26747. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26748. * @param totalVertices Defines the total number of vertices
  26749. * @returns the current mesh
  26750. */
  26751. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26752. /**
  26753. * Gets a boolean indicating if specific vertex data is present
  26754. * @param kind defines the vertex data kind to use
  26755. * @returns true is data kind is present
  26756. */
  26757. isVerticesDataPresent(kind: string): boolean;
  26758. /**
  26759. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26760. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26761. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26762. * @returns a BoundingInfo
  26763. */
  26764. getBoundingInfo(): BoundingInfo;
  26765. /**
  26766. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26767. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26768. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26769. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26770. * @returns the current mesh
  26771. */
  26772. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26773. /**
  26774. * Overwrite the current bounding info
  26775. * @param boundingInfo defines the new bounding info
  26776. * @returns the current mesh
  26777. */
  26778. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26779. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26780. readonly useBones: boolean;
  26781. /** @hidden */
  26782. _preActivate(): void;
  26783. /** @hidden */
  26784. _preActivateForIntermediateRendering(renderId: number): void;
  26785. /** @hidden */
  26786. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26787. /** @hidden */
  26788. _postActivate(): void;
  26789. /** @hidden */
  26790. _freeze(): void;
  26791. /** @hidden */
  26792. _unFreeze(): void;
  26793. /**
  26794. * Gets the current world matrix
  26795. * @returns a Matrix
  26796. */
  26797. getWorldMatrix(): Matrix;
  26798. /** @hidden */
  26799. _getWorldMatrixDeterminant(): number;
  26800. /**
  26801. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26802. */
  26803. readonly isAnInstance: boolean;
  26804. /**
  26805. * Gets a boolean indicating if this mesh has instances
  26806. */
  26807. readonly hasInstances: boolean;
  26808. /**
  26809. * Perform relative position change from the point of view of behind the front of the mesh.
  26810. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26811. * Supports definition of mesh facing forward or backward
  26812. * @param amountRight defines the distance on the right axis
  26813. * @param amountUp defines the distance on the up axis
  26814. * @param amountForward defines the distance on the forward axis
  26815. * @returns the current mesh
  26816. */
  26817. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26818. /**
  26819. * Calculate relative position change from the point of view of behind the front of the mesh.
  26820. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26821. * Supports definition of mesh facing forward or backward
  26822. * @param amountRight defines the distance on the right axis
  26823. * @param amountUp defines the distance on the up axis
  26824. * @param amountForward defines the distance on the forward axis
  26825. * @returns the new displacement vector
  26826. */
  26827. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26828. /**
  26829. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26830. * Supports definition of mesh facing forward or backward
  26831. * @param flipBack defines the flip
  26832. * @param twirlClockwise defines the twirl
  26833. * @param tiltRight defines the tilt
  26834. * @returns the current mesh
  26835. */
  26836. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26837. /**
  26838. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26839. * Supports definition of mesh facing forward or backward.
  26840. * @param flipBack defines the flip
  26841. * @param twirlClockwise defines the twirl
  26842. * @param tiltRight defines the tilt
  26843. * @returns the new rotation vector
  26844. */
  26845. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26846. /**
  26847. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26848. * This means the mesh underlying bounding box and sphere are recomputed.
  26849. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26850. * @returns the current mesh
  26851. */
  26852. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26853. /** @hidden */
  26854. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26855. /** @hidden */
  26856. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26857. /** @hidden */
  26858. _updateBoundingInfo(): AbstractMesh;
  26859. /** @hidden */
  26860. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26861. /** @hidden */
  26862. protected _afterComputeWorldMatrix(): void;
  26863. /** @hidden */
  26864. readonly _effectiveMesh: AbstractMesh;
  26865. /**
  26866. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26867. * A mesh is in the frustum if its bounding box intersects the frustum
  26868. * @param frustumPlanes defines the frustum to test
  26869. * @returns true if the mesh is in the frustum planes
  26870. */
  26871. isInFrustum(frustumPlanes: Plane[]): boolean;
  26872. /**
  26873. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26874. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26875. * @param frustumPlanes defines the frustum to test
  26876. * @returns true if the mesh is completely in the frustum planes
  26877. */
  26878. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26879. /**
  26880. * True if the mesh intersects another mesh or a SolidParticle object
  26881. * @param mesh defines a target mesh or SolidParticle to test
  26882. * @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)
  26883. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26884. * @returns true if there is an intersection
  26885. */
  26886. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26887. /**
  26888. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26889. * @param point defines the point to test
  26890. * @returns true if there is an intersection
  26891. */
  26892. intersectsPoint(point: Vector3): boolean;
  26893. /**
  26894. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26895. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26896. */
  26897. checkCollisions: boolean;
  26898. /**
  26899. * Gets Collider object used to compute collisions (not physics)
  26900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26901. */
  26902. readonly collider: Nullable<Collider>;
  26903. /**
  26904. * Move the mesh using collision engine
  26905. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26906. * @param displacement defines the requested displacement vector
  26907. * @returns the current mesh
  26908. */
  26909. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26910. private _onCollisionPositionChange;
  26911. /** @hidden */
  26912. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26913. /** @hidden */
  26914. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26915. /** @hidden */
  26916. _checkCollision(collider: Collider): AbstractMesh;
  26917. /** @hidden */
  26918. _generatePointsArray(): boolean;
  26919. /**
  26920. * Checks if the passed Ray intersects with the mesh
  26921. * @param ray defines the ray to use
  26922. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26923. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26924. * @returns the picking info
  26925. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26926. */
  26927. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26928. /**
  26929. * Clones the current mesh
  26930. * @param name defines the mesh name
  26931. * @param newParent defines the new mesh parent
  26932. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26933. * @returns the new mesh
  26934. */
  26935. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26936. /**
  26937. * Disposes all the submeshes of the current meshnp
  26938. * @returns the current mesh
  26939. */
  26940. releaseSubMeshes(): AbstractMesh;
  26941. /**
  26942. * Releases resources associated with this abstract mesh.
  26943. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26944. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26945. */
  26946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26947. /**
  26948. * Adds the passed mesh as a child to the current mesh
  26949. * @param mesh defines the child mesh
  26950. * @returns the current mesh
  26951. */
  26952. addChild(mesh: AbstractMesh): AbstractMesh;
  26953. /**
  26954. * Removes the passed mesh from the current mesh children list
  26955. * @param mesh defines the child mesh
  26956. * @returns the current mesh
  26957. */
  26958. removeChild(mesh: AbstractMesh): AbstractMesh;
  26959. /** @hidden */
  26960. private _initFacetData;
  26961. /**
  26962. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26963. * This method can be called within the render loop.
  26964. * 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
  26965. * @returns the current mesh
  26966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26967. */
  26968. updateFacetData(): AbstractMesh;
  26969. /**
  26970. * Returns the facetLocalNormals array.
  26971. * The normals are expressed in the mesh local spac
  26972. * @returns an array of Vector3
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26974. */
  26975. getFacetLocalNormals(): Vector3[];
  26976. /**
  26977. * Returns the facetLocalPositions array.
  26978. * The facet positions are expressed in the mesh local space
  26979. * @returns an array of Vector3
  26980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26981. */
  26982. getFacetLocalPositions(): Vector3[];
  26983. /**
  26984. * Returns the facetLocalPartioning array
  26985. * @returns an array of array of numbers
  26986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26987. */
  26988. getFacetLocalPartitioning(): number[][];
  26989. /**
  26990. * Returns the i-th facet position in the world system.
  26991. * This method allocates a new Vector3 per call
  26992. * @param i defines the facet index
  26993. * @returns a new Vector3
  26994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26995. */
  26996. getFacetPosition(i: number): Vector3;
  26997. /**
  26998. * Sets the reference Vector3 with the i-th facet position in the world system
  26999. * @param i defines the facet index
  27000. * @param ref defines the target vector
  27001. * @returns the current mesh
  27002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27003. */
  27004. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27005. /**
  27006. * Returns the i-th facet normal in the world system.
  27007. * This method allocates a new Vector3 per call
  27008. * @param i defines the facet index
  27009. * @returns a new Vector3
  27010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27011. */
  27012. getFacetNormal(i: number): Vector3;
  27013. /**
  27014. * Sets the reference Vector3 with the i-th facet normal in the world system
  27015. * @param i defines the facet index
  27016. * @param ref defines the target vector
  27017. * @returns the current mesh
  27018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27019. */
  27020. getFacetNormalToRef(i: number, ref: Vector3): this;
  27021. /**
  27022. * 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)
  27023. * @param x defines x coordinate
  27024. * @param y defines y coordinate
  27025. * @param z defines z coordinate
  27026. * @returns the array of facet indexes
  27027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27028. */
  27029. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27030. /**
  27031. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27032. * @param projected sets as the (x,y,z) world projection on the facet
  27033. * @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
  27034. * @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
  27035. * @param x defines x coordinate
  27036. * @param y defines y coordinate
  27037. * @param z defines z coordinate
  27038. * @returns the face index if found (or null instead)
  27039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27040. */
  27041. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27042. /**
  27043. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27044. * @param projected sets as the (x,y,z) local projection on the facet
  27045. * @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
  27046. * @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
  27047. * @param x defines x coordinate
  27048. * @param y defines y coordinate
  27049. * @param z defines z coordinate
  27050. * @returns the face index if found (or null instead)
  27051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27052. */
  27053. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27054. /**
  27055. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27056. * @returns the parameters
  27057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27058. */
  27059. getFacetDataParameters(): any;
  27060. /**
  27061. * Disables the feature FacetData and frees the related memory
  27062. * @returns the current mesh
  27063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27064. */
  27065. disableFacetData(): AbstractMesh;
  27066. /**
  27067. * Updates the AbstractMesh indices array
  27068. * @param indices defines the data source
  27069. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27070. * @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)
  27071. * @returns the current mesh
  27072. */
  27073. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27074. /**
  27075. * Creates new normals data for the mesh
  27076. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27077. * @returns the current mesh
  27078. */
  27079. createNormals(updatable: boolean): AbstractMesh;
  27080. /**
  27081. * Align the mesh with a normal
  27082. * @param normal defines the normal to use
  27083. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27084. * @returns the current mesh
  27085. */
  27086. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27087. /** @hidden */
  27088. _checkOcclusionQuery(): boolean;
  27089. /**
  27090. * Disables the mesh edge rendering mode
  27091. * @returns the currentAbstractMesh
  27092. */
  27093. disableEdgesRendering(): AbstractMesh;
  27094. /**
  27095. * Enables the edge rendering mode on the mesh.
  27096. * This mode makes the mesh edges visible
  27097. * @param epsilon defines the maximal distance between two angles to detect a face
  27098. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27099. * @returns the currentAbstractMesh
  27100. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27101. */
  27102. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27103. }
  27104. }
  27105. declare module "babylonjs/Actions/actionEvent" {
  27106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27107. import { Nullable } from "babylonjs/types";
  27108. import { Sprite } from "babylonjs/Sprites/sprite";
  27109. import { Scene } from "babylonjs/scene";
  27110. import { Vector2 } from "babylonjs/Maths/math.vector";
  27111. /**
  27112. * Interface used to define ActionEvent
  27113. */
  27114. export interface IActionEvent {
  27115. /** The mesh or sprite that triggered the action */
  27116. source: any;
  27117. /** The X mouse cursor position at the time of the event */
  27118. pointerX: number;
  27119. /** The Y mouse cursor position at the time of the event */
  27120. pointerY: number;
  27121. /** The mesh that is currently pointed at (can be null) */
  27122. meshUnderPointer: Nullable<AbstractMesh>;
  27123. /** the original (browser) event that triggered the ActionEvent */
  27124. sourceEvent?: any;
  27125. /** additional data for the event */
  27126. additionalData?: any;
  27127. }
  27128. /**
  27129. * ActionEvent is the event being sent when an action is triggered.
  27130. */
  27131. export class ActionEvent implements IActionEvent {
  27132. /** The mesh or sprite that triggered the action */
  27133. source: any;
  27134. /** The X mouse cursor position at the time of the event */
  27135. pointerX: number;
  27136. /** The Y mouse cursor position at the time of the event */
  27137. pointerY: number;
  27138. /** The mesh that is currently pointed at (can be null) */
  27139. meshUnderPointer: Nullable<AbstractMesh>;
  27140. /** the original (browser) event that triggered the ActionEvent */
  27141. sourceEvent?: any;
  27142. /** additional data for the event */
  27143. additionalData?: any;
  27144. /**
  27145. * Creates a new ActionEvent
  27146. * @param source The mesh or sprite that triggered the action
  27147. * @param pointerX The X mouse cursor position at the time of the event
  27148. * @param pointerY The Y mouse cursor position at the time of the event
  27149. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27150. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27151. * @param additionalData additional data for the event
  27152. */
  27153. constructor(
  27154. /** The mesh or sprite that triggered the action */
  27155. source: any,
  27156. /** The X mouse cursor position at the time of the event */
  27157. pointerX: number,
  27158. /** The Y mouse cursor position at the time of the event */
  27159. pointerY: number,
  27160. /** The mesh that is currently pointed at (can be null) */
  27161. meshUnderPointer: Nullable<AbstractMesh>,
  27162. /** the original (browser) event that triggered the ActionEvent */
  27163. sourceEvent?: any,
  27164. /** additional data for the event */
  27165. additionalData?: any);
  27166. /**
  27167. * Helper function to auto-create an ActionEvent from a source mesh.
  27168. * @param source The source mesh that triggered the event
  27169. * @param evt The original (browser) event
  27170. * @param additionalData additional data for the event
  27171. * @returns the new ActionEvent
  27172. */
  27173. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27174. /**
  27175. * Helper function to auto-create an ActionEvent from a source sprite
  27176. * @param source The source sprite that triggered the event
  27177. * @param scene Scene associated with the sprite
  27178. * @param evt The original (browser) event
  27179. * @param additionalData additional data for the event
  27180. * @returns the new ActionEvent
  27181. */
  27182. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27183. /**
  27184. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27185. * @param scene the scene where the event occurred
  27186. * @param evt The original (browser) event
  27187. * @returns the new ActionEvent
  27188. */
  27189. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27190. /**
  27191. * Helper function to auto-create an ActionEvent from a primitive
  27192. * @param prim defines the target primitive
  27193. * @param pointerPos defines the pointer position
  27194. * @param evt The original (browser) event
  27195. * @param additionalData additional data for the event
  27196. * @returns the new ActionEvent
  27197. */
  27198. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27199. }
  27200. }
  27201. declare module "babylonjs/Actions/abstractActionManager" {
  27202. import { IDisposable } from "babylonjs/scene";
  27203. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27204. import { IAction } from "babylonjs/Actions/action";
  27205. import { Nullable } from "babylonjs/types";
  27206. /**
  27207. * Abstract class used to decouple action Manager from scene and meshes.
  27208. * Do not instantiate.
  27209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27210. */
  27211. export abstract class AbstractActionManager implements IDisposable {
  27212. /** Gets the list of active triggers */
  27213. static Triggers: {
  27214. [key: string]: number;
  27215. };
  27216. /** Gets the cursor to use when hovering items */
  27217. hoverCursor: string;
  27218. /** Gets the list of actions */
  27219. actions: IAction[];
  27220. /**
  27221. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27222. */
  27223. isRecursive: boolean;
  27224. /**
  27225. * Releases all associated resources
  27226. */
  27227. abstract dispose(): void;
  27228. /**
  27229. * Does this action manager has pointer triggers
  27230. */
  27231. abstract readonly hasPointerTriggers: boolean;
  27232. /**
  27233. * Does this action manager has pick triggers
  27234. */
  27235. abstract readonly hasPickTriggers: boolean;
  27236. /**
  27237. * Process a specific trigger
  27238. * @param trigger defines the trigger to process
  27239. * @param evt defines the event details to be processed
  27240. */
  27241. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27242. /**
  27243. * Does this action manager handles actions of any of the given triggers
  27244. * @param triggers defines the triggers to be tested
  27245. * @return a boolean indicating whether one (or more) of the triggers is handled
  27246. */
  27247. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27248. /**
  27249. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27250. * speed.
  27251. * @param triggerA defines the trigger to be tested
  27252. * @param triggerB defines the trigger to be tested
  27253. * @return a boolean indicating whether one (or more) of the triggers is handled
  27254. */
  27255. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27256. /**
  27257. * Does this action manager handles actions of a given trigger
  27258. * @param trigger defines the trigger to be tested
  27259. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27260. * @return whether the trigger is handled
  27261. */
  27262. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27263. /**
  27264. * Serialize this manager to a JSON object
  27265. * @param name defines the property name to store this manager
  27266. * @returns a JSON representation of this manager
  27267. */
  27268. abstract serialize(name: string): any;
  27269. /**
  27270. * Registers an action to this action manager
  27271. * @param action defines the action to be registered
  27272. * @return the action amended (prepared) after registration
  27273. */
  27274. abstract registerAction(action: IAction): Nullable<IAction>;
  27275. /**
  27276. * Unregisters an action to this action manager
  27277. * @param action defines the action to be unregistered
  27278. * @return a boolean indicating whether the action has been unregistered
  27279. */
  27280. abstract unregisterAction(action: IAction): Boolean;
  27281. /**
  27282. * Does exist one action manager with at least one trigger
  27283. **/
  27284. static readonly HasTriggers: boolean;
  27285. /**
  27286. * Does exist one action manager with at least one pick trigger
  27287. **/
  27288. static readonly HasPickTriggers: boolean;
  27289. /**
  27290. * Does exist one action manager that handles actions of a given trigger
  27291. * @param trigger defines the trigger to be tested
  27292. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27293. **/
  27294. static HasSpecificTrigger(trigger: number): boolean;
  27295. }
  27296. }
  27297. declare module "babylonjs/node" {
  27298. import { Scene } from "babylonjs/scene";
  27299. import { Nullable } from "babylonjs/types";
  27300. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27301. import { Engine } from "babylonjs/Engines/engine";
  27302. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27303. import { Observable } from "babylonjs/Misc/observable";
  27304. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27305. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27306. import { Animatable } from "babylonjs/Animations/animatable";
  27307. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27308. import { Animation } from "babylonjs/Animations/animation";
  27309. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27311. /**
  27312. * Defines how a node can be built from a string name.
  27313. */
  27314. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27315. /**
  27316. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27317. */
  27318. export class Node implements IBehaviorAware<Node> {
  27319. /** @hidden */
  27320. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27321. private static _NodeConstructors;
  27322. /**
  27323. * Add a new node constructor
  27324. * @param type defines the type name of the node to construct
  27325. * @param constructorFunc defines the constructor function
  27326. */
  27327. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27328. /**
  27329. * Returns a node constructor based on type name
  27330. * @param type defines the type name
  27331. * @param name defines the new node name
  27332. * @param scene defines the hosting scene
  27333. * @param options defines optional options to transmit to constructors
  27334. * @returns the new constructor or null
  27335. */
  27336. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27337. /**
  27338. * Gets or sets the name of the node
  27339. */
  27340. name: string;
  27341. /**
  27342. * Gets or sets the id of the node
  27343. */
  27344. id: string;
  27345. /**
  27346. * Gets or sets the unique id of the node
  27347. */
  27348. uniqueId: number;
  27349. /**
  27350. * Gets or sets a string used to store user defined state for the node
  27351. */
  27352. state: string;
  27353. /**
  27354. * Gets or sets an object used to store user defined information for the node
  27355. */
  27356. metadata: any;
  27357. /**
  27358. * For internal use only. Please do not use.
  27359. */
  27360. reservedDataStore: any;
  27361. /**
  27362. * List of inspectable custom properties (used by the Inspector)
  27363. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27364. */
  27365. inspectableCustomProperties: IInspectable[];
  27366. /**
  27367. * Gets or sets a boolean used to define if the node must be serialized
  27368. */
  27369. doNotSerialize: boolean;
  27370. /** @hidden */
  27371. _isDisposed: boolean;
  27372. /**
  27373. * Gets a list of Animations associated with the node
  27374. */
  27375. animations: import("babylonjs/Animations/animation").Animation[];
  27376. protected _ranges: {
  27377. [name: string]: Nullable<AnimationRange>;
  27378. };
  27379. /**
  27380. * Callback raised when the node is ready to be used
  27381. */
  27382. onReady: Nullable<(node: Node) => void>;
  27383. private _isEnabled;
  27384. private _isParentEnabled;
  27385. private _isReady;
  27386. /** @hidden */
  27387. _currentRenderId: number;
  27388. private _parentUpdateId;
  27389. /** @hidden */
  27390. _childUpdateId: number;
  27391. /** @hidden */
  27392. _waitingParentId: Nullable<string>;
  27393. /** @hidden */
  27394. _scene: Scene;
  27395. /** @hidden */
  27396. _cache: any;
  27397. private _parentNode;
  27398. private _children;
  27399. /** @hidden */
  27400. _worldMatrix: Matrix;
  27401. /** @hidden */
  27402. _worldMatrixDeterminant: number;
  27403. /** @hidden */
  27404. _worldMatrixDeterminantIsDirty: boolean;
  27405. /** @hidden */
  27406. private _sceneRootNodesIndex;
  27407. /**
  27408. * Gets a boolean indicating if the node has been disposed
  27409. * @returns true if the node was disposed
  27410. */
  27411. isDisposed(): boolean;
  27412. /**
  27413. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27414. * @see https://doc.babylonjs.com/how_to/parenting
  27415. */
  27416. parent: Nullable<Node>;
  27417. private addToSceneRootNodes;
  27418. private removeFromSceneRootNodes;
  27419. private _animationPropertiesOverride;
  27420. /**
  27421. * Gets or sets the animation properties override
  27422. */
  27423. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27424. /**
  27425. * Gets a string idenfifying the name of the class
  27426. * @returns "Node" string
  27427. */
  27428. getClassName(): string;
  27429. /** @hidden */
  27430. readonly _isNode: boolean;
  27431. /**
  27432. * An event triggered when the mesh is disposed
  27433. */
  27434. onDisposeObservable: Observable<Node>;
  27435. private _onDisposeObserver;
  27436. /**
  27437. * Sets a callback that will be raised when the node will be disposed
  27438. */
  27439. onDispose: () => void;
  27440. /**
  27441. * Creates a new Node
  27442. * @param name the name and id to be given to this node
  27443. * @param scene the scene this node will be added to
  27444. * @param addToRootNodes the node will be added to scene.rootNodes
  27445. */
  27446. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27447. /**
  27448. * Gets the scene of the node
  27449. * @returns a scene
  27450. */
  27451. getScene(): Scene;
  27452. /**
  27453. * Gets the engine of the node
  27454. * @returns a Engine
  27455. */
  27456. getEngine(): Engine;
  27457. private _behaviors;
  27458. /**
  27459. * Attach a behavior to the node
  27460. * @see http://doc.babylonjs.com/features/behaviour
  27461. * @param behavior defines the behavior to attach
  27462. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27463. * @returns the current Node
  27464. */
  27465. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27466. /**
  27467. * Remove an attached behavior
  27468. * @see http://doc.babylonjs.com/features/behaviour
  27469. * @param behavior defines the behavior to attach
  27470. * @returns the current Node
  27471. */
  27472. removeBehavior(behavior: Behavior<Node>): Node;
  27473. /**
  27474. * Gets the list of attached behaviors
  27475. * @see http://doc.babylonjs.com/features/behaviour
  27476. */
  27477. readonly behaviors: Behavior<Node>[];
  27478. /**
  27479. * Gets an attached behavior by name
  27480. * @param name defines the name of the behavior to look for
  27481. * @see http://doc.babylonjs.com/features/behaviour
  27482. * @returns null if behavior was not found else the requested behavior
  27483. */
  27484. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27485. /**
  27486. * Returns the latest update of the World matrix
  27487. * @returns a Matrix
  27488. */
  27489. getWorldMatrix(): Matrix;
  27490. /** @hidden */
  27491. _getWorldMatrixDeterminant(): number;
  27492. /**
  27493. * Returns directly the latest state of the mesh World matrix.
  27494. * A Matrix is returned.
  27495. */
  27496. readonly worldMatrixFromCache: Matrix;
  27497. /** @hidden */
  27498. _initCache(): void;
  27499. /** @hidden */
  27500. updateCache(force?: boolean): void;
  27501. /** @hidden */
  27502. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27503. /** @hidden */
  27504. _updateCache(ignoreParentClass?: boolean): void;
  27505. /** @hidden */
  27506. _isSynchronized(): boolean;
  27507. /** @hidden */
  27508. _markSyncedWithParent(): void;
  27509. /** @hidden */
  27510. isSynchronizedWithParent(): boolean;
  27511. /** @hidden */
  27512. isSynchronized(): boolean;
  27513. /**
  27514. * Is this node ready to be used/rendered
  27515. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27516. * @return true if the node is ready
  27517. */
  27518. isReady(completeCheck?: boolean): boolean;
  27519. /**
  27520. * Is this node enabled?
  27521. * 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
  27522. * @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
  27523. * @return whether this node (and its parent) is enabled
  27524. */
  27525. isEnabled(checkAncestors?: boolean): boolean;
  27526. /** @hidden */
  27527. protected _syncParentEnabledState(): void;
  27528. /**
  27529. * Set the enabled state of this node
  27530. * @param value defines the new enabled state
  27531. */
  27532. setEnabled(value: boolean): void;
  27533. /**
  27534. * Is this node a descendant of the given node?
  27535. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27536. * @param ancestor defines the parent node to inspect
  27537. * @returns a boolean indicating if this node is a descendant of the given node
  27538. */
  27539. isDescendantOf(ancestor: Node): boolean;
  27540. /** @hidden */
  27541. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27542. /**
  27543. * Will return all nodes that have this node as ascendant
  27544. * @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
  27545. * @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
  27546. * @return all children nodes of all types
  27547. */
  27548. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27549. /**
  27550. * Get all child-meshes of this node
  27551. * @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)
  27552. * @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
  27553. * @returns an array of AbstractMesh
  27554. */
  27555. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27556. /**
  27557. * Get all direct children of this node
  27558. * @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
  27559. * @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)
  27560. * @returns an array of Node
  27561. */
  27562. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27563. /** @hidden */
  27564. _setReady(state: boolean): void;
  27565. /**
  27566. * Get an animation by name
  27567. * @param name defines the name of the animation to look for
  27568. * @returns null if not found else the requested animation
  27569. */
  27570. getAnimationByName(name: string): Nullable<Animation>;
  27571. /**
  27572. * Creates an animation range for this node
  27573. * @param name defines the name of the range
  27574. * @param from defines the starting key
  27575. * @param to defines the end key
  27576. */
  27577. createAnimationRange(name: string, from: number, to: number): void;
  27578. /**
  27579. * Delete a specific animation range
  27580. * @param name defines the name of the range to delete
  27581. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27582. */
  27583. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27584. /**
  27585. * Get an animation range by name
  27586. * @param name defines the name of the animation range to look for
  27587. * @returns null if not found else the requested animation range
  27588. */
  27589. getAnimationRange(name: string): Nullable<AnimationRange>;
  27590. /**
  27591. * Gets the list of all animation ranges defined on this node
  27592. * @returns an array
  27593. */
  27594. getAnimationRanges(): Nullable<AnimationRange>[];
  27595. /**
  27596. * Will start the animation sequence
  27597. * @param name defines the range frames for animation sequence
  27598. * @param loop defines if the animation should loop (false by default)
  27599. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27600. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27601. * @returns the object created for this animation. If range does not exist, it will return null
  27602. */
  27603. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27604. /**
  27605. * Serialize animation ranges into a JSON compatible object
  27606. * @returns serialization object
  27607. */
  27608. serializeAnimationRanges(): any;
  27609. /**
  27610. * Computes the world matrix of the node
  27611. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27612. * @returns the world matrix
  27613. */
  27614. computeWorldMatrix(force?: boolean): Matrix;
  27615. /**
  27616. * Releases resources associated with this node.
  27617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27619. */
  27620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27621. /**
  27622. * Parse animation range data from a serialization object and store them into a given node
  27623. * @param node defines where to store the animation ranges
  27624. * @param parsedNode defines the serialization object to read data from
  27625. * @param scene defines the hosting scene
  27626. */
  27627. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27628. /**
  27629. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27630. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27631. * @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
  27632. * @returns the new bounding vectors
  27633. */
  27634. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27635. min: Vector3;
  27636. max: Vector3;
  27637. };
  27638. }
  27639. }
  27640. declare module "babylonjs/Animations/animation" {
  27641. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27642. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27643. import { Color3 } from "babylonjs/Maths/math.color";
  27644. import { Nullable } from "babylonjs/types";
  27645. import { Scene } from "babylonjs/scene";
  27646. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27647. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27648. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27649. import { Node } from "babylonjs/node";
  27650. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27651. import { Size } from "babylonjs/Maths/math.size";
  27652. import { Animatable } from "babylonjs/Animations/animatable";
  27653. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27654. /**
  27655. * @hidden
  27656. */
  27657. export class _IAnimationState {
  27658. key: number;
  27659. repeatCount: number;
  27660. workValue?: any;
  27661. loopMode?: number;
  27662. offsetValue?: any;
  27663. highLimitValue?: any;
  27664. }
  27665. /**
  27666. * Class used to store any kind of animation
  27667. */
  27668. export class Animation {
  27669. /**Name of the animation */
  27670. name: string;
  27671. /**Property to animate */
  27672. targetProperty: string;
  27673. /**The frames per second of the animation */
  27674. framePerSecond: number;
  27675. /**The data type of the animation */
  27676. dataType: number;
  27677. /**The loop mode of the animation */
  27678. loopMode?: number | undefined;
  27679. /**Specifies if blending should be enabled */
  27680. enableBlending?: boolean | undefined;
  27681. /**
  27682. * Use matrix interpolation instead of using direct key value when animating matrices
  27683. */
  27684. static AllowMatricesInterpolation: boolean;
  27685. /**
  27686. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27687. */
  27688. static AllowMatrixDecomposeForInterpolation: boolean;
  27689. /**
  27690. * Stores the key frames of the animation
  27691. */
  27692. private _keys;
  27693. /**
  27694. * Stores the easing function of the animation
  27695. */
  27696. private _easingFunction;
  27697. /**
  27698. * @hidden Internal use only
  27699. */
  27700. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27701. /**
  27702. * The set of event that will be linked to this animation
  27703. */
  27704. private _events;
  27705. /**
  27706. * Stores an array of target property paths
  27707. */
  27708. targetPropertyPath: string[];
  27709. /**
  27710. * Stores the blending speed of the animation
  27711. */
  27712. blendingSpeed: number;
  27713. /**
  27714. * Stores the animation ranges for the animation
  27715. */
  27716. private _ranges;
  27717. /**
  27718. * @hidden Internal use
  27719. */
  27720. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27721. /**
  27722. * Sets up an animation
  27723. * @param property The property to animate
  27724. * @param animationType The animation type to apply
  27725. * @param framePerSecond The frames per second of the animation
  27726. * @param easingFunction The easing function used in the animation
  27727. * @returns The created animation
  27728. */
  27729. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27730. /**
  27731. * Create and start an animation on a node
  27732. * @param name defines the name of the global animation that will be run on all nodes
  27733. * @param node defines the root node where the animation will take place
  27734. * @param targetProperty defines property to animate
  27735. * @param framePerSecond defines the number of frame per second yo use
  27736. * @param totalFrame defines the number of frames in total
  27737. * @param from defines the initial value
  27738. * @param to defines the final value
  27739. * @param loopMode defines which loop mode you want to use (off by default)
  27740. * @param easingFunction defines the easing function to use (linear by default)
  27741. * @param onAnimationEnd defines the callback to call when animation end
  27742. * @returns the animatable created for this animation
  27743. */
  27744. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27745. /**
  27746. * Create and start an animation on a node and its descendants
  27747. * @param name defines the name of the global animation that will be run on all nodes
  27748. * @param node defines the root node where the animation will take place
  27749. * @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
  27750. * @param targetProperty defines property to animate
  27751. * @param framePerSecond defines the number of frame per second to use
  27752. * @param totalFrame defines the number of frames in total
  27753. * @param from defines the initial value
  27754. * @param to defines the final value
  27755. * @param loopMode defines which loop mode you want to use (off by default)
  27756. * @param easingFunction defines the easing function to use (linear by default)
  27757. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27758. * @returns the list of animatables created for all nodes
  27759. * @example https://www.babylonjs-playground.com/#MH0VLI
  27760. */
  27761. 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[]>;
  27762. /**
  27763. * Creates a new animation, merges it with the existing animations and starts it
  27764. * @param name Name of the animation
  27765. * @param node Node which contains the scene that begins the animations
  27766. * @param targetProperty Specifies which property to animate
  27767. * @param framePerSecond The frames per second of the animation
  27768. * @param totalFrame The total number of frames
  27769. * @param from The frame at the beginning of the animation
  27770. * @param to The frame at the end of the animation
  27771. * @param loopMode Specifies the loop mode of the animation
  27772. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27773. * @param onAnimationEnd Callback to run once the animation is complete
  27774. * @returns Nullable animation
  27775. */
  27776. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27777. /**
  27778. * Transition property of an host to the target Value
  27779. * @param property The property to transition
  27780. * @param targetValue The target Value of the property
  27781. * @param host The object where the property to animate belongs
  27782. * @param scene Scene used to run the animation
  27783. * @param frameRate Framerate (in frame/s) to use
  27784. * @param transition The transition type we want to use
  27785. * @param duration The duration of the animation, in milliseconds
  27786. * @param onAnimationEnd Callback trigger at the end of the animation
  27787. * @returns Nullable animation
  27788. */
  27789. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27790. /**
  27791. * Return the array of runtime animations currently using this animation
  27792. */
  27793. readonly runtimeAnimations: RuntimeAnimation[];
  27794. /**
  27795. * Specifies if any of the runtime animations are currently running
  27796. */
  27797. readonly hasRunningRuntimeAnimations: boolean;
  27798. /**
  27799. * Initializes the animation
  27800. * @param name Name of the animation
  27801. * @param targetProperty Property to animate
  27802. * @param framePerSecond The frames per second of the animation
  27803. * @param dataType The data type of the animation
  27804. * @param loopMode The loop mode of the animation
  27805. * @param enableBlending Specifies if blending should be enabled
  27806. */
  27807. constructor(
  27808. /**Name of the animation */
  27809. name: string,
  27810. /**Property to animate */
  27811. targetProperty: string,
  27812. /**The frames per second of the animation */
  27813. framePerSecond: number,
  27814. /**The data type of the animation */
  27815. dataType: number,
  27816. /**The loop mode of the animation */
  27817. loopMode?: number | undefined,
  27818. /**Specifies if blending should be enabled */
  27819. enableBlending?: boolean | undefined);
  27820. /**
  27821. * Converts the animation to a string
  27822. * @param fullDetails support for multiple levels of logging within scene loading
  27823. * @returns String form of the animation
  27824. */
  27825. toString(fullDetails?: boolean): string;
  27826. /**
  27827. * Add an event to this animation
  27828. * @param event Event to add
  27829. */
  27830. addEvent(event: AnimationEvent): void;
  27831. /**
  27832. * Remove all events found at the given frame
  27833. * @param frame The frame to remove events from
  27834. */
  27835. removeEvents(frame: number): void;
  27836. /**
  27837. * Retrieves all the events from the animation
  27838. * @returns Events from the animation
  27839. */
  27840. getEvents(): AnimationEvent[];
  27841. /**
  27842. * Creates an animation range
  27843. * @param name Name of the animation range
  27844. * @param from Starting frame of the animation range
  27845. * @param to Ending frame of the animation
  27846. */
  27847. createRange(name: string, from: number, to: number): void;
  27848. /**
  27849. * Deletes an animation range by name
  27850. * @param name Name of the animation range to delete
  27851. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27852. */
  27853. deleteRange(name: string, deleteFrames?: boolean): void;
  27854. /**
  27855. * Gets the animation range by name, or null if not defined
  27856. * @param name Name of the animation range
  27857. * @returns Nullable animation range
  27858. */
  27859. getRange(name: string): Nullable<AnimationRange>;
  27860. /**
  27861. * Gets the key frames from the animation
  27862. * @returns The key frames of the animation
  27863. */
  27864. getKeys(): Array<IAnimationKey>;
  27865. /**
  27866. * Gets the highest frame rate of the animation
  27867. * @returns Highest frame rate of the animation
  27868. */
  27869. getHighestFrame(): number;
  27870. /**
  27871. * Gets the easing function of the animation
  27872. * @returns Easing function of the animation
  27873. */
  27874. getEasingFunction(): IEasingFunction;
  27875. /**
  27876. * Sets the easing function of the animation
  27877. * @param easingFunction A custom mathematical formula for animation
  27878. */
  27879. setEasingFunction(easingFunction: EasingFunction): void;
  27880. /**
  27881. * Interpolates a scalar linearly
  27882. * @param startValue Start value of the animation curve
  27883. * @param endValue End value of the animation curve
  27884. * @param gradient Scalar amount to interpolate
  27885. * @returns Interpolated scalar value
  27886. */
  27887. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27888. /**
  27889. * Interpolates a scalar cubically
  27890. * @param startValue Start value of the animation curve
  27891. * @param outTangent End tangent of the animation
  27892. * @param endValue End value of the animation curve
  27893. * @param inTangent Start tangent of the animation curve
  27894. * @param gradient Scalar amount to interpolate
  27895. * @returns Interpolated scalar value
  27896. */
  27897. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27898. /**
  27899. * Interpolates a quaternion using a spherical linear interpolation
  27900. * @param startValue Start value of the animation curve
  27901. * @param endValue End value of the animation curve
  27902. * @param gradient Scalar amount to interpolate
  27903. * @returns Interpolated quaternion value
  27904. */
  27905. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27906. /**
  27907. * Interpolates a quaternion cubically
  27908. * @param startValue Start value of the animation curve
  27909. * @param outTangent End tangent of the animation curve
  27910. * @param endValue End value of the animation curve
  27911. * @param inTangent Start tangent of the animation curve
  27912. * @param gradient Scalar amount to interpolate
  27913. * @returns Interpolated quaternion value
  27914. */
  27915. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27916. /**
  27917. * Interpolates a Vector3 linearl
  27918. * @param startValue Start value of the animation curve
  27919. * @param endValue End value of the animation curve
  27920. * @param gradient Scalar amount to interpolate
  27921. * @returns Interpolated scalar value
  27922. */
  27923. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27924. /**
  27925. * Interpolates a Vector3 cubically
  27926. * @param startValue Start value of the animation curve
  27927. * @param outTangent End tangent of the animation
  27928. * @param endValue End value of the animation curve
  27929. * @param inTangent Start tangent of the animation curve
  27930. * @param gradient Scalar amount to interpolate
  27931. * @returns InterpolatedVector3 value
  27932. */
  27933. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27934. /**
  27935. * Interpolates a Vector2 linearly
  27936. * @param startValue Start value of the animation curve
  27937. * @param endValue End value of the animation curve
  27938. * @param gradient Scalar amount to interpolate
  27939. * @returns Interpolated Vector2 value
  27940. */
  27941. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27942. /**
  27943. * Interpolates a Vector2 cubically
  27944. * @param startValue Start value of the animation curve
  27945. * @param outTangent End tangent of the animation
  27946. * @param endValue End value of the animation curve
  27947. * @param inTangent Start tangent of the animation curve
  27948. * @param gradient Scalar amount to interpolate
  27949. * @returns Interpolated Vector2 value
  27950. */
  27951. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27952. /**
  27953. * Interpolates a size linearly
  27954. * @param startValue Start value of the animation curve
  27955. * @param endValue End value of the animation curve
  27956. * @param gradient Scalar amount to interpolate
  27957. * @returns Interpolated Size value
  27958. */
  27959. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27960. /**
  27961. * Interpolates a Color3 linearly
  27962. * @param startValue Start value of the animation curve
  27963. * @param endValue End value of the animation curve
  27964. * @param gradient Scalar amount to interpolate
  27965. * @returns Interpolated Color3 value
  27966. */
  27967. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27968. /**
  27969. * @hidden Internal use only
  27970. */
  27971. _getKeyValue(value: any): any;
  27972. /**
  27973. * @hidden Internal use only
  27974. */
  27975. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27976. /**
  27977. * Defines the function to use to interpolate matrices
  27978. * @param startValue defines the start matrix
  27979. * @param endValue defines the end matrix
  27980. * @param gradient defines the gradient between both matrices
  27981. * @param result defines an optional target matrix where to store the interpolation
  27982. * @returns the interpolated matrix
  27983. */
  27984. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27985. /**
  27986. * Makes a copy of the animation
  27987. * @returns Cloned animation
  27988. */
  27989. clone(): Animation;
  27990. /**
  27991. * Sets the key frames of the animation
  27992. * @param values The animation key frames to set
  27993. */
  27994. setKeys(values: Array<IAnimationKey>): void;
  27995. /**
  27996. * Serializes the animation to an object
  27997. * @returns Serialized object
  27998. */
  27999. serialize(): any;
  28000. /**
  28001. * Float animation type
  28002. */
  28003. private static _ANIMATIONTYPE_FLOAT;
  28004. /**
  28005. * Vector3 animation type
  28006. */
  28007. private static _ANIMATIONTYPE_VECTOR3;
  28008. /**
  28009. * Quaternion animation type
  28010. */
  28011. private static _ANIMATIONTYPE_QUATERNION;
  28012. /**
  28013. * Matrix animation type
  28014. */
  28015. private static _ANIMATIONTYPE_MATRIX;
  28016. /**
  28017. * Color3 animation type
  28018. */
  28019. private static _ANIMATIONTYPE_COLOR3;
  28020. /**
  28021. * Vector2 animation type
  28022. */
  28023. private static _ANIMATIONTYPE_VECTOR2;
  28024. /**
  28025. * Size animation type
  28026. */
  28027. private static _ANIMATIONTYPE_SIZE;
  28028. /**
  28029. * Relative Loop Mode
  28030. */
  28031. private static _ANIMATIONLOOPMODE_RELATIVE;
  28032. /**
  28033. * Cycle Loop Mode
  28034. */
  28035. private static _ANIMATIONLOOPMODE_CYCLE;
  28036. /**
  28037. * Constant Loop Mode
  28038. */
  28039. private static _ANIMATIONLOOPMODE_CONSTANT;
  28040. /**
  28041. * Get the float animation type
  28042. */
  28043. static readonly ANIMATIONTYPE_FLOAT: number;
  28044. /**
  28045. * Get the Vector3 animation type
  28046. */
  28047. static readonly ANIMATIONTYPE_VECTOR3: number;
  28048. /**
  28049. * Get the Vector2 animation type
  28050. */
  28051. static readonly ANIMATIONTYPE_VECTOR2: number;
  28052. /**
  28053. * Get the Size animation type
  28054. */
  28055. static readonly ANIMATIONTYPE_SIZE: number;
  28056. /**
  28057. * Get the Quaternion animation type
  28058. */
  28059. static readonly ANIMATIONTYPE_QUATERNION: number;
  28060. /**
  28061. * Get the Matrix animation type
  28062. */
  28063. static readonly ANIMATIONTYPE_MATRIX: number;
  28064. /**
  28065. * Get the Color3 animation type
  28066. */
  28067. static readonly ANIMATIONTYPE_COLOR3: number;
  28068. /**
  28069. * Get the Relative Loop Mode
  28070. */
  28071. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28072. /**
  28073. * Get the Cycle Loop Mode
  28074. */
  28075. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28076. /**
  28077. * Get the Constant Loop Mode
  28078. */
  28079. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28080. /** @hidden */
  28081. static _UniversalLerp(left: any, right: any, amount: number): any;
  28082. /**
  28083. * Parses an animation object and creates an animation
  28084. * @param parsedAnimation Parsed animation object
  28085. * @returns Animation object
  28086. */
  28087. static Parse(parsedAnimation: any): Animation;
  28088. /**
  28089. * Appends the serialized animations from the source animations
  28090. * @param source Source containing the animations
  28091. * @param destination Target to store the animations
  28092. */
  28093. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28094. }
  28095. }
  28096. declare module "babylonjs/Animations/animatable.interface" {
  28097. import { Nullable } from "babylonjs/types";
  28098. import { Animation } from "babylonjs/Animations/animation";
  28099. /**
  28100. * Interface containing an array of animations
  28101. */
  28102. export interface IAnimatable {
  28103. /**
  28104. * Array of animations
  28105. */
  28106. animations: Nullable<Array<Animation>>;
  28107. }
  28108. }
  28109. declare module "babylonjs/Materials/fresnelParameters" {
  28110. import { Color3 } from "babylonjs/Maths/math.color";
  28111. /**
  28112. * This represents all the required information to add a fresnel effect on a material:
  28113. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28114. */
  28115. export class FresnelParameters {
  28116. private _isEnabled;
  28117. /**
  28118. * Define if the fresnel effect is enable or not.
  28119. */
  28120. isEnabled: boolean;
  28121. /**
  28122. * Define the color used on edges (grazing angle)
  28123. */
  28124. leftColor: Color3;
  28125. /**
  28126. * Define the color used on center
  28127. */
  28128. rightColor: Color3;
  28129. /**
  28130. * Define bias applied to computed fresnel term
  28131. */
  28132. bias: number;
  28133. /**
  28134. * Defined the power exponent applied to fresnel term
  28135. */
  28136. power: number;
  28137. /**
  28138. * Clones the current fresnel and its valuues
  28139. * @returns a clone fresnel configuration
  28140. */
  28141. clone(): FresnelParameters;
  28142. /**
  28143. * Serializes the current fresnel parameters to a JSON representation.
  28144. * @return the JSON serialization
  28145. */
  28146. serialize(): any;
  28147. /**
  28148. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28149. * @param parsedFresnelParameters Define the JSON representation
  28150. * @returns the parsed parameters
  28151. */
  28152. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28153. }
  28154. }
  28155. declare module "babylonjs/Misc/decorators" {
  28156. import { Nullable } from "babylonjs/types";
  28157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28158. import { Scene } from "babylonjs/scene";
  28159. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28160. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28161. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28162. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28163. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28164. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28165. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28166. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28167. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28168. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28169. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28170. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28171. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28172. /**
  28173. * Decorator used to define property that can be serialized as reference to a camera
  28174. * @param sourceName defines the name of the property to decorate
  28175. */
  28176. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28177. /**
  28178. * Class used to help serialization objects
  28179. */
  28180. export class SerializationHelper {
  28181. /** @hidden */
  28182. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28183. /** @hidden */
  28184. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28185. /** @hidden */
  28186. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28187. /** @hidden */
  28188. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28189. /**
  28190. * Appends the serialized animations from the source animations
  28191. * @param source Source containing the animations
  28192. * @param destination Target to store the animations
  28193. */
  28194. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28195. /**
  28196. * Static function used to serialized a specific entity
  28197. * @param entity defines the entity to serialize
  28198. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28199. * @returns a JSON compatible object representing the serialization of the entity
  28200. */
  28201. static Serialize<T>(entity: T, serializationObject?: any): any;
  28202. /**
  28203. * Creates a new entity from a serialization data object
  28204. * @param creationFunction defines a function used to instanciated the new entity
  28205. * @param source defines the source serialization data
  28206. * @param scene defines the hosting scene
  28207. * @param rootUrl defines the root url for resources
  28208. * @returns a new entity
  28209. */
  28210. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28211. /**
  28212. * Clones an object
  28213. * @param creationFunction defines the function used to instanciate the new object
  28214. * @param source defines the source object
  28215. * @returns the cloned object
  28216. */
  28217. static Clone<T>(creationFunction: () => T, source: T): T;
  28218. /**
  28219. * Instanciates a new object based on a source one (some data will be shared between both object)
  28220. * @param creationFunction defines the function used to instanciate the new object
  28221. * @param source defines the source object
  28222. * @returns the new object
  28223. */
  28224. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28225. }
  28226. }
  28227. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28228. import { Nullable } from "babylonjs/types";
  28229. /**
  28230. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28231. */
  28232. export interface CubeMapInfo {
  28233. /**
  28234. * The pixel array for the front face.
  28235. * This is stored in format, left to right, up to down format.
  28236. */
  28237. front: Nullable<ArrayBufferView>;
  28238. /**
  28239. * The pixel array for the back face.
  28240. * This is stored in format, left to right, up to down format.
  28241. */
  28242. back: Nullable<ArrayBufferView>;
  28243. /**
  28244. * The pixel array for the left face.
  28245. * This is stored in format, left to right, up to down format.
  28246. */
  28247. left: Nullable<ArrayBufferView>;
  28248. /**
  28249. * The pixel array for the right face.
  28250. * This is stored in format, left to right, up to down format.
  28251. */
  28252. right: Nullable<ArrayBufferView>;
  28253. /**
  28254. * The pixel array for the up face.
  28255. * This is stored in format, left to right, up to down format.
  28256. */
  28257. up: Nullable<ArrayBufferView>;
  28258. /**
  28259. * The pixel array for the down face.
  28260. * This is stored in format, left to right, up to down format.
  28261. */
  28262. down: Nullable<ArrayBufferView>;
  28263. /**
  28264. * The size of the cubemap stored.
  28265. *
  28266. * Each faces will be size * size pixels.
  28267. */
  28268. size: number;
  28269. /**
  28270. * The format of the texture.
  28271. *
  28272. * RGBA, RGB.
  28273. */
  28274. format: number;
  28275. /**
  28276. * The type of the texture data.
  28277. *
  28278. * UNSIGNED_INT, FLOAT.
  28279. */
  28280. type: number;
  28281. /**
  28282. * Specifies whether the texture is in gamma space.
  28283. */
  28284. gammaSpace: boolean;
  28285. }
  28286. /**
  28287. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28288. */
  28289. export class PanoramaToCubeMapTools {
  28290. private static FACE_FRONT;
  28291. private static FACE_BACK;
  28292. private static FACE_RIGHT;
  28293. private static FACE_LEFT;
  28294. private static FACE_DOWN;
  28295. private static FACE_UP;
  28296. /**
  28297. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28298. *
  28299. * @param float32Array The source data.
  28300. * @param inputWidth The width of the input panorama.
  28301. * @param inputHeight The height of the input panorama.
  28302. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28303. * @return The cubemap data
  28304. */
  28305. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28306. private static CreateCubemapTexture;
  28307. private static CalcProjectionSpherical;
  28308. }
  28309. }
  28310. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28311. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28313. import { Nullable } from "babylonjs/types";
  28314. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28315. /**
  28316. * Helper class dealing with the extraction of spherical polynomial dataArray
  28317. * from a cube map.
  28318. */
  28319. export class CubeMapToSphericalPolynomialTools {
  28320. private static FileFaces;
  28321. /**
  28322. * Converts a texture to the according Spherical Polynomial data.
  28323. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28324. *
  28325. * @param texture The texture to extract the information from.
  28326. * @return The Spherical Polynomial data.
  28327. */
  28328. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28329. /**
  28330. * Converts a cubemap to the according Spherical Polynomial data.
  28331. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28332. *
  28333. * @param cubeInfo The Cube map to extract the information from.
  28334. * @return The Spherical Polynomial data.
  28335. */
  28336. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28337. }
  28338. }
  28339. declare module "babylonjs/Misc/guid" {
  28340. /**
  28341. * Class used to manipulate GUIDs
  28342. */
  28343. export class GUID {
  28344. /**
  28345. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28346. * Be aware Math.random() could cause collisions, but:
  28347. * "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"
  28348. * @returns a pseudo random id
  28349. */
  28350. static RandomId(): string;
  28351. }
  28352. }
  28353. declare module "babylonjs/Materials/Textures/baseTexture" {
  28354. import { Observable } from "babylonjs/Misc/observable";
  28355. import { Nullable } from "babylonjs/types";
  28356. import { Scene } from "babylonjs/scene";
  28357. import { Matrix } from "babylonjs/Maths/math.vector";
  28358. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28359. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28360. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28361. import { ISize } from "babylonjs/Maths/math.size";
  28362. /**
  28363. * Base class of all the textures in babylon.
  28364. * It groups all the common properties the materials, post process, lights... might need
  28365. * in order to make a correct use of the texture.
  28366. */
  28367. export class BaseTexture implements IAnimatable {
  28368. /**
  28369. * Default anisotropic filtering level for the application.
  28370. * It is set to 4 as a good tradeoff between perf and quality.
  28371. */
  28372. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28373. /**
  28374. * Gets or sets the unique id of the texture
  28375. */
  28376. uniqueId: number;
  28377. /**
  28378. * Define the name of the texture.
  28379. */
  28380. name: string;
  28381. /**
  28382. * Gets or sets an object used to store user defined information.
  28383. */
  28384. metadata: any;
  28385. /**
  28386. * For internal use only. Please do not use.
  28387. */
  28388. reservedDataStore: any;
  28389. private _hasAlpha;
  28390. /**
  28391. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28392. */
  28393. hasAlpha: boolean;
  28394. /**
  28395. * Defines if the alpha value should be determined via the rgb values.
  28396. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28397. */
  28398. getAlphaFromRGB: boolean;
  28399. /**
  28400. * Intensity or strength of the texture.
  28401. * It is commonly used by materials to fine tune the intensity of the texture
  28402. */
  28403. level: number;
  28404. /**
  28405. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28406. * This is part of the texture as textures usually maps to one uv set.
  28407. */
  28408. coordinatesIndex: number;
  28409. private _coordinatesMode;
  28410. /**
  28411. * How a texture is mapped.
  28412. *
  28413. * | Value | Type | Description |
  28414. * | ----- | ----------------------------------- | ----------- |
  28415. * | 0 | EXPLICIT_MODE | |
  28416. * | 1 | SPHERICAL_MODE | |
  28417. * | 2 | PLANAR_MODE | |
  28418. * | 3 | CUBIC_MODE | |
  28419. * | 4 | PROJECTION_MODE | |
  28420. * | 5 | SKYBOX_MODE | |
  28421. * | 6 | INVCUBIC_MODE | |
  28422. * | 7 | EQUIRECTANGULAR_MODE | |
  28423. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28424. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28425. */
  28426. coordinatesMode: number;
  28427. /**
  28428. * | Value | Type | Description |
  28429. * | ----- | ------------------ | ----------- |
  28430. * | 0 | CLAMP_ADDRESSMODE | |
  28431. * | 1 | WRAP_ADDRESSMODE | |
  28432. * | 2 | MIRROR_ADDRESSMODE | |
  28433. */
  28434. wrapU: number;
  28435. /**
  28436. * | Value | Type | Description |
  28437. * | ----- | ------------------ | ----------- |
  28438. * | 0 | CLAMP_ADDRESSMODE | |
  28439. * | 1 | WRAP_ADDRESSMODE | |
  28440. * | 2 | MIRROR_ADDRESSMODE | |
  28441. */
  28442. wrapV: number;
  28443. /**
  28444. * | Value | Type | Description |
  28445. * | ----- | ------------------ | ----------- |
  28446. * | 0 | CLAMP_ADDRESSMODE | |
  28447. * | 1 | WRAP_ADDRESSMODE | |
  28448. * | 2 | MIRROR_ADDRESSMODE | |
  28449. */
  28450. wrapR: number;
  28451. /**
  28452. * With compliant hardware and browser (supporting anisotropic filtering)
  28453. * this defines the level of anisotropic filtering in the texture.
  28454. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28455. */
  28456. anisotropicFilteringLevel: number;
  28457. /**
  28458. * Define if the texture is a cube texture or if false a 2d texture.
  28459. */
  28460. isCube: boolean;
  28461. /**
  28462. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28463. */
  28464. is3D: boolean;
  28465. /**
  28466. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28467. * HDR texture are usually stored in linear space.
  28468. * This only impacts the PBR and Background materials
  28469. */
  28470. gammaSpace: boolean;
  28471. /**
  28472. * Gets whether or not the texture contains RGBD data.
  28473. */
  28474. readonly isRGBD: boolean;
  28475. /**
  28476. * Is Z inverted in the texture (useful in a cube texture).
  28477. */
  28478. invertZ: boolean;
  28479. /**
  28480. * Are mip maps generated for this texture or not.
  28481. */
  28482. readonly noMipmap: boolean;
  28483. /**
  28484. * @hidden
  28485. */
  28486. lodLevelInAlpha: boolean;
  28487. /**
  28488. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28489. */
  28490. lodGenerationOffset: number;
  28491. /**
  28492. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28493. */
  28494. lodGenerationScale: number;
  28495. /**
  28496. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28497. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28498. * average roughness values.
  28499. */
  28500. linearSpecularLOD: boolean;
  28501. /**
  28502. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28503. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28504. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28505. */
  28506. irradianceTexture: Nullable<BaseTexture>;
  28507. /**
  28508. * Define if the texture is a render target.
  28509. */
  28510. isRenderTarget: boolean;
  28511. /**
  28512. * Define the unique id of the texture in the scene.
  28513. */
  28514. readonly uid: string;
  28515. /**
  28516. * Return a string representation of the texture.
  28517. * @returns the texture as a string
  28518. */
  28519. toString(): string;
  28520. /**
  28521. * Get the class name of the texture.
  28522. * @returns "BaseTexture"
  28523. */
  28524. getClassName(): string;
  28525. /**
  28526. * Define the list of animation attached to the texture.
  28527. */
  28528. animations: import("babylonjs/Animations/animation").Animation[];
  28529. /**
  28530. * An event triggered when the texture is disposed.
  28531. */
  28532. onDisposeObservable: Observable<BaseTexture>;
  28533. private _onDisposeObserver;
  28534. /**
  28535. * Callback triggered when the texture has been disposed.
  28536. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28537. */
  28538. onDispose: () => void;
  28539. /**
  28540. * Define the current state of the loading sequence when in delayed load mode.
  28541. */
  28542. delayLoadState: number;
  28543. private _scene;
  28544. /** @hidden */
  28545. _texture: Nullable<InternalTexture>;
  28546. private _uid;
  28547. /**
  28548. * Define if the texture is preventinga material to render or not.
  28549. * If not and the texture is not ready, the engine will use a default black texture instead.
  28550. */
  28551. readonly isBlocking: boolean;
  28552. /**
  28553. * Instantiates a new BaseTexture.
  28554. * Base class of all the textures in babylon.
  28555. * It groups all the common properties the materials, post process, lights... might need
  28556. * in order to make a correct use of the texture.
  28557. * @param scene Define the scene the texture blongs to
  28558. */
  28559. constructor(scene: Nullable<Scene>);
  28560. /**
  28561. * Get the scene the texture belongs to.
  28562. * @returns the scene or null if undefined
  28563. */
  28564. getScene(): Nullable<Scene>;
  28565. /**
  28566. * Get the texture transform matrix used to offset tile the texture for istance.
  28567. * @returns the transformation matrix
  28568. */
  28569. getTextureMatrix(): Matrix;
  28570. /**
  28571. * Get the texture reflection matrix used to rotate/transform the reflection.
  28572. * @returns the reflection matrix
  28573. */
  28574. getReflectionTextureMatrix(): Matrix;
  28575. /**
  28576. * Get the underlying lower level texture from Babylon.
  28577. * @returns the insternal texture
  28578. */
  28579. getInternalTexture(): Nullable<InternalTexture>;
  28580. /**
  28581. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28582. * @returns true if ready or not blocking
  28583. */
  28584. isReadyOrNotBlocking(): boolean;
  28585. /**
  28586. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28587. * @returns true if fully ready
  28588. */
  28589. isReady(): boolean;
  28590. private _cachedSize;
  28591. /**
  28592. * Get the size of the texture.
  28593. * @returns the texture size.
  28594. */
  28595. getSize(): ISize;
  28596. /**
  28597. * Get the base size of the texture.
  28598. * It can be different from the size if the texture has been resized for POT for instance
  28599. * @returns the base size
  28600. */
  28601. getBaseSize(): ISize;
  28602. /**
  28603. * Update the sampling mode of the texture.
  28604. * Default is Trilinear mode.
  28605. *
  28606. * | Value | Type | Description |
  28607. * | ----- | ------------------ | ----------- |
  28608. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28609. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28610. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28611. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28612. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28613. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28614. * | 7 | NEAREST_LINEAR | |
  28615. * | 8 | NEAREST_NEAREST | |
  28616. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28617. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28618. * | 11 | LINEAR_LINEAR | |
  28619. * | 12 | LINEAR_NEAREST | |
  28620. *
  28621. * > _mag_: magnification filter (close to the viewer)
  28622. * > _min_: minification filter (far from the viewer)
  28623. * > _mip_: filter used between mip map levels
  28624. *@param samplingMode Define the new sampling mode of the texture
  28625. */
  28626. updateSamplingMode(samplingMode: number): void;
  28627. /**
  28628. * Scales the texture if is `canRescale()`
  28629. * @param ratio the resize factor we want to use to rescale
  28630. */
  28631. scale(ratio: number): void;
  28632. /**
  28633. * Get if the texture can rescale.
  28634. */
  28635. readonly canRescale: boolean;
  28636. /** @hidden */
  28637. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28638. /** @hidden */
  28639. _rebuild(): void;
  28640. /**
  28641. * Triggers the load sequence in delayed load mode.
  28642. */
  28643. delayLoad(): void;
  28644. /**
  28645. * Clones the texture.
  28646. * @returns the cloned texture
  28647. */
  28648. clone(): Nullable<BaseTexture>;
  28649. /**
  28650. * Get the texture underlying type (INT, FLOAT...)
  28651. */
  28652. readonly textureType: number;
  28653. /**
  28654. * Get the texture underlying format (RGB, RGBA...)
  28655. */
  28656. readonly textureFormat: number;
  28657. /**
  28658. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28659. * This will returns an RGBA array buffer containing either in values (0-255) or
  28660. * float values (0-1) depending of the underlying buffer type.
  28661. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28662. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28663. * @param buffer defines a user defined buffer to fill with data (can be null)
  28664. * @returns The Array buffer containing the pixels data.
  28665. */
  28666. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28667. /**
  28668. * Release and destroy the underlying lower level texture aka internalTexture.
  28669. */
  28670. releaseInternalTexture(): void;
  28671. /**
  28672. * Get the polynomial representation of the texture data.
  28673. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28674. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28675. */
  28676. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28677. /** @hidden */
  28678. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28679. /** @hidden */
  28680. readonly _lodTextureMid: Nullable<BaseTexture>;
  28681. /** @hidden */
  28682. readonly _lodTextureLow: Nullable<BaseTexture>;
  28683. /**
  28684. * Dispose the texture and release its associated resources.
  28685. */
  28686. dispose(): void;
  28687. /**
  28688. * Serialize the texture into a JSON representation that can be parsed later on.
  28689. * @returns the JSON representation of the texture
  28690. */
  28691. serialize(): any;
  28692. /**
  28693. * Helper function to be called back once a list of texture contains only ready textures.
  28694. * @param textures Define the list of textures to wait for
  28695. * @param callback Define the callback triggered once the entire list will be ready
  28696. */
  28697. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28698. }
  28699. }
  28700. declare module "babylonjs/Materials/Textures/internalTexture" {
  28701. import { Observable } from "babylonjs/Misc/observable";
  28702. import { Nullable, int } from "babylonjs/types";
  28703. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28704. import { Engine } from "babylonjs/Engines/engine";
  28705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28706. /**
  28707. * Class used to store data associated with WebGL texture data for the engine
  28708. * This class should not be used directly
  28709. */
  28710. export class InternalTexture {
  28711. /** @hidden */
  28712. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28713. /**
  28714. * The source of the texture data is unknown
  28715. */
  28716. static DATASOURCE_UNKNOWN: number;
  28717. /**
  28718. * Texture data comes from an URL
  28719. */
  28720. static DATASOURCE_URL: number;
  28721. /**
  28722. * Texture data is only used for temporary storage
  28723. */
  28724. static DATASOURCE_TEMP: number;
  28725. /**
  28726. * Texture data comes from raw data (ArrayBuffer)
  28727. */
  28728. static DATASOURCE_RAW: number;
  28729. /**
  28730. * Texture content is dynamic (video or dynamic texture)
  28731. */
  28732. static DATASOURCE_DYNAMIC: number;
  28733. /**
  28734. * Texture content is generated by rendering to it
  28735. */
  28736. static DATASOURCE_RENDERTARGET: number;
  28737. /**
  28738. * Texture content is part of a multi render target process
  28739. */
  28740. static DATASOURCE_MULTIRENDERTARGET: number;
  28741. /**
  28742. * Texture data comes from a cube data file
  28743. */
  28744. static DATASOURCE_CUBE: number;
  28745. /**
  28746. * Texture data comes from a raw cube data
  28747. */
  28748. static DATASOURCE_CUBERAW: number;
  28749. /**
  28750. * Texture data come from a prefiltered cube data file
  28751. */
  28752. static DATASOURCE_CUBEPREFILTERED: number;
  28753. /**
  28754. * Texture content is raw 3D data
  28755. */
  28756. static DATASOURCE_RAW3D: number;
  28757. /**
  28758. * Texture content is a depth texture
  28759. */
  28760. static DATASOURCE_DEPTHTEXTURE: number;
  28761. /**
  28762. * Texture data comes from a raw cube data encoded with RGBD
  28763. */
  28764. static DATASOURCE_CUBERAW_RGBD: number;
  28765. /**
  28766. * Defines if the texture is ready
  28767. */
  28768. isReady: boolean;
  28769. /**
  28770. * Defines if the texture is a cube texture
  28771. */
  28772. isCube: boolean;
  28773. /**
  28774. * Defines if the texture contains 3D data
  28775. */
  28776. is3D: boolean;
  28777. /**
  28778. * Defines if the texture contains multiview data
  28779. */
  28780. isMultiview: boolean;
  28781. /**
  28782. * Gets the URL used to load this texture
  28783. */
  28784. url: string;
  28785. /**
  28786. * Gets the sampling mode of the texture
  28787. */
  28788. samplingMode: number;
  28789. /**
  28790. * Gets a boolean indicating if the texture needs mipmaps generation
  28791. */
  28792. generateMipMaps: boolean;
  28793. /**
  28794. * Gets the number of samples used by the texture (WebGL2+ only)
  28795. */
  28796. samples: number;
  28797. /**
  28798. * Gets the type of the texture (int, float...)
  28799. */
  28800. type: number;
  28801. /**
  28802. * Gets the format of the texture (RGB, RGBA...)
  28803. */
  28804. format: number;
  28805. /**
  28806. * Observable called when the texture is loaded
  28807. */
  28808. onLoadedObservable: Observable<InternalTexture>;
  28809. /**
  28810. * Gets the width of the texture
  28811. */
  28812. width: number;
  28813. /**
  28814. * Gets the height of the texture
  28815. */
  28816. height: number;
  28817. /**
  28818. * Gets the depth of the texture
  28819. */
  28820. depth: number;
  28821. /**
  28822. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28823. */
  28824. baseWidth: number;
  28825. /**
  28826. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28827. */
  28828. baseHeight: number;
  28829. /**
  28830. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28831. */
  28832. baseDepth: number;
  28833. /**
  28834. * Gets a boolean indicating if the texture is inverted on Y axis
  28835. */
  28836. invertY: boolean;
  28837. /** @hidden */
  28838. _invertVScale: boolean;
  28839. /** @hidden */
  28840. _associatedChannel: number;
  28841. /** @hidden */
  28842. _dataSource: number;
  28843. /** @hidden */
  28844. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28845. /** @hidden */
  28846. _bufferView: Nullable<ArrayBufferView>;
  28847. /** @hidden */
  28848. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28849. /** @hidden */
  28850. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28851. /** @hidden */
  28852. _size: number;
  28853. /** @hidden */
  28854. _extension: string;
  28855. /** @hidden */
  28856. _files: Nullable<string[]>;
  28857. /** @hidden */
  28858. _workingCanvas: Nullable<HTMLCanvasElement>;
  28859. /** @hidden */
  28860. _workingContext: Nullable<CanvasRenderingContext2D>;
  28861. /** @hidden */
  28862. _framebuffer: Nullable<WebGLFramebuffer>;
  28863. /** @hidden */
  28864. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28865. /** @hidden */
  28866. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28867. /** @hidden */
  28868. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28869. /** @hidden */
  28870. _attachments: Nullable<number[]>;
  28871. /** @hidden */
  28872. _cachedCoordinatesMode: Nullable<number>;
  28873. /** @hidden */
  28874. _cachedWrapU: Nullable<number>;
  28875. /** @hidden */
  28876. _cachedWrapV: Nullable<number>;
  28877. /** @hidden */
  28878. _cachedWrapR: Nullable<number>;
  28879. /** @hidden */
  28880. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28881. /** @hidden */
  28882. _isDisabled: boolean;
  28883. /** @hidden */
  28884. _compression: Nullable<string>;
  28885. /** @hidden */
  28886. _generateStencilBuffer: boolean;
  28887. /** @hidden */
  28888. _generateDepthBuffer: boolean;
  28889. /** @hidden */
  28890. _comparisonFunction: number;
  28891. /** @hidden */
  28892. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28893. /** @hidden */
  28894. _lodGenerationScale: number;
  28895. /** @hidden */
  28896. _lodGenerationOffset: number;
  28897. /** @hidden */
  28898. _colorTextureArray: Nullable<WebGLTexture>;
  28899. /** @hidden */
  28900. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28901. /** @hidden */
  28902. _lodTextureHigh: Nullable<BaseTexture>;
  28903. /** @hidden */
  28904. _lodTextureMid: Nullable<BaseTexture>;
  28905. /** @hidden */
  28906. _lodTextureLow: Nullable<BaseTexture>;
  28907. /** @hidden */
  28908. _isRGBD: boolean;
  28909. /** @hidden */
  28910. _linearSpecularLOD: boolean;
  28911. /** @hidden */
  28912. _irradianceTexture: Nullable<BaseTexture>;
  28913. /** @hidden */
  28914. _webGLTexture: Nullable<WebGLTexture>;
  28915. /** @hidden */
  28916. _references: number;
  28917. private _engine;
  28918. /**
  28919. * Gets the Engine the texture belongs to.
  28920. * @returns The babylon engine
  28921. */
  28922. getEngine(): Engine;
  28923. /**
  28924. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28925. */
  28926. readonly dataSource: number;
  28927. /**
  28928. * Creates a new InternalTexture
  28929. * @param engine defines the engine to use
  28930. * @param dataSource defines the type of data that will be used
  28931. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28932. */
  28933. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28934. /**
  28935. * Increments the number of references (ie. the number of Texture that point to it)
  28936. */
  28937. incrementReferences(): void;
  28938. /**
  28939. * Change the size of the texture (not the size of the content)
  28940. * @param width defines the new width
  28941. * @param height defines the new height
  28942. * @param depth defines the new depth (1 by default)
  28943. */
  28944. updateSize(width: int, height: int, depth?: int): void;
  28945. /** @hidden */
  28946. _rebuild(): void;
  28947. /** @hidden */
  28948. _swapAndDie(target: InternalTexture): void;
  28949. /**
  28950. * Dispose the current allocated resources
  28951. */
  28952. dispose(): void;
  28953. }
  28954. }
  28955. declare module "babylonjs/Materials/effect" {
  28956. import { Observable } from "babylonjs/Misc/observable";
  28957. import { Nullable } from "babylonjs/types";
  28958. import { IDisposable } from "babylonjs/scene";
  28959. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28960. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28961. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28962. import { Engine } from "babylonjs/Engines/engine";
  28963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28968. /**
  28969. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28970. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28971. */
  28972. export class EffectFallbacks {
  28973. private _defines;
  28974. private _currentRank;
  28975. private _maxRank;
  28976. private _mesh;
  28977. /**
  28978. * Removes the fallback from the bound mesh.
  28979. */
  28980. unBindMesh(): void;
  28981. /**
  28982. * Adds a fallback on the specified property.
  28983. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28984. * @param define The name of the define in the shader
  28985. */
  28986. addFallback(rank: number, define: string): void;
  28987. /**
  28988. * Sets the mesh to use CPU skinning when needing to fallback.
  28989. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28990. * @param mesh The mesh to use the fallbacks.
  28991. */
  28992. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28993. /**
  28994. * Checks to see if more fallbacks are still availible.
  28995. */
  28996. readonly hasMoreFallbacks: boolean;
  28997. /**
  28998. * Removes the defines that should be removed when falling back.
  28999. * @param currentDefines defines the current define statements for the shader.
  29000. * @param effect defines the current effect we try to compile
  29001. * @returns The resulting defines with defines of the current rank removed.
  29002. */
  29003. reduce(currentDefines: string, effect: Effect): string;
  29004. }
  29005. /**
  29006. * Options to be used when creating an effect.
  29007. */
  29008. export class EffectCreationOptions {
  29009. /**
  29010. * Atrributes that will be used in the shader.
  29011. */
  29012. attributes: string[];
  29013. /**
  29014. * Uniform varible names that will be set in the shader.
  29015. */
  29016. uniformsNames: string[];
  29017. /**
  29018. * Uniform buffer varible names that will be set in the shader.
  29019. */
  29020. uniformBuffersNames: string[];
  29021. /**
  29022. * Sampler texture variable names that will be set in the shader.
  29023. */
  29024. samplers: string[];
  29025. /**
  29026. * Define statements that will be set in the shader.
  29027. */
  29028. defines: any;
  29029. /**
  29030. * Possible fallbacks for this effect to improve performance when needed.
  29031. */
  29032. fallbacks: Nullable<EffectFallbacks>;
  29033. /**
  29034. * Callback that will be called when the shader is compiled.
  29035. */
  29036. onCompiled: Nullable<(effect: Effect) => void>;
  29037. /**
  29038. * Callback that will be called if an error occurs during shader compilation.
  29039. */
  29040. onError: Nullable<(effect: Effect, errors: string) => void>;
  29041. /**
  29042. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29043. */
  29044. indexParameters: any;
  29045. /**
  29046. * Max number of lights that can be used in the shader.
  29047. */
  29048. maxSimultaneousLights: number;
  29049. /**
  29050. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29051. */
  29052. transformFeedbackVaryings: Nullable<string[]>;
  29053. }
  29054. /**
  29055. * Effect containing vertex and fragment shader that can be executed on an object.
  29056. */
  29057. export class Effect implements IDisposable {
  29058. /**
  29059. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29060. */
  29061. static ShadersRepository: string;
  29062. /**
  29063. * Name of the effect.
  29064. */
  29065. name: any;
  29066. /**
  29067. * String container all the define statements that should be set on the shader.
  29068. */
  29069. defines: string;
  29070. /**
  29071. * Callback that will be called when the shader is compiled.
  29072. */
  29073. onCompiled: Nullable<(effect: Effect) => void>;
  29074. /**
  29075. * Callback that will be called if an error occurs during shader compilation.
  29076. */
  29077. onError: Nullable<(effect: Effect, errors: string) => void>;
  29078. /**
  29079. * Callback that will be called when effect is bound.
  29080. */
  29081. onBind: Nullable<(effect: Effect) => void>;
  29082. /**
  29083. * Unique ID of the effect.
  29084. */
  29085. uniqueId: number;
  29086. /**
  29087. * Observable that will be called when the shader is compiled.
  29088. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29089. */
  29090. onCompileObservable: Observable<Effect>;
  29091. /**
  29092. * Observable that will be called if an error occurs during shader compilation.
  29093. */
  29094. onErrorObservable: Observable<Effect>;
  29095. /** @hidden */
  29096. _onBindObservable: Nullable<Observable<Effect>>;
  29097. /**
  29098. * Observable that will be called when effect is bound.
  29099. */
  29100. readonly onBindObservable: Observable<Effect>;
  29101. /** @hidden */
  29102. _bonesComputationForcedToCPU: boolean;
  29103. private static _uniqueIdSeed;
  29104. private _engine;
  29105. private _uniformBuffersNames;
  29106. private _uniformsNames;
  29107. private _samplerList;
  29108. private _samplers;
  29109. private _isReady;
  29110. private _compilationError;
  29111. private _attributesNames;
  29112. private _attributes;
  29113. private _uniforms;
  29114. /**
  29115. * Key for the effect.
  29116. * @hidden
  29117. */
  29118. _key: string;
  29119. private _indexParameters;
  29120. private _fallbacks;
  29121. private _vertexSourceCode;
  29122. private _fragmentSourceCode;
  29123. private _vertexSourceCodeOverride;
  29124. private _fragmentSourceCodeOverride;
  29125. private _transformFeedbackVaryings;
  29126. /**
  29127. * Compiled shader to webGL program.
  29128. * @hidden
  29129. */
  29130. _pipelineContext: Nullable<IPipelineContext>;
  29131. private _valueCache;
  29132. private static _baseCache;
  29133. /**
  29134. * Instantiates an effect.
  29135. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29136. * @param baseName Name of the effect.
  29137. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29138. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29139. * @param samplers List of sampler variables that will be passed to the shader.
  29140. * @param engine Engine to be used to render the effect
  29141. * @param defines Define statements to be added to the shader.
  29142. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29143. * @param onCompiled Callback that will be called when the shader is compiled.
  29144. * @param onError Callback that will be called if an error occurs during shader compilation.
  29145. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29146. */
  29147. 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);
  29148. private _useFinalCode;
  29149. /**
  29150. * Unique key for this effect
  29151. */
  29152. readonly key: string;
  29153. /**
  29154. * If the effect has been compiled and prepared.
  29155. * @returns if the effect is compiled and prepared.
  29156. */
  29157. isReady(): boolean;
  29158. private _isReadyInternal;
  29159. /**
  29160. * The engine the effect was initialized with.
  29161. * @returns the engine.
  29162. */
  29163. getEngine(): Engine;
  29164. /**
  29165. * The pipeline context for this effect
  29166. * @returns the associated pipeline context
  29167. */
  29168. getPipelineContext(): Nullable<IPipelineContext>;
  29169. /**
  29170. * The set of names of attribute variables for the shader.
  29171. * @returns An array of attribute names.
  29172. */
  29173. getAttributesNames(): string[];
  29174. /**
  29175. * Returns the attribute at the given index.
  29176. * @param index The index of the attribute.
  29177. * @returns The location of the attribute.
  29178. */
  29179. getAttributeLocation(index: number): number;
  29180. /**
  29181. * Returns the attribute based on the name of the variable.
  29182. * @param name of the attribute to look up.
  29183. * @returns the attribute location.
  29184. */
  29185. getAttributeLocationByName(name: string): number;
  29186. /**
  29187. * The number of attributes.
  29188. * @returns the numnber of attributes.
  29189. */
  29190. getAttributesCount(): number;
  29191. /**
  29192. * Gets the index of a uniform variable.
  29193. * @param uniformName of the uniform to look up.
  29194. * @returns the index.
  29195. */
  29196. getUniformIndex(uniformName: string): number;
  29197. /**
  29198. * Returns the attribute based on the name of the variable.
  29199. * @param uniformName of the uniform to look up.
  29200. * @returns the location of the uniform.
  29201. */
  29202. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29203. /**
  29204. * Returns an array of sampler variable names
  29205. * @returns The array of sampler variable neames.
  29206. */
  29207. getSamplers(): string[];
  29208. /**
  29209. * The error from the last compilation.
  29210. * @returns the error string.
  29211. */
  29212. getCompilationError(): string;
  29213. /**
  29214. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29215. * @param func The callback to be used.
  29216. */
  29217. executeWhenCompiled(func: (effect: Effect) => void): void;
  29218. private _checkIsReady;
  29219. /** @hidden */
  29220. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29221. /** @hidden */
  29222. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29223. /** @hidden */
  29224. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29225. /**
  29226. * Recompiles the webGL program
  29227. * @param vertexSourceCode The source code for the vertex shader.
  29228. * @param fragmentSourceCode The source code for the fragment shader.
  29229. * @param onCompiled Callback called when completed.
  29230. * @param onError Callback called on error.
  29231. * @hidden
  29232. */
  29233. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29234. /**
  29235. * Prepares the effect
  29236. * @hidden
  29237. */
  29238. _prepareEffect(): void;
  29239. private _processCompilationErrors;
  29240. /**
  29241. * Checks if the effect is supported. (Must be called after compilation)
  29242. */
  29243. readonly isSupported: boolean;
  29244. /**
  29245. * Binds a texture to the engine to be used as output of the shader.
  29246. * @param channel Name of the output variable.
  29247. * @param texture Texture to bind.
  29248. * @hidden
  29249. */
  29250. _bindTexture(channel: string, texture: InternalTexture): void;
  29251. /**
  29252. * Sets a texture on the engine to be used in the shader.
  29253. * @param channel Name of the sampler variable.
  29254. * @param texture Texture to set.
  29255. */
  29256. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29257. /**
  29258. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29259. * @param channel Name of the sampler variable.
  29260. * @param texture Texture to set.
  29261. */
  29262. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29263. /**
  29264. * Sets an array of textures on the engine to be used in the shader.
  29265. * @param channel Name of the variable.
  29266. * @param textures Textures to set.
  29267. */
  29268. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29269. /**
  29270. * 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)
  29271. * @param channel Name of the sampler variable.
  29272. * @param postProcess Post process to get the input texture from.
  29273. */
  29274. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29275. /**
  29276. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29277. * 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)
  29278. * @param channel Name of the sampler variable.
  29279. * @param postProcess Post process to get the output texture from.
  29280. */
  29281. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29282. /** @hidden */
  29283. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29284. /** @hidden */
  29285. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29286. /** @hidden */
  29287. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29288. /** @hidden */
  29289. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29290. /**
  29291. * Binds a buffer to a uniform.
  29292. * @param buffer Buffer to bind.
  29293. * @param name Name of the uniform variable to bind to.
  29294. */
  29295. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29296. /**
  29297. * Binds block to a uniform.
  29298. * @param blockName Name of the block to bind.
  29299. * @param index Index to bind.
  29300. */
  29301. bindUniformBlock(blockName: string, index: number): void;
  29302. /**
  29303. * Sets an interger value on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param value Value to be set.
  29306. * @returns this effect.
  29307. */
  29308. setInt(uniformName: string, value: number): Effect;
  29309. /**
  29310. * Sets an int array on a uniform variable.
  29311. * @param uniformName Name of the variable.
  29312. * @param array array to be set.
  29313. * @returns this effect.
  29314. */
  29315. setIntArray(uniformName: string, array: Int32Array): Effect;
  29316. /**
  29317. * 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)
  29318. * @param uniformName Name of the variable.
  29319. * @param array array to be set.
  29320. * @returns this effect.
  29321. */
  29322. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29323. /**
  29324. * 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)
  29325. * @param uniformName Name of the variable.
  29326. * @param array array to be set.
  29327. * @returns this effect.
  29328. */
  29329. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29330. /**
  29331. * 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)
  29332. * @param uniformName Name of the variable.
  29333. * @param array array to be set.
  29334. * @returns this effect.
  29335. */
  29336. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29337. /**
  29338. * Sets an float array on a uniform variable.
  29339. * @param uniformName Name of the variable.
  29340. * @param array array to be set.
  29341. * @returns this effect.
  29342. */
  29343. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29344. /**
  29345. * 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)
  29346. * @param uniformName Name of the variable.
  29347. * @param array array to be set.
  29348. * @returns this effect.
  29349. */
  29350. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29351. /**
  29352. * 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)
  29353. * @param uniformName Name of the variable.
  29354. * @param array array to be set.
  29355. * @returns this effect.
  29356. */
  29357. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29358. /**
  29359. * 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)
  29360. * @param uniformName Name of the variable.
  29361. * @param array array to be set.
  29362. * @returns this effect.
  29363. */
  29364. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29365. /**
  29366. * Sets an array on a uniform variable.
  29367. * @param uniformName Name of the variable.
  29368. * @param array array to be set.
  29369. * @returns this effect.
  29370. */
  29371. setArray(uniformName: string, array: number[]): Effect;
  29372. /**
  29373. * 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)
  29374. * @param uniformName Name of the variable.
  29375. * @param array array to be set.
  29376. * @returns this effect.
  29377. */
  29378. setArray2(uniformName: string, array: number[]): Effect;
  29379. /**
  29380. * 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)
  29381. * @param uniformName Name of the variable.
  29382. * @param array array to be set.
  29383. * @returns this effect.
  29384. */
  29385. setArray3(uniformName: string, array: number[]): Effect;
  29386. /**
  29387. * 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)
  29388. * @param uniformName Name of the variable.
  29389. * @param array array to be set.
  29390. * @returns this effect.
  29391. */
  29392. setArray4(uniformName: string, array: number[]): Effect;
  29393. /**
  29394. * Sets matrices on a uniform variable.
  29395. * @param uniformName Name of the variable.
  29396. * @param matrices matrices to be set.
  29397. * @returns this effect.
  29398. */
  29399. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29400. /**
  29401. * Sets matrix on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param matrix matrix to be set.
  29404. * @returns this effect.
  29405. */
  29406. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29407. /**
  29408. * 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)
  29409. * @param uniformName Name of the variable.
  29410. * @param matrix matrix to be set.
  29411. * @returns this effect.
  29412. */
  29413. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29414. /**
  29415. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29416. * @param uniformName Name of the variable.
  29417. * @param matrix matrix to be set.
  29418. * @returns this effect.
  29419. */
  29420. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29421. /**
  29422. * Sets a float on a uniform variable.
  29423. * @param uniformName Name of the variable.
  29424. * @param value value to be set.
  29425. * @returns this effect.
  29426. */
  29427. setFloat(uniformName: string, value: number): Effect;
  29428. /**
  29429. * Sets a boolean on a uniform variable.
  29430. * @param uniformName Name of the variable.
  29431. * @param bool value to be set.
  29432. * @returns this effect.
  29433. */
  29434. setBool(uniformName: string, bool: boolean): Effect;
  29435. /**
  29436. * Sets a Vector2 on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param vector2 vector2 to be set.
  29439. * @returns this effect.
  29440. */
  29441. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29442. /**
  29443. * Sets a float2 on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param x First float in float2.
  29446. * @param y Second float in float2.
  29447. * @returns this effect.
  29448. */
  29449. setFloat2(uniformName: string, x: number, y: number): Effect;
  29450. /**
  29451. * Sets a Vector3 on a uniform variable.
  29452. * @param uniformName Name of the variable.
  29453. * @param vector3 Value to be set.
  29454. * @returns this effect.
  29455. */
  29456. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29457. /**
  29458. * Sets a float3 on a uniform variable.
  29459. * @param uniformName Name of the variable.
  29460. * @param x First float in float3.
  29461. * @param y Second float in float3.
  29462. * @param z Third float in float3.
  29463. * @returns this effect.
  29464. */
  29465. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29466. /**
  29467. * Sets a Vector4 on a uniform variable.
  29468. * @param uniformName Name of the variable.
  29469. * @param vector4 Value to be set.
  29470. * @returns this effect.
  29471. */
  29472. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29473. /**
  29474. * Sets a float4 on a uniform variable.
  29475. * @param uniformName Name of the variable.
  29476. * @param x First float in float4.
  29477. * @param y Second float in float4.
  29478. * @param z Third float in float4.
  29479. * @param w Fourth float in float4.
  29480. * @returns this effect.
  29481. */
  29482. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29483. /**
  29484. * Sets a Color3 on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param color3 Value to be set.
  29487. * @returns this effect.
  29488. */
  29489. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29490. /**
  29491. * Sets a Color4 on a uniform variable.
  29492. * @param uniformName Name of the variable.
  29493. * @param color3 Value to be set.
  29494. * @param alpha Alpha value to be set.
  29495. * @returns this effect.
  29496. */
  29497. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29498. /**
  29499. * Sets a Color4 on a uniform variable
  29500. * @param uniformName defines the name of the variable
  29501. * @param color4 defines the value to be set
  29502. * @returns this effect.
  29503. */
  29504. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29505. /** Release all associated resources */
  29506. dispose(): void;
  29507. /**
  29508. * This function will add a new shader to the shader store
  29509. * @param name the name of the shader
  29510. * @param pixelShader optional pixel shader content
  29511. * @param vertexShader optional vertex shader content
  29512. */
  29513. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29514. /**
  29515. * Store of each shader (The can be looked up using effect.key)
  29516. */
  29517. static ShadersStore: {
  29518. [key: string]: string;
  29519. };
  29520. /**
  29521. * Store of each included file for a shader (The can be looked up using effect.key)
  29522. */
  29523. static IncludesShadersStore: {
  29524. [key: string]: string;
  29525. };
  29526. /**
  29527. * Resets the cache of effects.
  29528. */
  29529. static ResetCache(): void;
  29530. }
  29531. }
  29532. declare module "babylonjs/Materials/uniformBuffer" {
  29533. import { Nullable, FloatArray } from "babylonjs/types";
  29534. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29535. import { Engine } from "babylonjs/Engines/engine";
  29536. import { Effect } from "babylonjs/Materials/effect";
  29537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29538. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29539. import { Color3 } from "babylonjs/Maths/math.color";
  29540. /**
  29541. * Uniform buffer objects.
  29542. *
  29543. * Handles blocks of uniform on the GPU.
  29544. *
  29545. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29546. *
  29547. * For more information, please refer to :
  29548. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29549. */
  29550. export class UniformBuffer {
  29551. private _engine;
  29552. private _buffer;
  29553. private _data;
  29554. private _bufferData;
  29555. private _dynamic?;
  29556. private _uniformLocations;
  29557. private _uniformSizes;
  29558. private _uniformLocationPointer;
  29559. private _needSync;
  29560. private _noUBO;
  29561. private _currentEffect;
  29562. private static _MAX_UNIFORM_SIZE;
  29563. private static _tempBuffer;
  29564. /**
  29565. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29566. * This is dynamic to allow compat with webgl 1 and 2.
  29567. * You will need to pass the name of the uniform as well as the value.
  29568. */
  29569. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29570. /**
  29571. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29572. * This is dynamic to allow compat with webgl 1 and 2.
  29573. * You will need to pass the name of the uniform as well as the value.
  29574. */
  29575. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29576. /**
  29577. * Lambda to Update a single float in a uniform buffer.
  29578. * This is dynamic to allow compat with webgl 1 and 2.
  29579. * You will need to pass the name of the uniform as well as the value.
  29580. */
  29581. updateFloat: (name: string, x: number) => void;
  29582. /**
  29583. * Lambda to Update a vec2 of float in a uniform buffer.
  29584. * This is dynamic to allow compat with webgl 1 and 2.
  29585. * You will need to pass the name of the uniform as well as the value.
  29586. */
  29587. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29588. /**
  29589. * Lambda to Update a vec3 of float in a uniform buffer.
  29590. * This is dynamic to allow compat with webgl 1 and 2.
  29591. * You will need to pass the name of the uniform as well as the value.
  29592. */
  29593. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29594. /**
  29595. * Lambda to Update a vec4 of float in a uniform buffer.
  29596. * This is dynamic to allow compat with webgl 1 and 2.
  29597. * You will need to pass the name of the uniform as well as the value.
  29598. */
  29599. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29600. /**
  29601. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29602. * This is dynamic to allow compat with webgl 1 and 2.
  29603. * You will need to pass the name of the uniform as well as the value.
  29604. */
  29605. updateMatrix: (name: string, mat: Matrix) => void;
  29606. /**
  29607. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29608. * This is dynamic to allow compat with webgl 1 and 2.
  29609. * You will need to pass the name of the uniform as well as the value.
  29610. */
  29611. updateVector3: (name: string, vector: Vector3) => void;
  29612. /**
  29613. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29614. * This is dynamic to allow compat with webgl 1 and 2.
  29615. * You will need to pass the name of the uniform as well as the value.
  29616. */
  29617. updateVector4: (name: string, vector: Vector4) => void;
  29618. /**
  29619. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29620. * This is dynamic to allow compat with webgl 1 and 2.
  29621. * You will need to pass the name of the uniform as well as the value.
  29622. */
  29623. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29624. /**
  29625. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29626. * This is dynamic to allow compat with webgl 1 and 2.
  29627. * You will need to pass the name of the uniform as well as the value.
  29628. */
  29629. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29630. /**
  29631. * Instantiates a new Uniform buffer objects.
  29632. *
  29633. * Handles blocks of uniform on the GPU.
  29634. *
  29635. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29636. *
  29637. * For more information, please refer to :
  29638. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29639. * @param engine Define the engine the buffer is associated with
  29640. * @param data Define the data contained in the buffer
  29641. * @param dynamic Define if the buffer is updatable
  29642. */
  29643. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29644. /**
  29645. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29646. * or just falling back on setUniformXXX calls.
  29647. */
  29648. readonly useUbo: boolean;
  29649. /**
  29650. * Indicates if the WebGL underlying uniform buffer is in sync
  29651. * with the javascript cache data.
  29652. */
  29653. readonly isSync: boolean;
  29654. /**
  29655. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29656. * Also, a dynamic UniformBuffer will disable cache verification and always
  29657. * update the underlying WebGL uniform buffer to the GPU.
  29658. * @returns if Dynamic, otherwise false
  29659. */
  29660. isDynamic(): boolean;
  29661. /**
  29662. * The data cache on JS side.
  29663. * @returns the underlying data as a float array
  29664. */
  29665. getData(): Float32Array;
  29666. /**
  29667. * The underlying WebGL Uniform buffer.
  29668. * @returns the webgl buffer
  29669. */
  29670. getBuffer(): Nullable<DataBuffer>;
  29671. /**
  29672. * std140 layout specifies how to align data within an UBO structure.
  29673. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29674. * for specs.
  29675. */
  29676. private _fillAlignment;
  29677. /**
  29678. * Adds an uniform in the buffer.
  29679. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29680. * for the layout to be correct !
  29681. * @param name Name of the uniform, as used in the uniform block in the shader.
  29682. * @param size Data size, or data directly.
  29683. */
  29684. addUniform(name: string, size: number | number[]): void;
  29685. /**
  29686. * Adds a Matrix 4x4 to the uniform buffer.
  29687. * @param name Name of the uniform, as used in the uniform block in the shader.
  29688. * @param mat A 4x4 matrix.
  29689. */
  29690. addMatrix(name: string, mat: Matrix): void;
  29691. /**
  29692. * Adds a vec2 to the uniform buffer.
  29693. * @param name Name of the uniform, as used in the uniform block in the shader.
  29694. * @param x Define the x component value of the vec2
  29695. * @param y Define the y component value of the vec2
  29696. */
  29697. addFloat2(name: string, x: number, y: number): void;
  29698. /**
  29699. * Adds a vec3 to the uniform buffer.
  29700. * @param name Name of the uniform, as used in the uniform block in the shader.
  29701. * @param x Define the x component value of the vec3
  29702. * @param y Define the y component value of the vec3
  29703. * @param z Define the z component value of the vec3
  29704. */
  29705. addFloat3(name: string, x: number, y: number, z: number): void;
  29706. /**
  29707. * Adds a vec3 to the uniform buffer.
  29708. * @param name Name of the uniform, as used in the uniform block in the shader.
  29709. * @param color Define the vec3 from a Color
  29710. */
  29711. addColor3(name: string, color: Color3): void;
  29712. /**
  29713. * Adds a vec4 to the uniform buffer.
  29714. * @param name Name of the uniform, as used in the uniform block in the shader.
  29715. * @param color Define the rgb components from a Color
  29716. * @param alpha Define the a component of the vec4
  29717. */
  29718. addColor4(name: string, color: Color3, alpha: number): void;
  29719. /**
  29720. * Adds a vec3 to the uniform buffer.
  29721. * @param name Name of the uniform, as used in the uniform block in the shader.
  29722. * @param vector Define the vec3 components from a Vector
  29723. */
  29724. addVector3(name: string, vector: Vector3): void;
  29725. /**
  29726. * Adds a Matrix 3x3 to the uniform buffer.
  29727. * @param name Name of the uniform, as used in the uniform block in the shader.
  29728. */
  29729. addMatrix3x3(name: string): void;
  29730. /**
  29731. * Adds a Matrix 2x2 to the uniform buffer.
  29732. * @param name Name of the uniform, as used in the uniform block in the shader.
  29733. */
  29734. addMatrix2x2(name: string): void;
  29735. /**
  29736. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29737. */
  29738. create(): void;
  29739. /** @hidden */
  29740. _rebuild(): void;
  29741. /**
  29742. * Updates the WebGL Uniform Buffer on the GPU.
  29743. * If the `dynamic` flag is set to true, no cache comparison is done.
  29744. * Otherwise, the buffer will be updated only if the cache differs.
  29745. */
  29746. update(): void;
  29747. /**
  29748. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29749. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29750. * @param data Define the flattened data
  29751. * @param size Define the size of the data.
  29752. */
  29753. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29754. private _valueCache;
  29755. private _cacheMatrix;
  29756. private _updateMatrix3x3ForUniform;
  29757. private _updateMatrix3x3ForEffect;
  29758. private _updateMatrix2x2ForEffect;
  29759. private _updateMatrix2x2ForUniform;
  29760. private _updateFloatForEffect;
  29761. private _updateFloatForUniform;
  29762. private _updateFloat2ForEffect;
  29763. private _updateFloat2ForUniform;
  29764. private _updateFloat3ForEffect;
  29765. private _updateFloat3ForUniform;
  29766. private _updateFloat4ForEffect;
  29767. private _updateFloat4ForUniform;
  29768. private _updateMatrixForEffect;
  29769. private _updateMatrixForUniform;
  29770. private _updateVector3ForEffect;
  29771. private _updateVector3ForUniform;
  29772. private _updateVector4ForEffect;
  29773. private _updateVector4ForUniform;
  29774. private _updateColor3ForEffect;
  29775. private _updateColor3ForUniform;
  29776. private _updateColor4ForEffect;
  29777. private _updateColor4ForUniform;
  29778. /**
  29779. * Sets a sampler uniform on the effect.
  29780. * @param name Define the name of the sampler.
  29781. * @param texture Define the texture to set in the sampler
  29782. */
  29783. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29784. /**
  29785. * Directly updates the value of the uniform in the cache AND on the GPU.
  29786. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29787. * @param data Define the flattened data
  29788. */
  29789. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29790. /**
  29791. * Binds this uniform buffer to an effect.
  29792. * @param effect Define the effect to bind the buffer to
  29793. * @param name Name of the uniform block in the shader.
  29794. */
  29795. bindToEffect(effect: Effect, name: string): void;
  29796. /**
  29797. * Disposes the uniform buffer.
  29798. */
  29799. dispose(): void;
  29800. }
  29801. }
  29802. declare module "babylonjs/Audio/analyser" {
  29803. import { Scene } from "babylonjs/scene";
  29804. /**
  29805. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29807. */
  29808. export class Analyser {
  29809. /**
  29810. * Gets or sets the smoothing
  29811. * @ignorenaming
  29812. */
  29813. SMOOTHING: number;
  29814. /**
  29815. * Gets or sets the FFT table size
  29816. * @ignorenaming
  29817. */
  29818. FFT_SIZE: number;
  29819. /**
  29820. * Gets or sets the bar graph amplitude
  29821. * @ignorenaming
  29822. */
  29823. BARGRAPHAMPLITUDE: number;
  29824. /**
  29825. * Gets or sets the position of the debug canvas
  29826. * @ignorenaming
  29827. */
  29828. DEBUGCANVASPOS: {
  29829. x: number;
  29830. y: number;
  29831. };
  29832. /**
  29833. * Gets or sets the debug canvas size
  29834. * @ignorenaming
  29835. */
  29836. DEBUGCANVASSIZE: {
  29837. width: number;
  29838. height: number;
  29839. };
  29840. private _byteFreqs;
  29841. private _byteTime;
  29842. private _floatFreqs;
  29843. private _webAudioAnalyser;
  29844. private _debugCanvas;
  29845. private _debugCanvasContext;
  29846. private _scene;
  29847. private _registerFunc;
  29848. private _audioEngine;
  29849. /**
  29850. * Creates a new analyser
  29851. * @param scene defines hosting scene
  29852. */
  29853. constructor(scene: Scene);
  29854. /**
  29855. * Get the number of data values you will have to play with for the visualization
  29856. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29857. * @returns a number
  29858. */
  29859. getFrequencyBinCount(): number;
  29860. /**
  29861. * Gets the current frequency data as a byte array
  29862. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29863. * @returns a Uint8Array
  29864. */
  29865. getByteFrequencyData(): Uint8Array;
  29866. /**
  29867. * Gets the current waveform as a byte array
  29868. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29869. * @returns a Uint8Array
  29870. */
  29871. getByteTimeDomainData(): Uint8Array;
  29872. /**
  29873. * Gets the current frequency data as a float array
  29874. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29875. * @returns a Float32Array
  29876. */
  29877. getFloatFrequencyData(): Float32Array;
  29878. /**
  29879. * Renders the debug canvas
  29880. */
  29881. drawDebugCanvas(): void;
  29882. /**
  29883. * Stops rendering the debug canvas and removes it
  29884. */
  29885. stopDebugCanvas(): void;
  29886. /**
  29887. * Connects two audio nodes
  29888. * @param inputAudioNode defines first node to connect
  29889. * @param outputAudioNode defines second node to connect
  29890. */
  29891. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29892. /**
  29893. * Releases all associated resources
  29894. */
  29895. dispose(): void;
  29896. }
  29897. }
  29898. declare module "babylonjs/Audio/audioEngine" {
  29899. import { IDisposable } from "babylonjs/scene";
  29900. import { Analyser } from "babylonjs/Audio/analyser";
  29901. import { Nullable } from "babylonjs/types";
  29902. import { Observable } from "babylonjs/Misc/observable";
  29903. /**
  29904. * This represents an audio engine and it is responsible
  29905. * to play, synchronize and analyse sounds throughout the application.
  29906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29907. */
  29908. export interface IAudioEngine extends IDisposable {
  29909. /**
  29910. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29911. */
  29912. readonly canUseWebAudio: boolean;
  29913. /**
  29914. * Gets the current AudioContext if available.
  29915. */
  29916. readonly audioContext: Nullable<AudioContext>;
  29917. /**
  29918. * The master gain node defines the global audio volume of your audio engine.
  29919. */
  29920. readonly masterGain: GainNode;
  29921. /**
  29922. * Gets whether or not mp3 are supported by your browser.
  29923. */
  29924. readonly isMP3supported: boolean;
  29925. /**
  29926. * Gets whether or not ogg are supported by your browser.
  29927. */
  29928. readonly isOGGsupported: boolean;
  29929. /**
  29930. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29931. * @ignoreNaming
  29932. */
  29933. WarnedWebAudioUnsupported: boolean;
  29934. /**
  29935. * Defines if the audio engine relies on a custom unlocked button.
  29936. * In this case, the embedded button will not be displayed.
  29937. */
  29938. useCustomUnlockedButton: boolean;
  29939. /**
  29940. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29941. */
  29942. readonly unlocked: boolean;
  29943. /**
  29944. * Event raised when audio has been unlocked on the browser.
  29945. */
  29946. onAudioUnlockedObservable: Observable<AudioEngine>;
  29947. /**
  29948. * Event raised when audio has been locked on the browser.
  29949. */
  29950. onAudioLockedObservable: Observable<AudioEngine>;
  29951. /**
  29952. * Flags the audio engine in Locked state.
  29953. * This happens due to new browser policies preventing audio to autoplay.
  29954. */
  29955. lock(): void;
  29956. /**
  29957. * Unlocks the audio engine once a user action has been done on the dom.
  29958. * This is helpful to resume play once browser policies have been satisfied.
  29959. */
  29960. unlock(): void;
  29961. }
  29962. /**
  29963. * This represents the default audio engine used in babylon.
  29964. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29966. */
  29967. export class AudioEngine implements IAudioEngine {
  29968. private _audioContext;
  29969. private _audioContextInitialized;
  29970. private _muteButton;
  29971. private _hostElement;
  29972. /**
  29973. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29974. */
  29975. canUseWebAudio: boolean;
  29976. /**
  29977. * The master gain node defines the global audio volume of your audio engine.
  29978. */
  29979. masterGain: GainNode;
  29980. /**
  29981. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29982. * @ignoreNaming
  29983. */
  29984. WarnedWebAudioUnsupported: boolean;
  29985. /**
  29986. * Gets whether or not mp3 are supported by your browser.
  29987. */
  29988. isMP3supported: boolean;
  29989. /**
  29990. * Gets whether or not ogg are supported by your browser.
  29991. */
  29992. isOGGsupported: boolean;
  29993. /**
  29994. * Gets whether audio has been unlocked on the device.
  29995. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29996. * a user interaction has happened.
  29997. */
  29998. unlocked: boolean;
  29999. /**
  30000. * Defines if the audio engine relies on a custom unlocked button.
  30001. * In this case, the embedded button will not be displayed.
  30002. */
  30003. useCustomUnlockedButton: boolean;
  30004. /**
  30005. * Event raised when audio has been unlocked on the browser.
  30006. */
  30007. onAudioUnlockedObservable: Observable<AudioEngine>;
  30008. /**
  30009. * Event raised when audio has been locked on the browser.
  30010. */
  30011. onAudioLockedObservable: Observable<AudioEngine>;
  30012. /**
  30013. * Gets the current AudioContext if available.
  30014. */
  30015. readonly audioContext: Nullable<AudioContext>;
  30016. private _connectedAnalyser;
  30017. /**
  30018. * Instantiates a new audio engine.
  30019. *
  30020. * There should be only one per page as some browsers restrict the number
  30021. * of audio contexts you can create.
  30022. * @param hostElement defines the host element where to display the mute icon if necessary
  30023. */
  30024. constructor(hostElement?: Nullable<HTMLElement>);
  30025. /**
  30026. * Flags the audio engine in Locked state.
  30027. * This happens due to new browser policies preventing audio to autoplay.
  30028. */
  30029. lock(): void;
  30030. /**
  30031. * Unlocks the audio engine once a user action has been done on the dom.
  30032. * This is helpful to resume play once browser policies have been satisfied.
  30033. */
  30034. unlock(): void;
  30035. private _resumeAudioContext;
  30036. private _initializeAudioContext;
  30037. private _tryToRun;
  30038. private _triggerRunningState;
  30039. private _triggerSuspendedState;
  30040. private _displayMuteButton;
  30041. private _moveButtonToTopLeft;
  30042. private _onResize;
  30043. private _hideMuteButton;
  30044. /**
  30045. * Destroy and release the resources associated with the audio ccontext.
  30046. */
  30047. dispose(): void;
  30048. /**
  30049. * Gets the global volume sets on the master gain.
  30050. * @returns the global volume if set or -1 otherwise
  30051. */
  30052. getGlobalVolume(): number;
  30053. /**
  30054. * Sets the global volume of your experience (sets on the master gain).
  30055. * @param newVolume Defines the new global volume of the application
  30056. */
  30057. setGlobalVolume(newVolume: number): void;
  30058. /**
  30059. * Connect the audio engine to an audio analyser allowing some amazing
  30060. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30062. * @param analyser The analyser to connect to the engine
  30063. */
  30064. connectToAnalyser(analyser: Analyser): void;
  30065. }
  30066. }
  30067. declare module "babylonjs/Loading/loadingScreen" {
  30068. /**
  30069. * Interface used to present a loading screen while loading a scene
  30070. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30071. */
  30072. export interface ILoadingScreen {
  30073. /**
  30074. * Function called to display the loading screen
  30075. */
  30076. displayLoadingUI: () => void;
  30077. /**
  30078. * Function called to hide the loading screen
  30079. */
  30080. hideLoadingUI: () => void;
  30081. /**
  30082. * Gets or sets the color to use for the background
  30083. */
  30084. loadingUIBackgroundColor: string;
  30085. /**
  30086. * Gets or sets the text to display while loading
  30087. */
  30088. loadingUIText: string;
  30089. }
  30090. /**
  30091. * Class used for the default loading screen
  30092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30093. */
  30094. export class DefaultLoadingScreen implements ILoadingScreen {
  30095. private _renderingCanvas;
  30096. private _loadingText;
  30097. private _loadingDivBackgroundColor;
  30098. private _loadingDiv;
  30099. private _loadingTextDiv;
  30100. /** Gets or sets the logo url to use for the default loading screen */
  30101. static DefaultLogoUrl: string;
  30102. /** Gets or sets the spinner url to use for the default loading screen */
  30103. static DefaultSpinnerUrl: string;
  30104. /**
  30105. * Creates a new default loading screen
  30106. * @param _renderingCanvas defines the canvas used to render the scene
  30107. * @param _loadingText defines the default text to display
  30108. * @param _loadingDivBackgroundColor defines the default background color
  30109. */
  30110. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30111. /**
  30112. * Function called to display the loading screen
  30113. */
  30114. displayLoadingUI(): void;
  30115. /**
  30116. * Function called to hide the loading screen
  30117. */
  30118. hideLoadingUI(): void;
  30119. /**
  30120. * Gets or sets the text to display while loading
  30121. */
  30122. loadingUIText: string;
  30123. /**
  30124. * Gets or sets the color to use for the background
  30125. */
  30126. loadingUIBackgroundColor: string;
  30127. private _resizeLoadingUI;
  30128. }
  30129. }
  30130. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30131. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30132. import { Engine } from "babylonjs/Engines/engine";
  30133. import { Nullable } from "babylonjs/types";
  30134. /** @hidden */
  30135. export class WebGLPipelineContext implements IPipelineContext {
  30136. engine: Engine;
  30137. program: Nullable<WebGLProgram>;
  30138. context?: WebGLRenderingContext;
  30139. vertexShader?: WebGLShader;
  30140. fragmentShader?: WebGLShader;
  30141. isParallelCompiled: boolean;
  30142. onCompiled?: () => void;
  30143. transformFeedback?: WebGLTransformFeedback | null;
  30144. readonly isAsync: boolean;
  30145. readonly isReady: boolean;
  30146. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30147. }
  30148. }
  30149. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30150. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30151. /** @hidden */
  30152. export class WebGLDataBuffer extends DataBuffer {
  30153. private _buffer;
  30154. constructor(resource: WebGLBuffer);
  30155. readonly underlyingResource: any;
  30156. }
  30157. }
  30158. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30159. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30160. /** @hidden */
  30161. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30162. attributeProcessor(attribute: string): string;
  30163. varyingProcessor(varying: string, isFragment: boolean): string;
  30164. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30165. }
  30166. }
  30167. declare module "babylonjs/Misc/perfCounter" {
  30168. /**
  30169. * This class is used to track a performance counter which is number based.
  30170. * The user has access to many properties which give statistics of different nature.
  30171. *
  30172. * The implementer can track two kinds of Performance Counter: time and count.
  30173. * 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.
  30174. * 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.
  30175. */
  30176. export class PerfCounter {
  30177. /**
  30178. * Gets or sets a global boolean to turn on and off all the counters
  30179. */
  30180. static Enabled: boolean;
  30181. /**
  30182. * Returns the smallest value ever
  30183. */
  30184. readonly min: number;
  30185. /**
  30186. * Returns the biggest value ever
  30187. */
  30188. readonly max: number;
  30189. /**
  30190. * Returns the average value since the performance counter is running
  30191. */
  30192. readonly average: number;
  30193. /**
  30194. * Returns the average value of the last second the counter was monitored
  30195. */
  30196. readonly lastSecAverage: number;
  30197. /**
  30198. * Returns the current value
  30199. */
  30200. readonly current: number;
  30201. /**
  30202. * Gets the accumulated total
  30203. */
  30204. readonly total: number;
  30205. /**
  30206. * Gets the total value count
  30207. */
  30208. readonly count: number;
  30209. /**
  30210. * Creates a new counter
  30211. */
  30212. constructor();
  30213. /**
  30214. * Call this method to start monitoring a new frame.
  30215. * 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.
  30216. */
  30217. fetchNewFrame(): void;
  30218. /**
  30219. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30220. * @param newCount the count value to add to the monitored count
  30221. * @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.
  30222. */
  30223. addCount(newCount: number, fetchResult: boolean): void;
  30224. /**
  30225. * Start monitoring this performance counter
  30226. */
  30227. beginMonitoring(): void;
  30228. /**
  30229. * Compute the time lapsed since the previous beginMonitoring() call.
  30230. * @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
  30231. */
  30232. endMonitoring(newFrame?: boolean): void;
  30233. private _fetchResult;
  30234. private _startMonitoringTime;
  30235. private _min;
  30236. private _max;
  30237. private _average;
  30238. private _current;
  30239. private _totalValueCount;
  30240. private _totalAccumulated;
  30241. private _lastSecAverage;
  30242. private _lastSecAccumulated;
  30243. private _lastSecTime;
  30244. private _lastSecValueCount;
  30245. }
  30246. }
  30247. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30248. /**
  30249. * Interface for any object that can request an animation frame
  30250. */
  30251. export interface ICustomAnimationFrameRequester {
  30252. /**
  30253. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30254. */
  30255. renderFunction?: Function;
  30256. /**
  30257. * Called to request the next frame to render to
  30258. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30259. */
  30260. requestAnimationFrame: Function;
  30261. /**
  30262. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30263. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30264. */
  30265. requestID?: number;
  30266. }
  30267. }
  30268. declare module "babylonjs/Materials/Textures/videoTexture" {
  30269. import { Observable } from "babylonjs/Misc/observable";
  30270. import { Nullable } from "babylonjs/types";
  30271. import { Scene } from "babylonjs/scene";
  30272. import { Texture } from "babylonjs/Materials/Textures/texture";
  30273. /**
  30274. * Settings for finer control over video usage
  30275. */
  30276. export interface VideoTextureSettings {
  30277. /**
  30278. * Applies `autoplay` to video, if specified
  30279. */
  30280. autoPlay?: boolean;
  30281. /**
  30282. * Applies `loop` to video, if specified
  30283. */
  30284. loop?: boolean;
  30285. /**
  30286. * Automatically updates internal texture from video at every frame in the render loop
  30287. */
  30288. autoUpdateTexture: boolean;
  30289. /**
  30290. * Image src displayed during the video loading or until the user interacts with the video.
  30291. */
  30292. poster?: string;
  30293. }
  30294. /**
  30295. * If you want to display a video in your scene, this is the special texture for that.
  30296. * This special texture works similar to other textures, with the exception of a few parameters.
  30297. * @see https://doc.babylonjs.com/how_to/video_texture
  30298. */
  30299. export class VideoTexture extends Texture {
  30300. /**
  30301. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30302. */
  30303. readonly autoUpdateTexture: boolean;
  30304. /**
  30305. * The video instance used by the texture internally
  30306. */
  30307. readonly video: HTMLVideoElement;
  30308. private _onUserActionRequestedObservable;
  30309. /**
  30310. * Event triggerd when a dom action is required by the user to play the video.
  30311. * This happens due to recent changes in browser policies preventing video to auto start.
  30312. */
  30313. readonly onUserActionRequestedObservable: Observable<Texture>;
  30314. private _generateMipMaps;
  30315. private _engine;
  30316. private _stillImageCaptured;
  30317. private _displayingPosterTexture;
  30318. private _settings;
  30319. private _createInternalTextureOnEvent;
  30320. /**
  30321. * Creates a video texture.
  30322. * If you want to display a video in your scene, this is the special texture for that.
  30323. * This special texture works similar to other textures, with the exception of a few parameters.
  30324. * @see https://doc.babylonjs.com/how_to/video_texture
  30325. * @param name optional name, will detect from video source, if not defined
  30326. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30327. * @param scene is obviously the current scene.
  30328. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30329. * @param invertY is false by default but can be used to invert video on Y axis
  30330. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30331. * @param settings allows finer control over video usage
  30332. */
  30333. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30334. private _getName;
  30335. private _getVideo;
  30336. private _createInternalTexture;
  30337. private reset;
  30338. /**
  30339. * @hidden Internal method to initiate `update`.
  30340. */
  30341. _rebuild(): void;
  30342. /**
  30343. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30344. */
  30345. update(): void;
  30346. /**
  30347. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30348. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30349. */
  30350. updateTexture(isVisible: boolean): void;
  30351. protected _updateInternalTexture: () => void;
  30352. /**
  30353. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30354. * @param url New url.
  30355. */
  30356. updateURL(url: string): void;
  30357. /**
  30358. * Dispose the texture and release its associated resources.
  30359. */
  30360. dispose(): void;
  30361. /**
  30362. * Creates a video texture straight from a stream.
  30363. * @param scene Define the scene the texture should be created in
  30364. * @param stream Define the stream the texture should be created from
  30365. * @returns The created video texture as a promise
  30366. */
  30367. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30368. /**
  30369. * Creates a video texture straight from your WebCam video feed.
  30370. * @param scene Define the scene the texture should be created in
  30371. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30372. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30373. * @returns The created video texture as a promise
  30374. */
  30375. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30376. minWidth: number;
  30377. maxWidth: number;
  30378. minHeight: number;
  30379. maxHeight: number;
  30380. deviceId: string;
  30381. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30382. /**
  30383. * Creates a video texture straight from your WebCam video feed.
  30384. * @param scene Define the scene the texture should be created in
  30385. * @param onReady Define a callback to triggered once the texture will be ready
  30386. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30387. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30388. */
  30389. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30390. minWidth: number;
  30391. maxWidth: number;
  30392. minHeight: number;
  30393. maxHeight: number;
  30394. deviceId: string;
  30395. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30396. }
  30397. }
  30398. declare module "babylonjs/Engines/engine" {
  30399. import { Observable } from "babylonjs/Misc/observable";
  30400. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30401. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30402. import { Scene } from "babylonjs/scene";
  30403. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30404. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30405. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30406. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30409. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30410. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30411. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30412. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30413. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30414. import { WebRequest } from "babylonjs/Misc/webRequest";
  30415. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30416. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30417. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30418. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30419. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30420. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30421. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30422. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30423. import { Material } from "babylonjs/Materials/material";
  30424. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30426. /**
  30427. * Defines the interface used by objects containing a viewport (like a camera)
  30428. */
  30429. interface IViewportOwnerLike {
  30430. /**
  30431. * Gets or sets the viewport
  30432. */
  30433. viewport: IViewportLike;
  30434. }
  30435. /**
  30436. * Interface for attribute information associated with buffer instanciation
  30437. */
  30438. export class InstancingAttributeInfo {
  30439. /**
  30440. * Index/offset of the attribute in the vertex shader
  30441. */
  30442. index: number;
  30443. /**
  30444. * size of the attribute, 1, 2, 3 or 4
  30445. */
  30446. attributeSize: number;
  30447. /**
  30448. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30449. * default is FLOAT
  30450. */
  30451. attribyteType: number;
  30452. /**
  30453. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30454. */
  30455. normalized: boolean;
  30456. /**
  30457. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30458. */
  30459. offset: number;
  30460. /**
  30461. * Name of the GLSL attribute, for debugging purpose only
  30462. */
  30463. attributeName: string;
  30464. }
  30465. /**
  30466. * Define options used to create a depth texture
  30467. */
  30468. export class DepthTextureCreationOptions {
  30469. /** Specifies whether or not a stencil should be allocated in the texture */
  30470. generateStencil?: boolean;
  30471. /** Specifies whether or not bilinear filtering is enable on the texture */
  30472. bilinearFiltering?: boolean;
  30473. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30474. comparisonFunction?: number;
  30475. /** Specifies if the created texture is a cube texture */
  30476. isCube?: boolean;
  30477. }
  30478. /**
  30479. * Class used to describe the capabilities of the engine relatively to the current browser
  30480. */
  30481. export class EngineCapabilities {
  30482. /** Maximum textures units per fragment shader */
  30483. maxTexturesImageUnits: number;
  30484. /** Maximum texture units per vertex shader */
  30485. maxVertexTextureImageUnits: number;
  30486. /** Maximum textures units in the entire pipeline */
  30487. maxCombinedTexturesImageUnits: number;
  30488. /** Maximum texture size */
  30489. maxTextureSize: number;
  30490. /** Maximum cube texture size */
  30491. maxCubemapTextureSize: number;
  30492. /** Maximum render texture size */
  30493. maxRenderTextureSize: number;
  30494. /** Maximum number of vertex attributes */
  30495. maxVertexAttribs: number;
  30496. /** Maximum number of varyings */
  30497. maxVaryingVectors: number;
  30498. /** Maximum number of uniforms per vertex shader */
  30499. maxVertexUniformVectors: number;
  30500. /** Maximum number of uniforms per fragment shader */
  30501. maxFragmentUniformVectors: number;
  30502. /** Defines if standard derivates (dx/dy) are supported */
  30503. standardDerivatives: boolean;
  30504. /** Defines if s3tc texture compression is supported */
  30505. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30506. /** Defines if pvrtc texture compression is supported */
  30507. pvrtc: any;
  30508. /** Defines if etc1 texture compression is supported */
  30509. etc1: any;
  30510. /** Defines if etc2 texture compression is supported */
  30511. etc2: any;
  30512. /** Defines if astc texture compression is supported */
  30513. astc: any;
  30514. /** Defines if float textures are supported */
  30515. textureFloat: boolean;
  30516. /** Defines if vertex array objects are supported */
  30517. vertexArrayObject: boolean;
  30518. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30519. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30520. /** Gets the maximum level of anisotropy supported */
  30521. maxAnisotropy: number;
  30522. /** Defines if instancing is supported */
  30523. instancedArrays: boolean;
  30524. /** Defines if 32 bits indices are supported */
  30525. uintIndices: boolean;
  30526. /** Defines if high precision shaders are supported */
  30527. highPrecisionShaderSupported: boolean;
  30528. /** Defines if depth reading in the fragment shader is supported */
  30529. fragmentDepthSupported: boolean;
  30530. /** Defines if float texture linear filtering is supported*/
  30531. textureFloatLinearFiltering: boolean;
  30532. /** Defines if rendering to float textures is supported */
  30533. textureFloatRender: boolean;
  30534. /** Defines if half float textures are supported*/
  30535. textureHalfFloat: boolean;
  30536. /** Defines if half float texture linear filtering is supported*/
  30537. textureHalfFloatLinearFiltering: boolean;
  30538. /** Defines if rendering to half float textures is supported */
  30539. textureHalfFloatRender: boolean;
  30540. /** Defines if textureLOD shader command is supported */
  30541. textureLOD: boolean;
  30542. /** Defines if draw buffers extension is supported */
  30543. drawBuffersExtension: boolean;
  30544. /** Defines if depth textures are supported */
  30545. depthTextureExtension: boolean;
  30546. /** Defines if float color buffer are supported */
  30547. colorBufferFloat: boolean;
  30548. /** Gets disjoint timer query extension (null if not supported) */
  30549. timerQuery: EXT_disjoint_timer_query;
  30550. /** Defines if timestamp can be used with timer query */
  30551. canUseTimestampForTimerQuery: boolean;
  30552. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30553. multiview: any;
  30554. /** Function used to let the system compiles shaders in background */
  30555. parallelShaderCompile: {
  30556. COMPLETION_STATUS_KHR: number;
  30557. };
  30558. /** Max number of texture samples for MSAA */
  30559. maxMSAASamples: number;
  30560. }
  30561. /** Interface defining initialization parameters for Engine class */
  30562. export interface EngineOptions extends WebGLContextAttributes {
  30563. /**
  30564. * Defines if the engine should no exceed a specified device ratio
  30565. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30566. */
  30567. limitDeviceRatio?: number;
  30568. /**
  30569. * Defines if webvr should be enabled automatically
  30570. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30571. */
  30572. autoEnableWebVR?: boolean;
  30573. /**
  30574. * Defines if webgl2 should be turned off even if supported
  30575. * @see http://doc.babylonjs.com/features/webgl2
  30576. */
  30577. disableWebGL2Support?: boolean;
  30578. /**
  30579. * Defines if webaudio should be initialized as well
  30580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30581. */
  30582. audioEngine?: boolean;
  30583. /**
  30584. * Defines if animations should run using a deterministic lock step
  30585. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30586. */
  30587. deterministicLockstep?: boolean;
  30588. /** Defines the maximum steps to use with deterministic lock step mode */
  30589. lockstepMaxSteps?: number;
  30590. /**
  30591. * Defines that engine should ignore context lost events
  30592. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30593. */
  30594. doNotHandleContextLost?: boolean;
  30595. /**
  30596. * Defines that engine should ignore modifying touch action attribute and style
  30597. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30598. */
  30599. doNotHandleTouchAction?: boolean;
  30600. /**
  30601. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30602. */
  30603. useHighPrecisionFloats?: boolean;
  30604. }
  30605. /**
  30606. * Defines the interface used by display changed events
  30607. */
  30608. export interface IDisplayChangedEventArgs {
  30609. /** Gets the vrDisplay object (if any) */
  30610. vrDisplay: Nullable<any>;
  30611. /** Gets a boolean indicating if webVR is supported */
  30612. vrSupported: boolean;
  30613. }
  30614. /**
  30615. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30616. */
  30617. export class Engine {
  30618. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30619. static ExceptionList: ({
  30620. key: string;
  30621. capture: string;
  30622. captureConstraint: number;
  30623. targets: string[];
  30624. } | {
  30625. key: string;
  30626. capture: null;
  30627. captureConstraint: null;
  30628. targets: string[];
  30629. })[];
  30630. /** Gets the list of created engines */
  30631. static readonly Instances: Engine[];
  30632. /**
  30633. * Gets the latest created engine
  30634. */
  30635. static readonly LastCreatedEngine: Nullable<Engine>;
  30636. /**
  30637. * Gets the latest created scene
  30638. */
  30639. static readonly LastCreatedScene: Nullable<Scene>;
  30640. /**
  30641. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30642. * @param flag defines which part of the materials must be marked as dirty
  30643. * @param predicate defines a predicate used to filter which materials should be affected
  30644. */
  30645. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30646. /** @hidden */
  30647. static _TextureLoaders: IInternalTextureLoader[];
  30648. /** Defines that alpha blending is disabled */
  30649. static readonly ALPHA_DISABLE: number;
  30650. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30651. static readonly ALPHA_ADD: number;
  30652. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30653. static readonly ALPHA_COMBINE: number;
  30654. /** Defines that alpha blending to DEST - SRC * DEST */
  30655. static readonly ALPHA_SUBTRACT: number;
  30656. /** Defines that alpha blending to SRC * DEST */
  30657. static readonly ALPHA_MULTIPLY: number;
  30658. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30659. static readonly ALPHA_MAXIMIZED: number;
  30660. /** Defines that alpha blending to SRC + DEST */
  30661. static readonly ALPHA_ONEONE: number;
  30662. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30663. static readonly ALPHA_PREMULTIPLIED: number;
  30664. /**
  30665. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30666. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30667. */
  30668. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30669. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30670. static readonly ALPHA_INTERPOLATE: number;
  30671. /**
  30672. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30673. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30674. */
  30675. static readonly ALPHA_SCREENMODE: number;
  30676. /** Defines that the ressource is not delayed*/
  30677. static readonly DELAYLOADSTATE_NONE: number;
  30678. /** Defines that the ressource was successfully delay loaded */
  30679. static readonly DELAYLOADSTATE_LOADED: number;
  30680. /** Defines that the ressource is currently delay loading */
  30681. static readonly DELAYLOADSTATE_LOADING: number;
  30682. /** Defines that the ressource is delayed and has not started loading */
  30683. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30685. static readonly NEVER: number;
  30686. /** 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 */
  30687. static readonly ALWAYS: number;
  30688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30689. static readonly LESS: number;
  30690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30691. static readonly EQUAL: number;
  30692. /** 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 */
  30693. static readonly LEQUAL: number;
  30694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30695. static readonly GREATER: number;
  30696. /** 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 */
  30697. static readonly GEQUAL: number;
  30698. /** 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 */
  30699. static readonly NOTEQUAL: number;
  30700. /** Passed to stencilOperation to specify that stencil value must be kept */
  30701. static readonly KEEP: number;
  30702. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30703. static readonly REPLACE: number;
  30704. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30705. static readonly INCR: number;
  30706. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30707. static readonly DECR: number;
  30708. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30709. static readonly INVERT: number;
  30710. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30711. static readonly INCR_WRAP: number;
  30712. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30713. static readonly DECR_WRAP: number;
  30714. /** Texture is not repeating outside of 0..1 UVs */
  30715. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30716. /** Texture is repeating outside of 0..1 UVs */
  30717. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30718. /** Texture is repeating and mirrored */
  30719. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30720. /** ALPHA */
  30721. static readonly TEXTUREFORMAT_ALPHA: number;
  30722. /** LUMINANCE */
  30723. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30724. /** LUMINANCE_ALPHA */
  30725. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30726. /** RGB */
  30727. static readonly TEXTUREFORMAT_RGB: number;
  30728. /** RGBA */
  30729. static readonly TEXTUREFORMAT_RGBA: number;
  30730. /** RED */
  30731. static readonly TEXTUREFORMAT_RED: number;
  30732. /** RED (2nd reference) */
  30733. static readonly TEXTUREFORMAT_R: number;
  30734. /** RG */
  30735. static readonly TEXTUREFORMAT_RG: number;
  30736. /** RED_INTEGER */
  30737. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30738. /** RED_INTEGER (2nd reference) */
  30739. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30740. /** RG_INTEGER */
  30741. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30742. /** RGB_INTEGER */
  30743. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30744. /** RGBA_INTEGER */
  30745. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30746. /** UNSIGNED_BYTE */
  30747. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30748. /** UNSIGNED_BYTE (2nd reference) */
  30749. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30750. /** FLOAT */
  30751. static readonly TEXTURETYPE_FLOAT: number;
  30752. /** HALF_FLOAT */
  30753. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30754. /** BYTE */
  30755. static readonly TEXTURETYPE_BYTE: number;
  30756. /** SHORT */
  30757. static readonly TEXTURETYPE_SHORT: number;
  30758. /** UNSIGNED_SHORT */
  30759. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30760. /** INT */
  30761. static readonly TEXTURETYPE_INT: number;
  30762. /** UNSIGNED_INT */
  30763. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30764. /** UNSIGNED_SHORT_4_4_4_4 */
  30765. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30766. /** UNSIGNED_SHORT_5_5_5_1 */
  30767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30768. /** UNSIGNED_SHORT_5_6_5 */
  30769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30770. /** UNSIGNED_INT_2_10_10_10_REV */
  30771. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30772. /** UNSIGNED_INT_24_8 */
  30773. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30774. /** UNSIGNED_INT_10F_11F_11F_REV */
  30775. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30776. /** UNSIGNED_INT_5_9_9_9_REV */
  30777. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30778. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30779. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30780. /** nearest is mag = nearest and min = nearest and mip = linear */
  30781. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30782. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30784. /** Trilinear is mag = linear and min = linear and mip = linear */
  30785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30786. /** nearest is mag = nearest and min = nearest and mip = linear */
  30787. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30788. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30789. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30790. /** Trilinear is mag = linear and min = linear and mip = linear */
  30791. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30792. /** mag = nearest and min = nearest and mip = nearest */
  30793. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30794. /** mag = nearest and min = linear and mip = nearest */
  30795. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30796. /** mag = nearest and min = linear and mip = linear */
  30797. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30798. /** mag = nearest and min = linear and mip = none */
  30799. static readonly TEXTURE_NEAREST_LINEAR: number;
  30800. /** mag = nearest and min = nearest and mip = none */
  30801. static readonly TEXTURE_NEAREST_NEAREST: number;
  30802. /** mag = linear and min = nearest and mip = nearest */
  30803. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30804. /** mag = linear and min = nearest and mip = linear */
  30805. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30806. /** mag = linear and min = linear and mip = none */
  30807. static readonly TEXTURE_LINEAR_LINEAR: number;
  30808. /** mag = linear and min = nearest and mip = none */
  30809. static readonly TEXTURE_LINEAR_NEAREST: number;
  30810. /** Explicit coordinates mode */
  30811. static readonly TEXTURE_EXPLICIT_MODE: number;
  30812. /** Spherical coordinates mode */
  30813. static readonly TEXTURE_SPHERICAL_MODE: number;
  30814. /** Planar coordinates mode */
  30815. static readonly TEXTURE_PLANAR_MODE: number;
  30816. /** Cubic coordinates mode */
  30817. static readonly TEXTURE_CUBIC_MODE: number;
  30818. /** Projection coordinates mode */
  30819. static readonly TEXTURE_PROJECTION_MODE: number;
  30820. /** Skybox coordinates mode */
  30821. static readonly TEXTURE_SKYBOX_MODE: number;
  30822. /** Inverse Cubic coordinates mode */
  30823. static readonly TEXTURE_INVCUBIC_MODE: number;
  30824. /** Equirectangular coordinates mode */
  30825. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30826. /** Equirectangular Fixed coordinates mode */
  30827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30828. /** Equirectangular Fixed Mirrored coordinates mode */
  30829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30831. static readonly SCALEMODE_FLOOR: number;
  30832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30833. static readonly SCALEMODE_NEAREST: number;
  30834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30835. static readonly SCALEMODE_CEILING: number;
  30836. /**
  30837. * Returns the current npm package of the sdk
  30838. */
  30839. static readonly NpmPackage: string;
  30840. /**
  30841. * Returns the current version of the framework
  30842. */
  30843. static readonly Version: string;
  30844. /**
  30845. * Returns a string describing the current engine
  30846. */
  30847. readonly description: string;
  30848. /**
  30849. * Gets or sets the epsilon value used by collision engine
  30850. */
  30851. static CollisionsEpsilon: number;
  30852. /**
  30853. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30854. */
  30855. static ShadersRepository: string;
  30856. /**
  30857. * Method called to create the default loading screen.
  30858. * This can be overriden in your own app.
  30859. * @param canvas The rendering canvas element
  30860. * @returns The loading screen
  30861. */
  30862. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30863. /**
  30864. * Method called to create the default rescale post process on each engine.
  30865. */
  30866. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30867. /** @hidden */
  30868. _shaderProcessor: IShaderProcessor;
  30869. /**
  30870. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30871. */
  30872. forcePOTTextures: boolean;
  30873. /**
  30874. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30875. */
  30876. isFullscreen: boolean;
  30877. /**
  30878. * Gets a boolean indicating if the pointer is currently locked
  30879. */
  30880. isPointerLock: boolean;
  30881. /**
  30882. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30883. */
  30884. cullBackFaces: boolean;
  30885. /**
  30886. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30887. */
  30888. renderEvenInBackground: boolean;
  30889. /**
  30890. * Gets or sets a boolean indicating that cache can be kept between frames
  30891. */
  30892. preventCacheWipeBetweenFrames: boolean;
  30893. /**
  30894. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30895. **/
  30896. enableOfflineSupport: boolean;
  30897. /**
  30898. * 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)
  30899. **/
  30900. disableManifestCheck: boolean;
  30901. /**
  30902. * Gets the list of created scenes
  30903. */
  30904. scenes: Scene[];
  30905. /**
  30906. * Event raised when a new scene is created
  30907. */
  30908. onNewSceneAddedObservable: Observable<Scene>;
  30909. /**
  30910. * Gets the list of created postprocesses
  30911. */
  30912. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30913. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30914. validateShaderPrograms: boolean;
  30915. /**
  30916. * Observable event triggered each time the rendering canvas is resized
  30917. */
  30918. onResizeObservable: Observable<Engine>;
  30919. /**
  30920. * Observable event triggered each time the canvas loses focus
  30921. */
  30922. onCanvasBlurObservable: Observable<Engine>;
  30923. /**
  30924. * Observable event triggered each time the canvas gains focus
  30925. */
  30926. onCanvasFocusObservable: Observable<Engine>;
  30927. /**
  30928. * Observable event triggered each time the canvas receives pointerout event
  30929. */
  30930. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30931. /**
  30932. * Observable event triggered before each texture is initialized
  30933. */
  30934. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30935. /**
  30936. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30937. */
  30938. disableUniformBuffers: boolean;
  30939. /** @hidden */
  30940. _uniformBuffers: UniformBuffer[];
  30941. /**
  30942. * Gets a boolean indicating that the engine supports uniform buffers
  30943. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30944. */
  30945. readonly supportsUniformBuffers: boolean;
  30946. /**
  30947. * Observable raised when the engine begins a new frame
  30948. */
  30949. onBeginFrameObservable: Observable<Engine>;
  30950. /**
  30951. * If set, will be used to request the next animation frame for the render loop
  30952. */
  30953. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30954. /**
  30955. * Observable raised when the engine ends the current frame
  30956. */
  30957. onEndFrameObservable: Observable<Engine>;
  30958. /**
  30959. * Observable raised when the engine is about to compile a shader
  30960. */
  30961. onBeforeShaderCompilationObservable: Observable<Engine>;
  30962. /**
  30963. * Observable raised when the engine has jsut compiled a shader
  30964. */
  30965. onAfterShaderCompilationObservable: Observable<Engine>;
  30966. /** @hidden */
  30967. _gl: WebGLRenderingContext;
  30968. private _renderingCanvas;
  30969. private _windowIsBackground;
  30970. private _webGLVersion;
  30971. protected _highPrecisionShadersAllowed: boolean;
  30972. /** @hidden */
  30973. readonly _shouldUseHighPrecisionShader: boolean;
  30974. /**
  30975. * Gets a boolean indicating that only power of 2 textures are supported
  30976. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30977. */
  30978. readonly needPOTTextures: boolean;
  30979. /** @hidden */
  30980. _badOS: boolean;
  30981. /** @hidden */
  30982. _badDesktopOS: boolean;
  30983. /**
  30984. * Gets the audio engine
  30985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30986. * @ignorenaming
  30987. */
  30988. static audioEngine: IAudioEngine;
  30989. /**
  30990. * Default AudioEngine factory responsible of creating the Audio Engine.
  30991. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30992. */
  30993. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30994. /**
  30995. * Default offline support factory responsible of creating a tool used to store data locally.
  30996. * By default, this will create a Database object if the workload has been embedded.
  30997. */
  30998. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30999. private _onFocus;
  31000. private _onBlur;
  31001. private _onCanvasPointerOut;
  31002. private _onCanvasBlur;
  31003. private _onCanvasFocus;
  31004. private _onFullscreenChange;
  31005. private _onPointerLockChange;
  31006. private _hardwareScalingLevel;
  31007. /** @hidden */
  31008. _caps: EngineCapabilities;
  31009. private _pointerLockRequested;
  31010. private _isStencilEnable;
  31011. private _colorWrite;
  31012. private _loadingScreen;
  31013. /** @hidden */
  31014. _drawCalls: PerfCounter;
  31015. private _glVersion;
  31016. private _glRenderer;
  31017. private _glVendor;
  31018. private _videoTextureSupported;
  31019. private _renderingQueueLaunched;
  31020. private _activeRenderLoops;
  31021. private _deterministicLockstep;
  31022. private _lockstepMaxSteps;
  31023. /**
  31024. * Observable signaled when a context lost event is raised
  31025. */
  31026. onContextLostObservable: Observable<Engine>;
  31027. /**
  31028. * Observable signaled when a context restored event is raised
  31029. */
  31030. onContextRestoredObservable: Observable<Engine>;
  31031. private _onContextLost;
  31032. private _onContextRestored;
  31033. private _contextWasLost;
  31034. /** @hidden */
  31035. _doNotHandleContextLost: boolean;
  31036. /**
  31037. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31039. */
  31040. doNotHandleContextLost: boolean;
  31041. private _performanceMonitor;
  31042. private _fps;
  31043. private _deltaTime;
  31044. /**
  31045. * Turn this value on if you want to pause FPS computation when in background
  31046. */
  31047. disablePerformanceMonitorInBackground: boolean;
  31048. /**
  31049. * Gets the performance monitor attached to this engine
  31050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31051. */
  31052. readonly performanceMonitor: PerformanceMonitor;
  31053. /**
  31054. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31055. */
  31056. disableVertexArrayObjects: boolean;
  31057. /** @hidden */
  31058. protected _depthCullingState: _DepthCullingState;
  31059. /** @hidden */
  31060. protected _stencilState: _StencilState;
  31061. /** @hidden */
  31062. protected _alphaState: _AlphaState;
  31063. /** @hidden */
  31064. protected _alphaMode: number;
  31065. /** @hidden */
  31066. _internalTexturesCache: InternalTexture[];
  31067. /** @hidden */
  31068. protected _activeChannel: number;
  31069. private _currentTextureChannel;
  31070. /** @hidden */
  31071. protected _boundTexturesCache: {
  31072. [key: string]: Nullable<InternalTexture>;
  31073. };
  31074. /** @hidden */
  31075. protected _currentEffect: Nullable<Effect>;
  31076. /** @hidden */
  31077. protected _currentProgram: Nullable<WebGLProgram>;
  31078. private _compiledEffects;
  31079. private _vertexAttribArraysEnabled;
  31080. /** @hidden */
  31081. protected _cachedViewport: Nullable<IViewportLike>;
  31082. private _cachedVertexArrayObject;
  31083. /** @hidden */
  31084. protected _cachedVertexBuffers: any;
  31085. /** @hidden */
  31086. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31087. /** @hidden */
  31088. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31089. /** @hidden */
  31090. _currentRenderTarget: Nullable<InternalTexture>;
  31091. private _uintIndicesCurrentlySet;
  31092. private _currentBoundBuffer;
  31093. /** @hidden */
  31094. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31095. private _currentBufferPointers;
  31096. private _currentInstanceLocations;
  31097. private _currentInstanceBuffers;
  31098. private _textureUnits;
  31099. /** @hidden */
  31100. _workingCanvas: Nullable<HTMLCanvasElement>;
  31101. /** @hidden */
  31102. _workingContext: Nullable<CanvasRenderingContext2D>;
  31103. private _rescalePostProcess;
  31104. private _dummyFramebuffer;
  31105. private _externalData;
  31106. /** @hidden */
  31107. _bindedRenderFunction: any;
  31108. private _vaoRecordInProgress;
  31109. private _mustWipeVertexAttributes;
  31110. private _emptyTexture;
  31111. private _emptyCubeTexture;
  31112. private _emptyTexture3D;
  31113. /** @hidden */
  31114. _frameHandler: number;
  31115. private _nextFreeTextureSlots;
  31116. private _maxSimultaneousTextures;
  31117. private _activeRequests;
  31118. private _texturesSupported;
  31119. /** @hidden */
  31120. _textureFormatInUse: Nullable<string>;
  31121. /**
  31122. * Gets the list of texture formats supported
  31123. */
  31124. readonly texturesSupported: Array<string>;
  31125. /**
  31126. * Gets the list of texture formats in use
  31127. */
  31128. readonly textureFormatInUse: Nullable<string>;
  31129. /**
  31130. * Gets the current viewport
  31131. */
  31132. readonly currentViewport: Nullable<IViewportLike>;
  31133. /**
  31134. * Gets the default empty texture
  31135. */
  31136. readonly emptyTexture: InternalTexture;
  31137. /**
  31138. * Gets the default empty 3D texture
  31139. */
  31140. readonly emptyTexture3D: InternalTexture;
  31141. /**
  31142. * Gets the default empty cube texture
  31143. */
  31144. readonly emptyCubeTexture: InternalTexture;
  31145. /**
  31146. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31147. */
  31148. readonly premultipliedAlpha: boolean;
  31149. /**
  31150. * Creates a new engine
  31151. * @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
  31152. * @param antialias defines enable antialiasing (default: false)
  31153. * @param options defines further options to be sent to the getContext() function
  31154. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31155. */
  31156. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31157. /**
  31158. * Initializes a webVR display and starts listening to display change events
  31159. * The onVRDisplayChangedObservable will be notified upon these changes
  31160. * @returns The onVRDisplayChangedObservable
  31161. */
  31162. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31163. /** @hidden */
  31164. _prepareVRComponent(): void;
  31165. /** @hidden */
  31166. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31167. /** @hidden */
  31168. _submitVRFrame(): void;
  31169. /**
  31170. * Call this function to leave webVR mode
  31171. * Will do nothing if webVR is not supported or if there is no webVR device
  31172. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31173. */
  31174. disableVR(): void;
  31175. /**
  31176. * Gets a boolean indicating that the system is in VR mode and is presenting
  31177. * @returns true if VR mode is engaged
  31178. */
  31179. isVRPresenting(): boolean;
  31180. /** @hidden */
  31181. _requestVRFrame(): void;
  31182. private _disableTouchAction;
  31183. private _rebuildInternalTextures;
  31184. private _rebuildEffects;
  31185. /**
  31186. * Gets a boolean indicating if all created effects are ready
  31187. * @returns true if all effects are ready
  31188. */
  31189. areAllEffectsReady(): boolean;
  31190. private _rebuildBuffers;
  31191. private _initGLContext;
  31192. /**
  31193. * Gets version of the current webGL context
  31194. */
  31195. readonly webGLVersion: number;
  31196. /**
  31197. * Gets a string idenfifying the name of the class
  31198. * @returns "Engine" string
  31199. */
  31200. getClassName(): string;
  31201. /**
  31202. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31203. */
  31204. readonly isStencilEnable: boolean;
  31205. /** @hidden */
  31206. _prepareWorkingCanvas(): void;
  31207. /**
  31208. * Reset the texture cache to empty state
  31209. */
  31210. resetTextureCache(): void;
  31211. /**
  31212. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31214. * @returns true if engine is in deterministic lock step mode
  31215. */
  31216. isDeterministicLockStep(): boolean;
  31217. /**
  31218. * Gets the max steps when engine is running in deterministic lock step
  31219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31220. * @returns the max steps
  31221. */
  31222. getLockstepMaxSteps(): number;
  31223. /**
  31224. * Gets an object containing information about the current webGL context
  31225. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31226. */
  31227. getGlInfo(): {
  31228. vendor: string;
  31229. renderer: string;
  31230. version: string;
  31231. };
  31232. /**
  31233. * Gets current aspect ratio
  31234. * @param viewportOwner defines the camera to use to get the aspect ratio
  31235. * @param useScreen defines if screen size must be used (or the current render target if any)
  31236. * @returns a number defining the aspect ratio
  31237. */
  31238. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31239. /**
  31240. * Gets current screen aspect ratio
  31241. * @returns a number defining the aspect ratio
  31242. */
  31243. getScreenAspectRatio(): number;
  31244. /**
  31245. * Gets the current render width
  31246. * @param useScreen defines if screen size must be used (or the current render target if any)
  31247. * @returns a number defining the current render width
  31248. */
  31249. getRenderWidth(useScreen?: boolean): number;
  31250. /**
  31251. * Gets the current render height
  31252. * @param useScreen defines if screen size must be used (or the current render target if any)
  31253. * @returns a number defining the current render height
  31254. */
  31255. getRenderHeight(useScreen?: boolean): number;
  31256. /**
  31257. * Gets the HTML canvas attached with the current webGL context
  31258. * @returns a HTML canvas
  31259. */
  31260. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31261. /**
  31262. * Gets host window
  31263. * @returns the host window object
  31264. */
  31265. getHostWindow(): Window;
  31266. /**
  31267. * Gets host document
  31268. * @returns the host document object
  31269. */
  31270. getHostDocument(): Document;
  31271. /**
  31272. * Gets the client rect of the HTML canvas attached with the current webGL context
  31273. * @returns a client rectanglee
  31274. */
  31275. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31276. /**
  31277. * Defines the hardware scaling level.
  31278. * By default the hardware scaling level is computed from the window device ratio.
  31279. * 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.
  31280. * @param level defines the level to use
  31281. */
  31282. setHardwareScalingLevel(level: number): void;
  31283. /**
  31284. * Gets the current hardware scaling level.
  31285. * By default the hardware scaling level is computed from the window device ratio.
  31286. * 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.
  31287. * @returns a number indicating the current hardware scaling level
  31288. */
  31289. getHardwareScalingLevel(): number;
  31290. /**
  31291. * Gets the list of loaded textures
  31292. * @returns an array containing all loaded textures
  31293. */
  31294. getLoadedTexturesCache(): InternalTexture[];
  31295. /**
  31296. * Gets the object containing all engine capabilities
  31297. * @returns the EngineCapabilities object
  31298. */
  31299. getCaps(): EngineCapabilities;
  31300. /**
  31301. * Gets the current depth function
  31302. * @returns a number defining the depth function
  31303. */
  31304. getDepthFunction(): Nullable<number>;
  31305. /**
  31306. * Sets the current depth function
  31307. * @param depthFunc defines the function to use
  31308. */
  31309. setDepthFunction(depthFunc: number): void;
  31310. /**
  31311. * Sets the current depth function to GREATER
  31312. */
  31313. setDepthFunctionToGreater(): void;
  31314. /**
  31315. * Sets the current depth function to GEQUAL
  31316. */
  31317. setDepthFunctionToGreaterOrEqual(): void;
  31318. /**
  31319. * Sets the current depth function to LESS
  31320. */
  31321. setDepthFunctionToLess(): void;
  31322. private _cachedStencilBuffer;
  31323. private _cachedStencilFunction;
  31324. private _cachedStencilMask;
  31325. private _cachedStencilOperationPass;
  31326. private _cachedStencilOperationFail;
  31327. private _cachedStencilOperationDepthFail;
  31328. private _cachedStencilReference;
  31329. /**
  31330. * Caches the the state of the stencil buffer
  31331. */
  31332. cacheStencilState(): void;
  31333. /**
  31334. * Restores the state of the stencil buffer
  31335. */
  31336. restoreStencilState(): void;
  31337. /**
  31338. * Sets the current depth function to LEQUAL
  31339. */
  31340. setDepthFunctionToLessOrEqual(): void;
  31341. /**
  31342. * Gets a boolean indicating if stencil buffer is enabled
  31343. * @returns the current stencil buffer state
  31344. */
  31345. getStencilBuffer(): boolean;
  31346. /**
  31347. * Enable or disable the stencil buffer
  31348. * @param enable defines if the stencil buffer must be enabled or disabled
  31349. */
  31350. setStencilBuffer(enable: boolean): void;
  31351. /**
  31352. * Gets the current stencil mask
  31353. * @returns a number defining the new stencil mask to use
  31354. */
  31355. getStencilMask(): number;
  31356. /**
  31357. * Sets the current stencil mask
  31358. * @param mask defines the new stencil mask to use
  31359. */
  31360. setStencilMask(mask: number): void;
  31361. /**
  31362. * Gets the current stencil function
  31363. * @returns a number defining the stencil function to use
  31364. */
  31365. getStencilFunction(): number;
  31366. /**
  31367. * Gets the current stencil reference value
  31368. * @returns a number defining the stencil reference value to use
  31369. */
  31370. getStencilFunctionReference(): number;
  31371. /**
  31372. * Gets the current stencil mask
  31373. * @returns a number defining the stencil mask to use
  31374. */
  31375. getStencilFunctionMask(): number;
  31376. /**
  31377. * Sets the current stencil function
  31378. * @param stencilFunc defines the new stencil function to use
  31379. */
  31380. setStencilFunction(stencilFunc: number): void;
  31381. /**
  31382. * Sets the current stencil reference
  31383. * @param reference defines the new stencil reference to use
  31384. */
  31385. setStencilFunctionReference(reference: number): void;
  31386. /**
  31387. * Sets the current stencil mask
  31388. * @param mask defines the new stencil mask to use
  31389. */
  31390. setStencilFunctionMask(mask: number): void;
  31391. /**
  31392. * Gets the current stencil operation when stencil fails
  31393. * @returns a number defining stencil operation to use when stencil fails
  31394. */
  31395. getStencilOperationFail(): number;
  31396. /**
  31397. * Gets the current stencil operation when depth fails
  31398. * @returns a number defining stencil operation to use when depth fails
  31399. */
  31400. getStencilOperationDepthFail(): number;
  31401. /**
  31402. * Gets the current stencil operation when stencil passes
  31403. * @returns a number defining stencil operation to use when stencil passes
  31404. */
  31405. getStencilOperationPass(): number;
  31406. /**
  31407. * Sets the stencil operation to use when stencil fails
  31408. * @param operation defines the stencil operation to use when stencil fails
  31409. */
  31410. setStencilOperationFail(operation: number): void;
  31411. /**
  31412. * Sets the stencil operation to use when depth fails
  31413. * @param operation defines the stencil operation to use when depth fails
  31414. */
  31415. setStencilOperationDepthFail(operation: number): void;
  31416. /**
  31417. * Sets the stencil operation to use when stencil passes
  31418. * @param operation defines the stencil operation to use when stencil passes
  31419. */
  31420. setStencilOperationPass(operation: number): void;
  31421. /**
  31422. * Sets a boolean indicating if the dithering state is enabled or disabled
  31423. * @param value defines the dithering state
  31424. */
  31425. setDitheringState(value: boolean): void;
  31426. /**
  31427. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31428. * @param value defines the rasterizer state
  31429. */
  31430. setRasterizerState(value: boolean): void;
  31431. /**
  31432. * stop executing a render loop function and remove it from the execution array
  31433. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31434. */
  31435. stopRenderLoop(renderFunction?: () => void): void;
  31436. /** @hidden */
  31437. _renderLoop(): void;
  31438. /**
  31439. * Register and execute a render loop. The engine can have more than one render function
  31440. * @param renderFunction defines the function to continuously execute
  31441. */
  31442. runRenderLoop(renderFunction: () => void): void;
  31443. /**
  31444. * Toggle full screen mode
  31445. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31446. */
  31447. switchFullscreen(requestPointerLock: boolean): void;
  31448. /**
  31449. * Enters full screen mode
  31450. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31451. */
  31452. enterFullscreen(requestPointerLock: boolean): void;
  31453. /**
  31454. * Exits full screen mode
  31455. */
  31456. exitFullscreen(): void;
  31457. /**
  31458. * Enters Pointerlock mode
  31459. */
  31460. enterPointerlock(): void;
  31461. /**
  31462. * Exits Pointerlock mode
  31463. */
  31464. exitPointerlock(): void;
  31465. /**
  31466. * Clear the current render buffer or the current render target (if any is set up)
  31467. * @param color defines the color to use
  31468. * @param backBuffer defines if the back buffer must be cleared
  31469. * @param depth defines if the depth buffer must be cleared
  31470. * @param stencil defines if the stencil buffer must be cleared
  31471. */
  31472. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31473. /**
  31474. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31475. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31476. * @param y defines the y-coordinate of the corner of the clear rectangle
  31477. * @param width defines the width of the clear rectangle
  31478. * @param height defines the height of the clear rectangle
  31479. * @param clearColor defines the clear color
  31480. */
  31481. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31482. /**
  31483. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31484. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31485. * @param y defines the y-coordinate of the corner of the clear rectangle
  31486. * @param width defines the width of the clear rectangle
  31487. * @param height defines the height of the clear rectangle
  31488. */
  31489. enableScissor(x: number, y: number, width: number, height: number): void;
  31490. /**
  31491. * Disable previously set scissor test rectangle
  31492. */
  31493. disableScissor(): void;
  31494. private _viewportCached;
  31495. /** @hidden */
  31496. _viewport(x: number, y: number, width: number, height: number): void;
  31497. /**
  31498. * Set the WebGL's viewport
  31499. * @param viewport defines the viewport element to be used
  31500. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31501. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31502. */
  31503. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31504. /**
  31505. * Directly set the WebGL Viewport
  31506. * @param x defines the x coordinate of the viewport (in screen space)
  31507. * @param y defines the y coordinate of the viewport (in screen space)
  31508. * @param width defines the width of the viewport (in screen space)
  31509. * @param height defines the height of the viewport (in screen space)
  31510. * @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
  31511. */
  31512. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31513. /**
  31514. * Begin a new frame
  31515. */
  31516. beginFrame(): void;
  31517. /**
  31518. * Enf the current frame
  31519. */
  31520. endFrame(): void;
  31521. /**
  31522. * Resize the view according to the canvas' size
  31523. */
  31524. resize(): void;
  31525. /**
  31526. * Force a specific size of the canvas
  31527. * @param width defines the new canvas' width
  31528. * @param height defines the new canvas' height
  31529. */
  31530. setSize(width: number, height: number): void;
  31531. /**
  31532. * Binds the frame buffer to the specified texture.
  31533. * @param texture The texture to render to or null for the default canvas
  31534. * @param faceIndex The face of the texture to render to in case of cube texture
  31535. * @param requiredWidth The width of the target to render to
  31536. * @param requiredHeight The height of the target to render to
  31537. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31538. * @param depthStencilTexture The depth stencil texture to use to render
  31539. * @param lodLevel defines le lod level to bind to the frame buffer
  31540. */
  31541. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31542. /** @hidden */
  31543. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31544. /**
  31545. * Unbind the current render target texture from the webGL context
  31546. * @param texture defines the render target texture to unbind
  31547. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31548. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31549. */
  31550. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31551. /**
  31552. * Force the mipmap generation for the given render target texture
  31553. * @param texture defines the render target texture to use
  31554. */
  31555. generateMipMapsForCubemap(texture: InternalTexture): void;
  31556. /**
  31557. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31558. */
  31559. flushFramebuffer(): void;
  31560. /**
  31561. * Unbind the current render target and bind the default framebuffer
  31562. */
  31563. restoreDefaultFramebuffer(): void;
  31564. /**
  31565. * Create an uniform buffer
  31566. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31567. * @param elements defines the content of the uniform buffer
  31568. * @returns the webGL uniform buffer
  31569. */
  31570. createUniformBuffer(elements: FloatArray): DataBuffer;
  31571. /**
  31572. * Create a dynamic uniform buffer
  31573. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31574. * @param elements defines the content of the uniform buffer
  31575. * @returns the webGL uniform buffer
  31576. */
  31577. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31578. /**
  31579. * Update an existing uniform buffer
  31580. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31581. * @param uniformBuffer defines the target uniform buffer
  31582. * @param elements defines the content to update
  31583. * @param offset defines the offset in the uniform buffer where update should start
  31584. * @param count defines the size of the data to update
  31585. */
  31586. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31587. private _resetVertexBufferBinding;
  31588. /**
  31589. * Creates a vertex buffer
  31590. * @param data the data for the vertex buffer
  31591. * @returns the new WebGL static buffer
  31592. */
  31593. createVertexBuffer(data: DataArray): DataBuffer;
  31594. /**
  31595. * Creates a dynamic vertex buffer
  31596. * @param data the data for the dynamic vertex buffer
  31597. * @returns the new WebGL dynamic buffer
  31598. */
  31599. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31600. /**
  31601. * Update a dynamic index buffer
  31602. * @param indexBuffer defines the target index buffer
  31603. * @param indices defines the data to update
  31604. * @param offset defines the offset in the target index buffer where update should start
  31605. */
  31606. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31607. /**
  31608. * Updates a dynamic vertex buffer.
  31609. * @param vertexBuffer the vertex buffer to update
  31610. * @param data the data used to update the vertex buffer
  31611. * @param byteOffset the byte offset of the data
  31612. * @param byteLength the byte length of the data
  31613. */
  31614. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31615. private _resetIndexBufferBinding;
  31616. /**
  31617. * Creates a new index buffer
  31618. * @param indices defines the content of the index buffer
  31619. * @param updatable defines if the index buffer must be updatable
  31620. * @returns a new webGL buffer
  31621. */
  31622. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31623. /**
  31624. * Bind a webGL buffer to the webGL context
  31625. * @param buffer defines the buffer to bind
  31626. */
  31627. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31628. /**
  31629. * Bind an uniform buffer to the current webGL context
  31630. * @param buffer defines the buffer to bind
  31631. */
  31632. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31633. /**
  31634. * Bind a buffer to the current webGL context at a given location
  31635. * @param buffer defines the buffer to bind
  31636. * @param location defines the index where to bind the buffer
  31637. */
  31638. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31639. /**
  31640. * Bind a specific block at a given index in a specific shader program
  31641. * @param pipelineContext defines the pipeline context to use
  31642. * @param blockName defines the block name
  31643. * @param index defines the index where to bind the block
  31644. */
  31645. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31646. private bindIndexBuffer;
  31647. private bindBuffer;
  31648. /**
  31649. * update the bound buffer with the given data
  31650. * @param data defines the data to update
  31651. */
  31652. updateArrayBuffer(data: Float32Array): void;
  31653. private _vertexAttribPointer;
  31654. private _bindIndexBufferWithCache;
  31655. private _bindVertexBuffersAttributes;
  31656. /**
  31657. * Records a vertex array object
  31658. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31659. * @param vertexBuffers defines the list of vertex buffers to store
  31660. * @param indexBuffer defines the index buffer to store
  31661. * @param effect defines the effect to store
  31662. * @returns the new vertex array object
  31663. */
  31664. recordVertexArrayObject(vertexBuffers: {
  31665. [key: string]: VertexBuffer;
  31666. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31667. /**
  31668. * Bind a specific vertex array object
  31669. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31670. * @param vertexArrayObject defines the vertex array object to bind
  31671. * @param indexBuffer defines the index buffer to bind
  31672. */
  31673. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31674. /**
  31675. * Bind webGl buffers directly to the webGL context
  31676. * @param vertexBuffer defines the vertex buffer to bind
  31677. * @param indexBuffer defines the index buffer to bind
  31678. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31679. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31680. * @param effect defines the effect associated with the vertex buffer
  31681. */
  31682. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31683. private _unbindVertexArrayObject;
  31684. /**
  31685. * Bind a list of vertex buffers to the webGL context
  31686. * @param vertexBuffers defines the list of vertex buffers to bind
  31687. * @param indexBuffer defines the index buffer to bind
  31688. * @param effect defines the effect associated with the vertex buffers
  31689. */
  31690. bindBuffers(vertexBuffers: {
  31691. [key: string]: Nullable<VertexBuffer>;
  31692. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31693. /**
  31694. * Unbind all instance attributes
  31695. */
  31696. unbindInstanceAttributes(): void;
  31697. /**
  31698. * Release and free the memory of a vertex array object
  31699. * @param vao defines the vertex array object to delete
  31700. */
  31701. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31702. /** @hidden */
  31703. _releaseBuffer(buffer: DataBuffer): boolean;
  31704. /**
  31705. * Creates a webGL buffer to use with instanciation
  31706. * @param capacity defines the size of the buffer
  31707. * @returns the webGL buffer
  31708. */
  31709. createInstancesBuffer(capacity: number): DataBuffer;
  31710. /**
  31711. * Delete a webGL buffer used with instanciation
  31712. * @param buffer defines the webGL buffer to delete
  31713. */
  31714. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31715. /**
  31716. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31717. * @param instancesBuffer defines the webGL buffer to update and bind
  31718. * @param data defines the data to store in the buffer
  31719. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31720. */
  31721. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31722. /**
  31723. * Apply all cached states (depth, culling, stencil and alpha)
  31724. */
  31725. applyStates(): void;
  31726. /**
  31727. * Send a draw order
  31728. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31729. * @param indexStart defines the starting index
  31730. * @param indexCount defines the number of index to draw
  31731. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31732. */
  31733. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31734. /**
  31735. * Draw a list of points
  31736. * @param verticesStart defines the index of first vertex to draw
  31737. * @param verticesCount defines the count of vertices to draw
  31738. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31739. */
  31740. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31741. /**
  31742. * Draw a list of unindexed primitives
  31743. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31744. * @param verticesStart defines the index of first vertex to draw
  31745. * @param verticesCount defines the count of vertices to draw
  31746. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31747. */
  31748. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31749. /**
  31750. * Draw a list of indexed primitives
  31751. * @param fillMode defines the primitive to use
  31752. * @param indexStart defines the starting index
  31753. * @param indexCount defines the number of index to draw
  31754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31755. */
  31756. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31757. /**
  31758. * Draw a list of unindexed primitives
  31759. * @param fillMode defines the primitive to use
  31760. * @param verticesStart defines the index of first vertex to draw
  31761. * @param verticesCount defines the count of vertices to draw
  31762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31763. */
  31764. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31765. private _drawMode;
  31766. /** @hidden */
  31767. _releaseEffect(effect: Effect): void;
  31768. /** @hidden */
  31769. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31770. /**
  31771. * Create a new effect (used to store vertex/fragment shaders)
  31772. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31773. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31774. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31775. * @param samplers defines an array of string used to represent textures
  31776. * @param defines defines the string containing the defines to use to compile the shaders
  31777. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31778. * @param onCompiled defines a function to call when the effect creation is successful
  31779. * @param onError defines a function to call when the effect creation has failed
  31780. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31781. * @returns the new Effect
  31782. */
  31783. 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;
  31784. private _compileShader;
  31785. private _compileRawShader;
  31786. /**
  31787. * Directly creates a webGL program
  31788. * @param pipelineContext defines the pipeline context to attach to
  31789. * @param vertexCode defines the vertex shader code to use
  31790. * @param fragmentCode defines the fragment shader code to use
  31791. * @param context defines the webGL context to use (if not set, the current one will be used)
  31792. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31793. * @returns the new webGL program
  31794. */
  31795. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31796. /**
  31797. * Creates a webGL program
  31798. * @param pipelineContext defines the pipeline context to attach to
  31799. * @param vertexCode defines the vertex shader code to use
  31800. * @param fragmentCode defines the fragment shader code to use
  31801. * @param defines defines the string containing the defines to use to compile the shaders
  31802. * @param context defines the webGL context to use (if not set, the current one will be used)
  31803. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31804. * @returns the new webGL program
  31805. */
  31806. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31807. /**
  31808. * Creates a new pipeline context
  31809. * @returns the new pipeline
  31810. */
  31811. createPipelineContext(): WebGLPipelineContext;
  31812. private _createShaderProgram;
  31813. private _finalizePipelineContext;
  31814. /** @hidden */
  31815. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31816. /** @hidden */
  31817. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31818. /** @hidden */
  31819. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31820. /**
  31821. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31822. * @param pipelineContext defines the pipeline context to use
  31823. * @param uniformsNames defines the list of uniform names
  31824. * @returns an array of webGL uniform locations
  31825. */
  31826. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31827. /**
  31828. * Gets the lsit of active attributes for a given webGL program
  31829. * @param pipelineContext defines the pipeline context to use
  31830. * @param attributesNames defines the list of attribute names to get
  31831. * @returns an array of indices indicating the offset of each attribute
  31832. */
  31833. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31834. /**
  31835. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31836. * @param effect defines the effect to activate
  31837. */
  31838. enableEffect(effect: Nullable<Effect>): void;
  31839. /**
  31840. * Set the value of an uniform to an array of int32
  31841. * @param uniform defines the webGL uniform location where to store the value
  31842. * @param array defines the array of int32 to store
  31843. */
  31844. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31845. /**
  31846. * Set the value of an uniform to an array of int32 (stored as vec2)
  31847. * @param uniform defines the webGL uniform location where to store the value
  31848. * @param array defines the array of int32 to store
  31849. */
  31850. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31851. /**
  31852. * Set the value of an uniform to an array of int32 (stored as vec3)
  31853. * @param uniform defines the webGL uniform location where to store the value
  31854. * @param array defines the array of int32 to store
  31855. */
  31856. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31857. /**
  31858. * Set the value of an uniform to an array of int32 (stored as vec4)
  31859. * @param uniform defines the webGL uniform location where to store the value
  31860. * @param array defines the array of int32 to store
  31861. */
  31862. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31863. /**
  31864. * Set the value of an uniform to an array of float32
  31865. * @param uniform defines the webGL uniform location where to store the value
  31866. * @param array defines the array of float32 to store
  31867. */
  31868. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31869. /**
  31870. * Set the value of an uniform to an array of float32 (stored as vec2)
  31871. * @param uniform defines the webGL uniform location where to store the value
  31872. * @param array defines the array of float32 to store
  31873. */
  31874. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31875. /**
  31876. * Set the value of an uniform to an array of float32 (stored as vec3)
  31877. * @param uniform defines the webGL uniform location where to store the value
  31878. * @param array defines the array of float32 to store
  31879. */
  31880. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31881. /**
  31882. * Set the value of an uniform to an array of float32 (stored as vec4)
  31883. * @param uniform defines the webGL uniform location where to store the value
  31884. * @param array defines the array of float32 to store
  31885. */
  31886. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31887. /**
  31888. * Set the value of an uniform to an array of number
  31889. * @param uniform defines the webGL uniform location where to store the value
  31890. * @param array defines the array of number to store
  31891. */
  31892. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31893. /**
  31894. * Set the value of an uniform to an array of number (stored as vec2)
  31895. * @param uniform defines the webGL uniform location where to store the value
  31896. * @param array defines the array of number to store
  31897. */
  31898. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31899. /**
  31900. * Set the value of an uniform to an array of number (stored as vec3)
  31901. * @param uniform defines the webGL uniform location where to store the value
  31902. * @param array defines the array of number to store
  31903. */
  31904. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31905. /**
  31906. * Set the value of an uniform to an array of number (stored as vec4)
  31907. * @param uniform defines the webGL uniform location where to store the value
  31908. * @param array defines the array of number to store
  31909. */
  31910. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31911. /**
  31912. * Set the value of an uniform to an array of float32 (stored as matrices)
  31913. * @param uniform defines the webGL uniform location where to store the value
  31914. * @param matrices defines the array of float32 to store
  31915. */
  31916. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31917. /**
  31918. * Set the value of an uniform to a matrix (3x3)
  31919. * @param uniform defines the webGL uniform location where to store the value
  31920. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31921. */
  31922. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31923. /**
  31924. * Set the value of an uniform to a matrix (2x2)
  31925. * @param uniform defines the webGL uniform location where to store the value
  31926. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31927. */
  31928. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31929. /**
  31930. * Set the value of an uniform to a number (int)
  31931. * @param uniform defines the webGL uniform location where to store the value
  31932. * @param value defines the int number to store
  31933. */
  31934. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31935. /**
  31936. * Set the value of an uniform to a number (float)
  31937. * @param uniform defines the webGL uniform location where to store the value
  31938. * @param value defines the float number to store
  31939. */
  31940. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31941. /**
  31942. * Set the value of an uniform to a vec2
  31943. * @param uniform defines the webGL uniform location where to store the value
  31944. * @param x defines the 1st component of the value
  31945. * @param y defines the 2nd component of the value
  31946. */
  31947. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31948. /**
  31949. * Set the value of an uniform to a vec3
  31950. * @param uniform defines the webGL uniform location where to store the value
  31951. * @param x defines the 1st component of the value
  31952. * @param y defines the 2nd component of the value
  31953. * @param z defines the 3rd component of the value
  31954. */
  31955. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31956. /**
  31957. * Set the value of an uniform to a boolean
  31958. * @param uniform defines the webGL uniform location where to store the value
  31959. * @param bool defines the boolean to store
  31960. */
  31961. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31962. /**
  31963. * Set the value of an uniform to a vec4
  31964. * @param uniform defines the webGL uniform location where to store the value
  31965. * @param x defines the 1st component of the value
  31966. * @param y defines the 2nd component of the value
  31967. * @param z defines the 3rd component of the value
  31968. * @param w defines the 4th component of the value
  31969. */
  31970. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31971. /**
  31972. * Sets a Color4 on a uniform variable
  31973. * @param uniform defines the uniform location
  31974. * @param color4 defines the value to be set
  31975. */
  31976. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31977. /**
  31978. * Set various states to the webGL context
  31979. * @param culling defines backface culling state
  31980. * @param zOffset defines the value to apply to zOffset (0 by default)
  31981. * @param force defines if states must be applied even if cache is up to date
  31982. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31983. */
  31984. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31985. /**
  31986. * Set the z offset to apply to current rendering
  31987. * @param value defines the offset to apply
  31988. */
  31989. setZOffset(value: number): void;
  31990. /**
  31991. * Gets the current value of the zOffset
  31992. * @returns the current zOffset state
  31993. */
  31994. getZOffset(): number;
  31995. /**
  31996. * Enable or disable depth buffering
  31997. * @param enable defines the state to set
  31998. */
  31999. setDepthBuffer(enable: boolean): void;
  32000. /**
  32001. * Gets a boolean indicating if depth writing is enabled
  32002. * @returns the current depth writing state
  32003. */
  32004. getDepthWrite(): boolean;
  32005. /**
  32006. * Enable or disable depth writing
  32007. * @param enable defines the state to set
  32008. */
  32009. setDepthWrite(enable: boolean): void;
  32010. /**
  32011. * Enable or disable color writing
  32012. * @param enable defines the state to set
  32013. */
  32014. setColorWrite(enable: boolean): void;
  32015. /**
  32016. * Gets a boolean indicating if color writing is enabled
  32017. * @returns the current color writing state
  32018. */
  32019. getColorWrite(): boolean;
  32020. /**
  32021. * Sets alpha constants used by some alpha blending modes
  32022. * @param r defines the red component
  32023. * @param g defines the green component
  32024. * @param b defines the blue component
  32025. * @param a defines the alpha component
  32026. */
  32027. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32028. /**
  32029. * Sets the current alpha mode
  32030. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32031. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32032. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32033. */
  32034. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32035. /**
  32036. * Gets the current alpha mode
  32037. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32038. * @returns the current alpha mode
  32039. */
  32040. getAlphaMode(): number;
  32041. /**
  32042. * Clears the list of texture accessible through engine.
  32043. * This can help preventing texture load conflict due to name collision.
  32044. */
  32045. clearInternalTexturesCache(): void;
  32046. /**
  32047. * Force the entire cache to be cleared
  32048. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32049. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32050. */
  32051. wipeCaches(bruteForce?: boolean): void;
  32052. /**
  32053. * Set the compressed texture format to use, based on the formats you have, and the formats
  32054. * supported by the hardware / browser.
  32055. *
  32056. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32057. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32058. * to API arguments needed to compressed textures. This puts the burden on the container
  32059. * generator to house the arcane code for determining these for current & future formats.
  32060. *
  32061. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32062. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32063. *
  32064. * Note: The result of this call is not taken into account when a texture is base64.
  32065. *
  32066. * @param formatsAvailable defines the list of those format families you have created
  32067. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32068. *
  32069. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32070. * @returns The extension selected.
  32071. */
  32072. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32073. /** @hidden */
  32074. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32075. min: number;
  32076. mag: number;
  32077. };
  32078. /** @hidden */
  32079. _createTexture(): WebGLTexture;
  32080. /**
  32081. * Usually called from Texture.ts.
  32082. * Passed information to create a WebGLTexture
  32083. * @param urlArg defines a value which contains one of the following:
  32084. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32085. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32086. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32087. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32088. * @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)
  32089. * @param scene needed for loading to the correct scene
  32090. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32091. * @param onLoad optional callback to be called upon successful completion
  32092. * @param onError optional callback to be called upon failure
  32093. * @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
  32094. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32095. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32096. * @param forcedExtension defines the extension to use to pick the right loader
  32097. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32098. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32099. */
  32100. 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;
  32101. /**
  32102. * @hidden
  32103. * Rescales a texture
  32104. * @param source input texutre
  32105. * @param destination destination texture
  32106. * @param scene scene to use to render the resize
  32107. * @param internalFormat format to use when resizing
  32108. * @param onComplete callback to be called when resize has completed
  32109. */
  32110. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32111. private _unpackFlipYCached;
  32112. /**
  32113. * In case you are sharing the context with other applications, it might
  32114. * be interested to not cache the unpack flip y state to ensure a consistent
  32115. * value would be set.
  32116. */
  32117. enableUnpackFlipYCached: boolean;
  32118. /** @hidden */
  32119. _unpackFlipY(value: boolean): void;
  32120. /** @hidden */
  32121. _getUnpackAlignement(): number;
  32122. /**
  32123. * Creates a dynamic texture
  32124. * @param width defines the width of the texture
  32125. * @param height defines the height of the texture
  32126. * @param generateMipMaps defines if the engine should generate the mip levels
  32127. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32128. * @returns the dynamic texture inside an InternalTexture
  32129. */
  32130. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32131. /**
  32132. * Update the sampling mode of a given texture
  32133. * @param samplingMode defines the required sampling mode
  32134. * @param texture defines the texture to update
  32135. */
  32136. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32137. /**
  32138. * Update the content of a dynamic texture
  32139. * @param texture defines the texture to update
  32140. * @param canvas defines the canvas containing the source
  32141. * @param invertY defines if data must be stored with Y axis inverted
  32142. * @param premulAlpha defines if alpha is stored as premultiplied
  32143. * @param format defines the format of the data
  32144. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32145. */
  32146. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32147. /**
  32148. * Update a video texture
  32149. * @param texture defines the texture to update
  32150. * @param video defines the video element to use
  32151. * @param invertY defines if data must be stored with Y axis inverted
  32152. */
  32153. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32154. /**
  32155. * Updates a depth texture Comparison Mode and Function.
  32156. * If the comparison Function is equal to 0, the mode will be set to none.
  32157. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32158. * @param texture The texture to set the comparison function for
  32159. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32160. */
  32161. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32162. /** @hidden */
  32163. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32164. width: number;
  32165. height: number;
  32166. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32167. /**
  32168. * Creates a depth stencil texture.
  32169. * This is only available in WebGL 2 or with the depth texture extension available.
  32170. * @param size The size of face edge in the texture.
  32171. * @param options The options defining the texture.
  32172. * @returns The texture
  32173. */
  32174. createDepthStencilTexture(size: number | {
  32175. width: number;
  32176. height: number;
  32177. }, options: DepthTextureCreationOptions): InternalTexture;
  32178. /**
  32179. * Creates a depth stencil texture.
  32180. * This is only available in WebGL 2 or with the depth texture extension available.
  32181. * @param size The size of face edge in the texture.
  32182. * @param options The options defining the texture.
  32183. * @returns The texture
  32184. */
  32185. private _createDepthStencilTexture;
  32186. /**
  32187. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32188. * @param renderTarget The render target to set the frame buffer for
  32189. */
  32190. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32191. /**
  32192. * Creates a new render target texture
  32193. * @param size defines the size of the texture
  32194. * @param options defines the options used to create the texture
  32195. * @returns a new render target texture stored in an InternalTexture
  32196. */
  32197. createRenderTargetTexture(size: number | {
  32198. width: number;
  32199. height: number;
  32200. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32201. /** @hidden */
  32202. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32203. /**
  32204. * Updates the sample count of a render target texture
  32205. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32206. * @param texture defines the texture to update
  32207. * @param samples defines the sample count to set
  32208. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32209. */
  32210. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32211. /** @hidden */
  32212. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32213. /** @hidden */
  32214. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32215. /** @hidden */
  32216. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32217. /** @hidden */
  32218. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32219. /**
  32220. * @hidden
  32221. */
  32222. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32223. private _prepareWebGLTextureContinuation;
  32224. private _prepareWebGLTexture;
  32225. /** @hidden */
  32226. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32227. /** @hidden */
  32228. _releaseFramebufferObjects(texture: InternalTexture): void;
  32229. /** @hidden */
  32230. _releaseTexture(texture: InternalTexture): void;
  32231. private setProgram;
  32232. private _boundUniforms;
  32233. /**
  32234. * Binds an effect to the webGL context
  32235. * @param effect defines the effect to bind
  32236. */
  32237. bindSamplers(effect: Effect): void;
  32238. private _activateCurrentTexture;
  32239. /** @hidden */
  32240. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32241. /** @hidden */
  32242. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32243. /**
  32244. * Sets a texture to the webGL context from a postprocess
  32245. * @param channel defines the channel to use
  32246. * @param postProcess defines the source postprocess
  32247. */
  32248. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32249. /**
  32250. * Binds the output of the passed in post process to the texture channel specified
  32251. * @param channel The channel the texture should be bound to
  32252. * @param postProcess The post process which's output should be bound
  32253. */
  32254. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32255. /**
  32256. * Unbind all textures from the webGL context
  32257. */
  32258. unbindAllTextures(): void;
  32259. /**
  32260. * Sets a texture to the according uniform.
  32261. * @param channel The texture channel
  32262. * @param uniform The uniform to set
  32263. * @param texture The texture to apply
  32264. */
  32265. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32266. /**
  32267. * Sets a depth stencil texture from a render target to the according uniform.
  32268. * @param channel The texture channel
  32269. * @param uniform The uniform to set
  32270. * @param texture The render target texture containing the depth stencil texture to apply
  32271. */
  32272. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32273. private _bindSamplerUniformToChannel;
  32274. private _getTextureWrapMode;
  32275. private _setTexture;
  32276. /**
  32277. * Sets an array of texture to the webGL context
  32278. * @param channel defines the channel where the texture array must be set
  32279. * @param uniform defines the associated uniform location
  32280. * @param textures defines the array of textures to bind
  32281. */
  32282. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32283. /** @hidden */
  32284. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32285. private _setTextureParameterFloat;
  32286. private _setTextureParameterInteger;
  32287. /**
  32288. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32289. * @param x defines the x coordinate of the rectangle where pixels must be read
  32290. * @param y defines the y coordinate of the rectangle where pixels must be read
  32291. * @param width defines the width of the rectangle where pixels must be read
  32292. * @param height defines the height of the rectangle where pixels must be read
  32293. * @returns a Uint8Array containing RGBA colors
  32294. */
  32295. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32296. /**
  32297. * Add an externaly attached data from its key.
  32298. * This method call will fail and return false, if such key already exists.
  32299. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32300. * @param key the unique key that identifies the data
  32301. * @param data the data object to associate to the key for this Engine instance
  32302. * @return true if no such key were already present and the data was added successfully, false otherwise
  32303. */
  32304. addExternalData<T>(key: string, data: T): boolean;
  32305. /**
  32306. * Get an externaly attached data from its key
  32307. * @param key the unique key that identifies the data
  32308. * @return the associated data, if present (can be null), or undefined if not present
  32309. */
  32310. getExternalData<T>(key: string): T;
  32311. /**
  32312. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32313. * @param key the unique key that identifies the data
  32314. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32315. * @return the associated data, can be null if the factory returned null.
  32316. */
  32317. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32318. /**
  32319. * Remove an externaly attached data from the Engine instance
  32320. * @param key the unique key that identifies the data
  32321. * @return true if the data was successfully removed, false if it doesn't exist
  32322. */
  32323. removeExternalData(key: string): boolean;
  32324. /**
  32325. * Unbind all vertex attributes from the webGL context
  32326. */
  32327. unbindAllAttributes(): void;
  32328. /**
  32329. * 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
  32330. */
  32331. releaseEffects(): void;
  32332. /**
  32333. * Dispose and release all associated resources
  32334. */
  32335. dispose(): void;
  32336. /**
  32337. * Display the loading screen
  32338. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32339. */
  32340. displayLoadingUI(): void;
  32341. /**
  32342. * Hide the loading screen
  32343. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32344. */
  32345. hideLoadingUI(): void;
  32346. /**
  32347. * Gets the current loading screen object
  32348. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32349. */
  32350. /**
  32351. * Sets the current loading screen object
  32352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32353. */
  32354. loadingScreen: ILoadingScreen;
  32355. /**
  32356. * Sets the current loading screen text
  32357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32358. */
  32359. loadingUIText: string;
  32360. /**
  32361. * Sets the current loading screen background color
  32362. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32363. */
  32364. loadingUIBackgroundColor: string;
  32365. /**
  32366. * Attach a new callback raised when context lost event is fired
  32367. * @param callback defines the callback to call
  32368. */
  32369. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32370. /**
  32371. * Attach a new callback raised when context restored event is fired
  32372. * @param callback defines the callback to call
  32373. */
  32374. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32375. /**
  32376. * Gets the source code of the vertex shader associated with a specific webGL program
  32377. * @param program defines the program to use
  32378. * @returns a string containing the source code of the vertex shader associated with the program
  32379. */
  32380. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32381. /**
  32382. * Gets the source code of the fragment shader associated with a specific webGL program
  32383. * @param program defines the program to use
  32384. * @returns a string containing the source code of the fragment shader associated with the program
  32385. */
  32386. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32387. /**
  32388. * Get the current error code of the webGL context
  32389. * @returns the error code
  32390. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32391. */
  32392. getError(): number;
  32393. /**
  32394. * Gets the current framerate
  32395. * @returns a number representing the framerate
  32396. */
  32397. getFps(): number;
  32398. /**
  32399. * Gets the time spent between current and previous frame
  32400. * @returns a number representing the delta time in ms
  32401. */
  32402. getDeltaTime(): number;
  32403. private _measureFps;
  32404. /** @hidden */
  32405. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32406. private _canRenderToFloatFramebuffer;
  32407. private _canRenderToHalfFloatFramebuffer;
  32408. private _canRenderToFramebuffer;
  32409. /** @hidden */
  32410. _getWebGLTextureType(type: number): number;
  32411. /** @hidden */
  32412. _getInternalFormat(format: number): number;
  32413. /** @hidden */
  32414. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32415. /** @hidden */
  32416. _getRGBAMultiSampleBufferFormat(type: number): number;
  32417. /** @hidden */
  32418. _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;
  32419. /** @hidden */
  32420. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32421. /**
  32422. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32423. * @returns true if the engine can be created
  32424. * @ignorenaming
  32425. */
  32426. static isSupported(): boolean;
  32427. /**
  32428. * Find the next highest power of two.
  32429. * @param x Number to start search from.
  32430. * @return Next highest power of two.
  32431. */
  32432. static CeilingPOT(x: number): number;
  32433. /**
  32434. * Find the next lowest power of two.
  32435. * @param x Number to start search from.
  32436. * @return Next lowest power of two.
  32437. */
  32438. static FloorPOT(x: number): number;
  32439. /**
  32440. * Find the nearest power of two.
  32441. * @param x Number to start search from.
  32442. * @return Next nearest power of two.
  32443. */
  32444. static NearestPOT(x: number): number;
  32445. /**
  32446. * Get the closest exponent of two
  32447. * @param value defines the value to approximate
  32448. * @param max defines the maximum value to return
  32449. * @param mode defines how to define the closest value
  32450. * @returns closest exponent of two of the given value
  32451. */
  32452. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32453. /**
  32454. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32455. * @param func - the function to be called
  32456. * @param requester - the object that will request the next frame. Falls back to window.
  32457. * @returns frame number
  32458. */
  32459. static QueueNewFrame(func: () => void, requester?: any): number;
  32460. /**
  32461. * Ask the browser to promote the current element to pointerlock mode
  32462. * @param element defines the DOM element to promote
  32463. */
  32464. static _RequestPointerlock(element: HTMLElement): void;
  32465. /**
  32466. * Asks the browser to exit pointerlock mode
  32467. */
  32468. static _ExitPointerlock(): void;
  32469. /**
  32470. * Ask the browser to promote the current element to fullscreen rendering mode
  32471. * @param element defines the DOM element to promote
  32472. */
  32473. static _RequestFullscreen(element: HTMLElement): void;
  32474. /**
  32475. * Asks the browser to exit fullscreen mode
  32476. */
  32477. static _ExitFullscreen(): void;
  32478. }
  32479. }
  32480. declare module "babylonjs/Engines/engineStore" {
  32481. import { Nullable } from "babylonjs/types";
  32482. import { Engine } from "babylonjs/Engines/engine";
  32483. import { Scene } from "babylonjs/scene";
  32484. /**
  32485. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32486. * during the life time of the application.
  32487. */
  32488. export class EngineStore {
  32489. /** Gets the list of created engines */
  32490. static Instances: import("babylonjs/Engines/engine").Engine[];
  32491. /** @hidden */
  32492. static _LastCreatedScene: Nullable<Scene>;
  32493. /**
  32494. * Gets the latest created engine
  32495. */
  32496. static readonly LastCreatedEngine: Nullable<Engine>;
  32497. /**
  32498. * Gets the latest created scene
  32499. */
  32500. static readonly LastCreatedScene: Nullable<Scene>;
  32501. /**
  32502. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32503. * @ignorenaming
  32504. */
  32505. static UseFallbackTexture: boolean;
  32506. /**
  32507. * Texture content used if a texture cannot loaded
  32508. * @ignorenaming
  32509. */
  32510. static FallbackTexture: string;
  32511. }
  32512. }
  32513. declare module "babylonjs/Misc/promise" {
  32514. /**
  32515. * Helper class that provides a small promise polyfill
  32516. */
  32517. export class PromisePolyfill {
  32518. /**
  32519. * Static function used to check if the polyfill is required
  32520. * If this is the case then the function will inject the polyfill to window.Promise
  32521. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32522. */
  32523. static Apply(force?: boolean): void;
  32524. }
  32525. }
  32526. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32527. /**
  32528. * Interface for screenshot methods with describe argument called `size` as object with options
  32529. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32530. */
  32531. export interface IScreenshotSize {
  32532. /**
  32533. * number in pixels for canvas height
  32534. */
  32535. height?: number;
  32536. /**
  32537. * multiplier allowing render at a higher or lower resolution
  32538. * If value is defined then height and width will be ignored and taken from camera
  32539. */
  32540. precision?: number;
  32541. /**
  32542. * number in pixels for canvas width
  32543. */
  32544. width?: number;
  32545. }
  32546. }
  32547. declare module "babylonjs/Misc/tools" {
  32548. import { Nullable, float } from "babylonjs/types";
  32549. import { DomManagement } from "babylonjs/Misc/domManagement";
  32550. import { WebRequest } from "babylonjs/Misc/webRequest";
  32551. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32552. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32553. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32554. import { Camera } from "babylonjs/Cameras/camera";
  32555. import { Engine } from "babylonjs/Engines/engine";
  32556. interface IColor4Like {
  32557. r: float;
  32558. g: float;
  32559. b: float;
  32560. a: float;
  32561. }
  32562. /**
  32563. * Class containing a set of static utilities functions
  32564. */
  32565. export class Tools {
  32566. /**
  32567. * Gets or sets the base URL to use to load assets
  32568. */
  32569. static BaseUrl: string;
  32570. /**
  32571. * Enable/Disable Custom HTTP Request Headers globally.
  32572. * default = false
  32573. * @see CustomRequestHeaders
  32574. */
  32575. static UseCustomRequestHeaders: boolean;
  32576. /**
  32577. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32578. * i.e. when loading files, where the server/service expects an Authorization header
  32579. */
  32580. static CustomRequestHeaders: {
  32581. [key: string]: string;
  32582. };
  32583. /**
  32584. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32585. */
  32586. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32587. /**
  32588. * Default behaviour for cors in the application.
  32589. * It can be a string if the expected behavior is identical in the entire app.
  32590. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32591. */
  32592. static CorsBehavior: string | ((url: string | string[]) => string);
  32593. /**
  32594. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32595. * @ignorenaming
  32596. */
  32597. static UseFallbackTexture: boolean;
  32598. /**
  32599. * Use this object to register external classes like custom textures or material
  32600. * to allow the laoders to instantiate them
  32601. */
  32602. static RegisteredExternalClasses: {
  32603. [key: string]: Object;
  32604. };
  32605. /**
  32606. * Texture content used if a texture cannot loaded
  32607. * @ignorenaming
  32608. */
  32609. static fallbackTexture: string;
  32610. /**
  32611. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32612. * @param u defines the coordinate on X axis
  32613. * @param v defines the coordinate on Y axis
  32614. * @param width defines the width of the source data
  32615. * @param height defines the height of the source data
  32616. * @param pixels defines the source byte array
  32617. * @param color defines the output color
  32618. */
  32619. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32620. /**
  32621. * Interpolates between a and b via alpha
  32622. * @param a The lower value (returned when alpha = 0)
  32623. * @param b The upper value (returned when alpha = 1)
  32624. * @param alpha The interpolation-factor
  32625. * @return The mixed value
  32626. */
  32627. static Mix(a: number, b: number, alpha: number): number;
  32628. /**
  32629. * Tries to instantiate a new object from a given class name
  32630. * @param className defines the class name to instantiate
  32631. * @returns the new object or null if the system was not able to do the instantiation
  32632. */
  32633. static Instantiate(className: string): any;
  32634. /**
  32635. * Provides a slice function that will work even on IE
  32636. * @param data defines the array to slice
  32637. * @param start defines the start of the data (optional)
  32638. * @param end defines the end of the data (optional)
  32639. * @returns the new sliced array
  32640. */
  32641. static Slice<T>(data: T, start?: number, end?: number): T;
  32642. /**
  32643. * Polyfill for setImmediate
  32644. * @param action defines the action to execute after the current execution block
  32645. */
  32646. static SetImmediate(action: () => void): void;
  32647. /**
  32648. * Function indicating if a number is an exponent of 2
  32649. * @param value defines the value to test
  32650. * @returns true if the value is an exponent of 2
  32651. */
  32652. static IsExponentOfTwo(value: number): boolean;
  32653. private static _tmpFloatArray;
  32654. /**
  32655. * Returns the nearest 32-bit single precision float representation of a Number
  32656. * @param value A Number. If the parameter is of a different type, it will get converted
  32657. * to a number or to NaN if it cannot be converted
  32658. * @returns number
  32659. */
  32660. static FloatRound(value: number): number;
  32661. /**
  32662. * Extracts the filename from a path
  32663. * @param path defines the path to use
  32664. * @returns the filename
  32665. */
  32666. static GetFilename(path: string): string;
  32667. /**
  32668. * Extracts the "folder" part of a path (everything before the filename).
  32669. * @param uri The URI to extract the info from
  32670. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32671. * @returns The "folder" part of the path
  32672. */
  32673. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32674. /**
  32675. * Extracts text content from a DOM element hierarchy
  32676. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32677. */
  32678. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32679. /**
  32680. * Convert an angle in radians to degrees
  32681. * @param angle defines the angle to convert
  32682. * @returns the angle in degrees
  32683. */
  32684. static ToDegrees(angle: number): number;
  32685. /**
  32686. * Convert an angle in degrees to radians
  32687. * @param angle defines the angle to convert
  32688. * @returns the angle in radians
  32689. */
  32690. static ToRadians(angle: number): number;
  32691. /**
  32692. * Encode a buffer to a base64 string
  32693. * @param buffer defines the buffer to encode
  32694. * @returns the encoded string
  32695. */
  32696. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32697. /**
  32698. * Returns an array if obj is not an array
  32699. * @param obj defines the object to evaluate as an array
  32700. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32701. * @returns either obj directly if obj is an array or a new array containing obj
  32702. */
  32703. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32704. /**
  32705. * Gets the pointer prefix to use
  32706. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32707. */
  32708. static GetPointerPrefix(): string;
  32709. /**
  32710. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32711. * @param url define the url we are trying
  32712. * @param element define the dom element where to configure the cors policy
  32713. */
  32714. static SetCorsBehavior(url: string | string[], element: {
  32715. crossOrigin: string | null;
  32716. }): void;
  32717. /**
  32718. * Removes unwanted characters from an url
  32719. * @param url defines the url to clean
  32720. * @returns the cleaned url
  32721. */
  32722. static CleanUrl(url: string): string;
  32723. /**
  32724. * Gets or sets a function used to pre-process url before using them to load assets
  32725. */
  32726. static PreprocessUrl: (url: string) => string;
  32727. /**
  32728. * Loads an image as an HTMLImageElement.
  32729. * @param input url string, ArrayBuffer, or Blob to load
  32730. * @param onLoad callback called when the image successfully loads
  32731. * @param onError callback called when the image fails to load
  32732. * @param offlineProvider offline provider for caching
  32733. * @returns the HTMLImageElement of the loaded image
  32734. */
  32735. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32736. /**
  32737. * Loads a file
  32738. * @param url url string, ArrayBuffer, or Blob to load
  32739. * @param onSuccess callback called when the file successfully loads
  32740. * @param onProgress callback called while file is loading (if the server supports this mode)
  32741. * @param offlineProvider defines the offline provider for caching
  32742. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32743. * @param onError callback called when the file fails to load
  32744. * @returns a file request object
  32745. */
  32746. 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;
  32747. /**
  32748. * Loads a file from a url
  32749. * @param url the file url to load
  32750. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32751. */
  32752. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32753. /**
  32754. * Load a script (identified by an url). When the url returns, the
  32755. * content of this file is added into a new script element, attached to the DOM (body element)
  32756. * @param scriptUrl defines the url of the script to laod
  32757. * @param onSuccess defines the callback called when the script is loaded
  32758. * @param onError defines the callback to call if an error occurs
  32759. * @param scriptId defines the id of the script element
  32760. */
  32761. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32762. /**
  32763. * Load an asynchronous script (identified by an url). When the url returns, the
  32764. * content of this file is added into a new script element, attached to the DOM (body element)
  32765. * @param scriptUrl defines the url of the script to laod
  32766. * @param scriptId defines the id of the script element
  32767. * @returns a promise request object
  32768. */
  32769. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32770. /**
  32771. * Loads a file from a blob
  32772. * @param fileToLoad defines the blob to use
  32773. * @param callback defines the callback to call when data is loaded
  32774. * @param progressCallback defines the callback to call during loading process
  32775. * @returns a file request object
  32776. */
  32777. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32778. /**
  32779. * Loads a file
  32780. * @param fileToLoad defines the file to load
  32781. * @param callback defines the callback to call when data is loaded
  32782. * @param progressCallBack defines the callback to call during loading process
  32783. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32784. * @returns a file request object
  32785. */
  32786. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32787. /**
  32788. * Creates a data url from a given string content
  32789. * @param content defines the content to convert
  32790. * @returns the new data url link
  32791. */
  32792. static FileAsURL(content: string): string;
  32793. /**
  32794. * Format the given number to a specific decimal format
  32795. * @param value defines the number to format
  32796. * @param decimals defines the number of decimals to use
  32797. * @returns the formatted string
  32798. */
  32799. static Format(value: number, decimals?: number): string;
  32800. /**
  32801. * Tries to copy an object by duplicating every property
  32802. * @param source defines the source object
  32803. * @param destination defines the target object
  32804. * @param doNotCopyList defines a list of properties to avoid
  32805. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32806. */
  32807. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32808. /**
  32809. * Gets a boolean indicating if the given object has no own property
  32810. * @param obj defines the object to test
  32811. * @returns true if object has no own property
  32812. */
  32813. static IsEmpty(obj: any): boolean;
  32814. /**
  32815. * Function used to register events at window level
  32816. * @param windowElement defines the Window object to use
  32817. * @param events defines the events to register
  32818. */
  32819. static RegisterTopRootEvents(windowElement: Window, events: {
  32820. name: string;
  32821. handler: Nullable<(e: FocusEvent) => any>;
  32822. }[]): void;
  32823. /**
  32824. * Function used to unregister events from window level
  32825. * @param windowElement defines the Window object to use
  32826. * @param events defines the events to unregister
  32827. */
  32828. static UnregisterTopRootEvents(windowElement: Window, events: {
  32829. name: string;
  32830. handler: Nullable<(e: FocusEvent) => any>;
  32831. }[]): void;
  32832. /**
  32833. * @ignore
  32834. */
  32835. static _ScreenshotCanvas: HTMLCanvasElement;
  32836. /**
  32837. * Dumps the current bound framebuffer
  32838. * @param width defines the rendering width
  32839. * @param height defines the rendering height
  32840. * @param engine defines the hosting engine
  32841. * @param successCallback defines the callback triggered once the data are available
  32842. * @param mimeType defines the mime type of the result
  32843. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32844. */
  32845. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32846. /**
  32847. * Converts the canvas data to blob.
  32848. * This acts as a polyfill for browsers not supporting the to blob function.
  32849. * @param canvas Defines the canvas to extract the data from
  32850. * @param successCallback Defines the callback triggered once the data are available
  32851. * @param mimeType Defines the mime type of the result
  32852. */
  32853. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32854. /**
  32855. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32856. * @param successCallback defines the callback triggered once the data are available
  32857. * @param mimeType defines the mime type of the result
  32858. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32859. */
  32860. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32861. /**
  32862. * Downloads a blob in the browser
  32863. * @param blob defines the blob to download
  32864. * @param fileName defines the name of the downloaded file
  32865. */
  32866. static Download(blob: Blob, fileName: string): void;
  32867. /**
  32868. * Captures a screenshot of the current rendering
  32869. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32870. * @param engine defines the rendering engine
  32871. * @param camera defines the source camera
  32872. * @param size This parameter can be set to a single number or to an object with the
  32873. * following (optional) properties: precision, width, height. If a single number is passed,
  32874. * it will be used for both width and height. If an object is passed, the screenshot size
  32875. * will be derived from the parameters. The precision property is a multiplier allowing
  32876. * rendering at a higher or lower resolution
  32877. * @param successCallback defines the callback receives a single parameter which contains the
  32878. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32879. * src parameter of an <img> to display it
  32880. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32881. * Check your browser for supported MIME types
  32882. */
  32883. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32884. /**
  32885. * Captures a screenshot of the current rendering
  32886. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32887. * @param engine defines the rendering engine
  32888. * @param camera defines the source camera
  32889. * @param size This parameter can be set to a single number or to an object with the
  32890. * following (optional) properties: precision, width, height. If a single number is passed,
  32891. * it will be used for both width and height. If an object is passed, the screenshot size
  32892. * will be derived from the parameters. The precision property is a multiplier allowing
  32893. * rendering at a higher or lower resolution
  32894. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32895. * Check your browser for supported MIME types
  32896. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32897. * to the src parameter of an <img> to display it
  32898. */
  32899. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32900. /**
  32901. * Generates an image screenshot from the specified camera.
  32902. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32903. * @param engine The engine to use for rendering
  32904. * @param camera The camera to use for rendering
  32905. * @param size This parameter can be set to a single number or to an object with the
  32906. * following (optional) properties: precision, width, height. If a single number is passed,
  32907. * it will be used for both width and height. If an object is passed, the screenshot size
  32908. * will be derived from the parameters. The precision property is a multiplier allowing
  32909. * rendering at a higher or lower resolution
  32910. * @param successCallback The callback receives a single parameter which contains the
  32911. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32912. * src parameter of an <img> to display it
  32913. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32914. * Check your browser for supported MIME types
  32915. * @param samples Texture samples (default: 1)
  32916. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32917. * @param fileName A name for for the downloaded file.
  32918. */
  32919. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32920. /**
  32921. * Generates an image screenshot from the specified camera.
  32922. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32923. * @param engine The engine to use for rendering
  32924. * @param camera The camera to use for rendering
  32925. * @param size This parameter can be set to a single number or to an object with the
  32926. * following (optional) properties: precision, width, height. If a single number is passed,
  32927. * it will be used for both width and height. If an object is passed, the screenshot size
  32928. * will be derived from the parameters. The precision property is a multiplier allowing
  32929. * rendering at a higher or lower resolution
  32930. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32931. * Check your browser for supported MIME types
  32932. * @param samples Texture samples (default: 1)
  32933. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32934. * @param fileName A name for for the downloaded file.
  32935. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32936. * to the src parameter of an <img> to display it
  32937. */
  32938. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32939. /**
  32940. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32941. * Be aware Math.random() could cause collisions, but:
  32942. * "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"
  32943. * @returns a pseudo random id
  32944. */
  32945. static RandomId(): string;
  32946. /**
  32947. * Test if the given uri is a base64 string
  32948. * @param uri The uri to test
  32949. * @return True if the uri is a base64 string or false otherwise
  32950. */
  32951. static IsBase64(uri: string): boolean;
  32952. /**
  32953. * Decode the given base64 uri.
  32954. * @param uri The uri to decode
  32955. * @return The decoded base64 data.
  32956. */
  32957. static DecodeBase64(uri: string): ArrayBuffer;
  32958. /**
  32959. * Gets the absolute url.
  32960. * @param url the input url
  32961. * @return the absolute url
  32962. */
  32963. static GetAbsoluteUrl(url: string): string;
  32964. /**
  32965. * No log
  32966. */
  32967. static readonly NoneLogLevel: number;
  32968. /**
  32969. * Only message logs
  32970. */
  32971. static readonly MessageLogLevel: number;
  32972. /**
  32973. * Only warning logs
  32974. */
  32975. static readonly WarningLogLevel: number;
  32976. /**
  32977. * Only error logs
  32978. */
  32979. static readonly ErrorLogLevel: number;
  32980. /**
  32981. * All logs
  32982. */
  32983. static readonly AllLogLevel: number;
  32984. /**
  32985. * Gets a value indicating the number of loading errors
  32986. * @ignorenaming
  32987. */
  32988. static readonly errorsCount: number;
  32989. /**
  32990. * Callback called when a new log is added
  32991. */
  32992. static OnNewCacheEntry: (entry: string) => void;
  32993. /**
  32994. * Log a message to the console
  32995. * @param message defines the message to log
  32996. */
  32997. static Log(message: string): void;
  32998. /**
  32999. * Write a warning message to the console
  33000. * @param message defines the message to log
  33001. */
  33002. static Warn(message: string): void;
  33003. /**
  33004. * Write an error message to the console
  33005. * @param message defines the message to log
  33006. */
  33007. static Error(message: string): void;
  33008. /**
  33009. * Gets current log cache (list of logs)
  33010. */
  33011. static readonly LogCache: string;
  33012. /**
  33013. * Clears the log cache
  33014. */
  33015. static ClearLogCache(): void;
  33016. /**
  33017. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33018. */
  33019. static LogLevels: number;
  33020. /**
  33021. * Checks if the window object exists
  33022. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33023. */
  33024. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33025. /**
  33026. * No performance log
  33027. */
  33028. static readonly PerformanceNoneLogLevel: number;
  33029. /**
  33030. * Use user marks to log performance
  33031. */
  33032. static readonly PerformanceUserMarkLogLevel: number;
  33033. /**
  33034. * Log performance to the console
  33035. */
  33036. static readonly PerformanceConsoleLogLevel: number;
  33037. private static _performance;
  33038. /**
  33039. * Sets the current performance log level
  33040. */
  33041. static PerformanceLogLevel: number;
  33042. private static _StartPerformanceCounterDisabled;
  33043. private static _EndPerformanceCounterDisabled;
  33044. private static _StartUserMark;
  33045. private static _EndUserMark;
  33046. private static _StartPerformanceConsole;
  33047. private static _EndPerformanceConsole;
  33048. /**
  33049. * Starts a performance counter
  33050. */
  33051. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33052. /**
  33053. * Ends a specific performance coutner
  33054. */
  33055. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33056. /**
  33057. * Gets either window.performance.now() if supported or Date.now() else
  33058. */
  33059. static readonly Now: number;
  33060. /**
  33061. * This method will return the name of the class used to create the instance of the given object.
  33062. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33063. * @param object the object to get the class name from
  33064. * @param isType defines if the object is actually a type
  33065. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33066. */
  33067. static GetClassName(object: any, isType?: boolean): string;
  33068. /**
  33069. * Gets the first element of an array satisfying a given predicate
  33070. * @param array defines the array to browse
  33071. * @param predicate defines the predicate to use
  33072. * @returns null if not found or the element
  33073. */
  33074. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33075. /**
  33076. * This method will return the name of the full name of the class, including its owning module (if any).
  33077. * 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).
  33078. * @param object the object to get the class name from
  33079. * @param isType defines if the object is actually a type
  33080. * @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.
  33081. * @ignorenaming
  33082. */
  33083. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33084. /**
  33085. * Returns a promise that resolves after the given amount of time.
  33086. * @param delay Number of milliseconds to delay
  33087. * @returns Promise that resolves after the given amount of time
  33088. */
  33089. static DelayAsync(delay: number): Promise<void>;
  33090. }
  33091. /**
  33092. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33093. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33094. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33095. * @param name The name of the class, case should be preserved
  33096. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33097. */
  33098. export function className(name: string, module?: string): (target: Object) => void;
  33099. /**
  33100. * An implementation of a loop for asynchronous functions.
  33101. */
  33102. export class AsyncLoop {
  33103. /**
  33104. * Defines the number of iterations for the loop
  33105. */
  33106. iterations: number;
  33107. /**
  33108. * Defines the current index of the loop.
  33109. */
  33110. index: number;
  33111. private _done;
  33112. private _fn;
  33113. private _successCallback;
  33114. /**
  33115. * Constructor.
  33116. * @param iterations the number of iterations.
  33117. * @param func the function to run each iteration
  33118. * @param successCallback the callback that will be called upon succesful execution
  33119. * @param offset starting offset.
  33120. */
  33121. constructor(
  33122. /**
  33123. * Defines the number of iterations for the loop
  33124. */
  33125. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33126. /**
  33127. * Execute the next iteration. Must be called after the last iteration was finished.
  33128. */
  33129. executeNext(): void;
  33130. /**
  33131. * Break the loop and run the success callback.
  33132. */
  33133. breakLoop(): void;
  33134. /**
  33135. * Create and run an async loop.
  33136. * @param iterations the number of iterations.
  33137. * @param fn the function to run each iteration
  33138. * @param successCallback the callback that will be called upon succesful execution
  33139. * @param offset starting offset.
  33140. * @returns the created async loop object
  33141. */
  33142. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33143. /**
  33144. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33145. * @param iterations total number of iterations
  33146. * @param syncedIterations number of synchronous iterations in each async iteration.
  33147. * @param fn the function to call each iteration.
  33148. * @param callback a success call back that will be called when iterating stops.
  33149. * @param breakFunction a break condition (optional)
  33150. * @param timeout timeout settings for the setTimeout function. default - 0.
  33151. * @returns the created async loop object
  33152. */
  33153. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33154. }
  33155. }
  33156. declare module "babylonjs/Collisions/collisionCoordinator" {
  33157. import { Nullable } from "babylonjs/types";
  33158. import { Scene } from "babylonjs/scene";
  33159. import { Vector3 } from "babylonjs/Maths/math.vector";
  33160. import { Collider } from "babylonjs/Collisions/collider";
  33161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33162. /** @hidden */
  33163. export interface ICollisionCoordinator {
  33164. createCollider(): Collider;
  33165. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33166. init(scene: Scene): void;
  33167. }
  33168. /** @hidden */
  33169. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33170. private _scene;
  33171. private _scaledPosition;
  33172. private _scaledVelocity;
  33173. private _finalPosition;
  33174. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33175. createCollider(): Collider;
  33176. init(scene: Scene): void;
  33177. private _collideWithWorld;
  33178. }
  33179. }
  33180. declare module "babylonjs/Inputs/scene.inputManager" {
  33181. import { Nullable } from "babylonjs/types";
  33182. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33183. import { Vector2 } from "babylonjs/Maths/math.vector";
  33184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33185. import { Scene } from "babylonjs/scene";
  33186. /**
  33187. * Class used to manage all inputs for the scene.
  33188. */
  33189. export class InputManager {
  33190. /** The distance in pixel that you have to move to prevent some events */
  33191. static DragMovementThreshold: number;
  33192. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33193. static LongPressDelay: number;
  33194. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33195. static DoubleClickDelay: number;
  33196. /** If you need to check double click without raising a single click at first click, enable this flag */
  33197. static ExclusiveDoubleClickMode: boolean;
  33198. private _wheelEventName;
  33199. private _onPointerMove;
  33200. private _onPointerDown;
  33201. private _onPointerUp;
  33202. private _initClickEvent;
  33203. private _initActionManager;
  33204. private _delayedSimpleClick;
  33205. private _delayedSimpleClickTimeout;
  33206. private _previousDelayedSimpleClickTimeout;
  33207. private _meshPickProceed;
  33208. private _previousButtonPressed;
  33209. private _currentPickResult;
  33210. private _previousPickResult;
  33211. private _totalPointersPressed;
  33212. private _doubleClickOccured;
  33213. private _pointerOverMesh;
  33214. private _pickedDownMesh;
  33215. private _pickedUpMesh;
  33216. private _pointerX;
  33217. private _pointerY;
  33218. private _unTranslatedPointerX;
  33219. private _unTranslatedPointerY;
  33220. private _startingPointerPosition;
  33221. private _previousStartingPointerPosition;
  33222. private _startingPointerTime;
  33223. private _previousStartingPointerTime;
  33224. private _pointerCaptures;
  33225. private _onKeyDown;
  33226. private _onKeyUp;
  33227. private _onCanvasFocusObserver;
  33228. private _onCanvasBlurObserver;
  33229. private _scene;
  33230. /**
  33231. * Creates a new InputManager
  33232. * @param scene defines the hosting scene
  33233. */
  33234. constructor(scene: Scene);
  33235. /**
  33236. * Gets the mesh that is currently under the pointer
  33237. */
  33238. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33239. /**
  33240. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33241. */
  33242. readonly unTranslatedPointer: Vector2;
  33243. /**
  33244. * Gets or sets the current on-screen X position of the pointer
  33245. */
  33246. pointerX: number;
  33247. /**
  33248. * Gets or sets the current on-screen Y position of the pointer
  33249. */
  33250. pointerY: number;
  33251. private _updatePointerPosition;
  33252. private _processPointerMove;
  33253. private _setRayOnPointerInfo;
  33254. private _checkPrePointerObservable;
  33255. /**
  33256. * Use this method to simulate a pointer move on a mesh
  33257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33260. */
  33261. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33262. /**
  33263. * Use this method to simulate a pointer down on a mesh
  33264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33267. */
  33268. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33269. private _processPointerDown;
  33270. /** @hidden */
  33271. _isPointerSwiping(): boolean;
  33272. /**
  33273. * Use this method to simulate a pointer up on a mesh
  33274. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33275. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33276. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33277. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33278. */
  33279. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33280. private _processPointerUp;
  33281. /**
  33282. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33283. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33284. * @returns true if the pointer was captured
  33285. */
  33286. isPointerCaptured(pointerId?: number): boolean;
  33287. /**
  33288. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33289. * @param attachUp defines if you want to attach events to pointerup
  33290. * @param attachDown defines if you want to attach events to pointerdown
  33291. * @param attachMove defines if you want to attach events to pointermove
  33292. */
  33293. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33294. /**
  33295. * Detaches all event handlers
  33296. */
  33297. detachControl(): void;
  33298. /**
  33299. * Force the value of meshUnderPointer
  33300. * @param mesh defines the mesh to use
  33301. */
  33302. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33303. /**
  33304. * Gets the mesh under the pointer
  33305. * @returns a Mesh or null if no mesh is under the pointer
  33306. */
  33307. getPointerOverMesh(): Nullable<AbstractMesh>;
  33308. }
  33309. }
  33310. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33311. /**
  33312. * Helper class used to generate session unique ID
  33313. */
  33314. export class UniqueIdGenerator {
  33315. private static _UniqueIdCounter;
  33316. /**
  33317. * Gets an unique (relatively to the current scene) Id
  33318. */
  33319. static readonly UniqueId: number;
  33320. }
  33321. }
  33322. declare module "babylonjs/Animations/animationGroup" {
  33323. import { Animatable } from "babylonjs/Animations/animatable";
  33324. import { Animation } from "babylonjs/Animations/animation";
  33325. import { Scene, IDisposable } from "babylonjs/scene";
  33326. import { Observable } from "babylonjs/Misc/observable";
  33327. import { Nullable } from "babylonjs/types";
  33328. import "babylonjs/Animations/animatable";
  33329. /**
  33330. * This class defines the direct association between an animation and a target
  33331. */
  33332. export class TargetedAnimation {
  33333. /**
  33334. * Animation to perform
  33335. */
  33336. animation: Animation;
  33337. /**
  33338. * Target to animate
  33339. */
  33340. target: any;
  33341. /**
  33342. * Serialize the object
  33343. * @returns the JSON object representing the current entity
  33344. */
  33345. serialize(): any;
  33346. }
  33347. /**
  33348. * Use this class to create coordinated animations on multiple targets
  33349. */
  33350. export class AnimationGroup implements IDisposable {
  33351. /** The name of the animation group */
  33352. name: string;
  33353. private _scene;
  33354. private _targetedAnimations;
  33355. private _animatables;
  33356. private _from;
  33357. private _to;
  33358. private _isStarted;
  33359. private _isPaused;
  33360. private _speedRatio;
  33361. private _loopAnimation;
  33362. /**
  33363. * Gets or sets the unique id of the node
  33364. */
  33365. uniqueId: number;
  33366. /**
  33367. * This observable will notify when one animation have ended
  33368. */
  33369. onAnimationEndObservable: Observable<TargetedAnimation>;
  33370. /**
  33371. * Observer raised when one animation loops
  33372. */
  33373. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33374. /**
  33375. * This observable will notify when all animations have ended.
  33376. */
  33377. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33378. /**
  33379. * This observable will notify when all animations have paused.
  33380. */
  33381. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33382. /**
  33383. * This observable will notify when all animations are playing.
  33384. */
  33385. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33386. /**
  33387. * Gets the first frame
  33388. */
  33389. readonly from: number;
  33390. /**
  33391. * Gets the last frame
  33392. */
  33393. readonly to: number;
  33394. /**
  33395. * Define if the animations are started
  33396. */
  33397. readonly isStarted: boolean;
  33398. /**
  33399. * Gets a value indicating that the current group is playing
  33400. */
  33401. readonly isPlaying: boolean;
  33402. /**
  33403. * Gets or sets the speed ratio to use for all animations
  33404. */
  33405. /**
  33406. * Gets or sets the speed ratio to use for all animations
  33407. */
  33408. speedRatio: number;
  33409. /**
  33410. * Gets or sets if all animations should loop or not
  33411. */
  33412. loopAnimation: boolean;
  33413. /**
  33414. * Gets the targeted animations for this animation group
  33415. */
  33416. readonly targetedAnimations: Array<TargetedAnimation>;
  33417. /**
  33418. * returning the list of animatables controlled by this animation group.
  33419. */
  33420. readonly animatables: Array<Animatable>;
  33421. /**
  33422. * Instantiates a new Animation Group.
  33423. * This helps managing several animations at once.
  33424. * @see http://doc.babylonjs.com/how_to/group
  33425. * @param name Defines the name of the group
  33426. * @param scene Defines the scene the group belongs to
  33427. */
  33428. constructor(
  33429. /** The name of the animation group */
  33430. name: string, scene?: Nullable<Scene>);
  33431. /**
  33432. * Add an animation (with its target) in the group
  33433. * @param animation defines the animation we want to add
  33434. * @param target defines the target of the animation
  33435. * @returns the TargetedAnimation object
  33436. */
  33437. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33438. /**
  33439. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33440. * It can add constant keys at begin or end
  33441. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33442. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33443. * @returns the animation group
  33444. */
  33445. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33446. /**
  33447. * Start all animations on given targets
  33448. * @param loop defines if animations must loop
  33449. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33450. * @param from defines the from key (optional)
  33451. * @param to defines the to key (optional)
  33452. * @returns the current animation group
  33453. */
  33454. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33455. /**
  33456. * Pause all animations
  33457. * @returns the animation group
  33458. */
  33459. pause(): AnimationGroup;
  33460. /**
  33461. * Play all animations to initial state
  33462. * This function will start() the animations if they were not started or will restart() them if they were paused
  33463. * @param loop defines if animations must loop
  33464. * @returns the animation group
  33465. */
  33466. play(loop?: boolean): AnimationGroup;
  33467. /**
  33468. * Reset all animations to initial state
  33469. * @returns the animation group
  33470. */
  33471. reset(): AnimationGroup;
  33472. /**
  33473. * Restart animations from key 0
  33474. * @returns the animation group
  33475. */
  33476. restart(): AnimationGroup;
  33477. /**
  33478. * Stop all animations
  33479. * @returns the animation group
  33480. */
  33481. stop(): AnimationGroup;
  33482. /**
  33483. * Set animation weight for all animatables
  33484. * @param weight defines the weight to use
  33485. * @return the animationGroup
  33486. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33487. */
  33488. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33489. /**
  33490. * Synchronize and normalize all animatables with a source animatable
  33491. * @param root defines the root animatable to synchronize with
  33492. * @return the animationGroup
  33493. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33494. */
  33495. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33496. /**
  33497. * Goes to a specific frame in this animation group
  33498. * @param frame the frame number to go to
  33499. * @return the animationGroup
  33500. */
  33501. goToFrame(frame: number): AnimationGroup;
  33502. /**
  33503. * Dispose all associated resources
  33504. */
  33505. dispose(): void;
  33506. private _checkAnimationGroupEnded;
  33507. /**
  33508. * Clone the current animation group and returns a copy
  33509. * @param newName defines the name of the new group
  33510. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33511. * @returns the new aniamtion group
  33512. */
  33513. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33514. /**
  33515. * Serializes the animationGroup to an object
  33516. * @returns Serialized object
  33517. */
  33518. serialize(): any;
  33519. /**
  33520. * Returns a new AnimationGroup object parsed from the source provided.
  33521. * @param parsedAnimationGroup defines the source
  33522. * @param scene defines the scene that will receive the animationGroup
  33523. * @returns a new AnimationGroup
  33524. */
  33525. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33526. /**
  33527. * Returns the string "AnimationGroup"
  33528. * @returns "AnimationGroup"
  33529. */
  33530. getClassName(): string;
  33531. /**
  33532. * Creates a detailled string about the object
  33533. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33534. * @returns a string representing the object
  33535. */
  33536. toString(fullDetails?: boolean): string;
  33537. }
  33538. }
  33539. declare module "babylonjs/scene" {
  33540. import { Nullable } from "babylonjs/types";
  33541. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33542. import { Observable } from "babylonjs/Misc/observable";
  33543. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33544. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33545. import { Geometry } from "babylonjs/Meshes/geometry";
  33546. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33549. import { Mesh } from "babylonjs/Meshes/mesh";
  33550. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33551. import { Bone } from "babylonjs/Bones/bone";
  33552. import { Skeleton } from "babylonjs/Bones/skeleton";
  33553. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33554. import { Camera } from "babylonjs/Cameras/camera";
  33555. import { AbstractScene } from "babylonjs/abstractScene";
  33556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33557. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33558. import { Material } from "babylonjs/Materials/material";
  33559. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33560. import { Effect } from "babylonjs/Materials/effect";
  33561. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33562. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33563. import { Light } from "babylonjs/Lights/light";
  33564. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33565. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33566. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33567. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33568. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33569. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33570. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33571. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33572. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33573. import { Engine } from "babylonjs/Engines/engine";
  33574. import { Node } from "babylonjs/node";
  33575. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33576. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33577. import { WebRequest } from "babylonjs/Misc/webRequest";
  33578. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33579. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33580. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33581. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33582. import { Plane } from "babylonjs/Maths/math.plane";
  33583. import { Ray } from "babylonjs/Culling/ray";
  33584. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33585. import { Animation } from "babylonjs/Animations/animation";
  33586. import { Animatable } from "babylonjs/Animations/animatable";
  33587. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33588. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33589. import { Collider } from "babylonjs/Collisions/collider";
  33590. /**
  33591. * Define an interface for all classes that will hold resources
  33592. */
  33593. export interface IDisposable {
  33594. /**
  33595. * Releases all held resources
  33596. */
  33597. dispose(): void;
  33598. }
  33599. /** Interface defining initialization parameters for Scene class */
  33600. export interface SceneOptions {
  33601. /**
  33602. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33603. * It will improve performance when the number of geometries becomes important.
  33604. */
  33605. useGeometryUniqueIdsMap?: boolean;
  33606. /**
  33607. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33608. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33609. */
  33610. useMaterialMeshMap?: boolean;
  33611. /**
  33612. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33613. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33614. */
  33615. useClonedMeshhMap?: boolean;
  33616. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33617. virtual?: boolean;
  33618. }
  33619. /**
  33620. * Represents a scene to be rendered by the engine.
  33621. * @see http://doc.babylonjs.com/features/scene
  33622. */
  33623. export class Scene extends AbstractScene implements IAnimatable {
  33624. /** The fog is deactivated */
  33625. static readonly FOGMODE_NONE: number;
  33626. /** The fog density is following an exponential function */
  33627. static readonly FOGMODE_EXP: number;
  33628. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33629. static readonly FOGMODE_EXP2: number;
  33630. /** The fog density is following a linear function. */
  33631. static readonly FOGMODE_LINEAR: number;
  33632. /**
  33633. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33635. */
  33636. static MinDeltaTime: number;
  33637. /**
  33638. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33640. */
  33641. static MaxDeltaTime: number;
  33642. /**
  33643. * Factory used to create the default material.
  33644. * @param name The name of the material to create
  33645. * @param scene The scene to create the material for
  33646. * @returns The default material
  33647. */
  33648. static DefaultMaterialFactory(scene: Scene): Material;
  33649. /**
  33650. * Factory used to create the a collision coordinator.
  33651. * @returns The collision coordinator
  33652. */
  33653. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33654. /** @hidden */
  33655. _inputManager: InputManager;
  33656. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33657. cameraToUseForPointers: Nullable<Camera>;
  33658. /** @hidden */
  33659. readonly _isScene: boolean;
  33660. /**
  33661. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33662. */
  33663. autoClear: boolean;
  33664. /**
  33665. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33666. */
  33667. autoClearDepthAndStencil: boolean;
  33668. /**
  33669. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33670. */
  33671. clearColor: Color4;
  33672. /**
  33673. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33674. */
  33675. ambientColor: Color3;
  33676. /**
  33677. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33678. * It should only be one of the following (if not the default embedded one):
  33679. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33680. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33681. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33682. * The material properties need to be setup according to the type of texture in use.
  33683. */
  33684. environmentBRDFTexture: BaseTexture;
  33685. /** @hidden */
  33686. protected _environmentTexture: Nullable<BaseTexture>;
  33687. /**
  33688. * Texture used in all pbr material as the reflection texture.
  33689. * As in the majority of the scene they are the same (exception for multi room and so on),
  33690. * this is easier to reference from here than from all the materials.
  33691. */
  33692. /**
  33693. * Texture used in all pbr material as the reflection texture.
  33694. * As in the majority of the scene they are the same (exception for multi room and so on),
  33695. * this is easier to set here than in all the materials.
  33696. */
  33697. environmentTexture: Nullable<BaseTexture>;
  33698. /** @hidden */
  33699. protected _environmentIntensity: number;
  33700. /**
  33701. * Intensity of the environment in all pbr material.
  33702. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33703. * As in the majority of the scene they are the same (exception for multi room and so on),
  33704. * this is easier to reference from here than from all the materials.
  33705. */
  33706. /**
  33707. * Intensity of the environment in all pbr material.
  33708. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33709. * As in the majority of the scene they are the same (exception for multi room and so on),
  33710. * this is easier to set here than in all the materials.
  33711. */
  33712. environmentIntensity: number;
  33713. /** @hidden */
  33714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33715. /**
  33716. * Default image processing configuration used either in the rendering
  33717. * Forward main pass or through the imageProcessingPostProcess if present.
  33718. * As in the majority of the scene they are the same (exception for multi camera),
  33719. * this is easier to reference from here than from all the materials and post process.
  33720. *
  33721. * No setter as we it is a shared configuration, you can set the values instead.
  33722. */
  33723. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33724. private _forceWireframe;
  33725. /**
  33726. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33727. */
  33728. forceWireframe: boolean;
  33729. private _forcePointsCloud;
  33730. /**
  33731. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33732. */
  33733. forcePointsCloud: boolean;
  33734. /**
  33735. * Gets or sets the active clipplane 1
  33736. */
  33737. clipPlane: Nullable<Plane>;
  33738. /**
  33739. * Gets or sets the active clipplane 2
  33740. */
  33741. clipPlane2: Nullable<Plane>;
  33742. /**
  33743. * Gets or sets the active clipplane 3
  33744. */
  33745. clipPlane3: Nullable<Plane>;
  33746. /**
  33747. * Gets or sets the active clipplane 4
  33748. */
  33749. clipPlane4: Nullable<Plane>;
  33750. /**
  33751. * Gets or sets a boolean indicating if animations are enabled
  33752. */
  33753. animationsEnabled: boolean;
  33754. private _animationPropertiesOverride;
  33755. /**
  33756. * Gets or sets the animation properties override
  33757. */
  33758. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33759. /**
  33760. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33761. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33762. */
  33763. useConstantAnimationDeltaTime: boolean;
  33764. /**
  33765. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33766. * Please note that it requires to run a ray cast through the scene on every frame
  33767. */
  33768. constantlyUpdateMeshUnderPointer: boolean;
  33769. /**
  33770. * Defines the HTML cursor to use when hovering over interactive elements
  33771. */
  33772. hoverCursor: string;
  33773. /**
  33774. * Defines the HTML default cursor to use (empty by default)
  33775. */
  33776. defaultCursor: string;
  33777. /**
  33778. * This is used to call preventDefault() on pointer down
  33779. * in order to block unwanted artifacts like system double clicks
  33780. */
  33781. preventDefaultOnPointerDown: boolean;
  33782. /**
  33783. * This is used to call preventDefault() on pointer up
  33784. * in order to block unwanted artifacts like system double clicks
  33785. */
  33786. preventDefaultOnPointerUp: boolean;
  33787. /**
  33788. * Gets or sets user defined metadata
  33789. */
  33790. metadata: any;
  33791. /**
  33792. * For internal use only. Please do not use.
  33793. */
  33794. reservedDataStore: any;
  33795. /**
  33796. * Gets the name of the plugin used to load this scene (null by default)
  33797. */
  33798. loadingPluginName: string;
  33799. /**
  33800. * Use this array to add regular expressions used to disable offline support for specific urls
  33801. */
  33802. disableOfflineSupportExceptionRules: RegExp[];
  33803. /**
  33804. * An event triggered when the scene is disposed.
  33805. */
  33806. onDisposeObservable: Observable<Scene>;
  33807. private _onDisposeObserver;
  33808. /** Sets a function to be executed when this scene is disposed. */
  33809. onDispose: () => void;
  33810. /**
  33811. * An event triggered before rendering the scene (right after animations and physics)
  33812. */
  33813. onBeforeRenderObservable: Observable<Scene>;
  33814. private _onBeforeRenderObserver;
  33815. /** Sets a function to be executed before rendering this scene */
  33816. beforeRender: Nullable<() => void>;
  33817. /**
  33818. * An event triggered after rendering the scene
  33819. */
  33820. onAfterRenderObservable: Observable<Scene>;
  33821. /**
  33822. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33823. */
  33824. onAfterRenderCameraObservable: Observable<Camera>;
  33825. private _onAfterRenderObserver;
  33826. /** Sets a function to be executed after rendering this scene */
  33827. afterRender: Nullable<() => void>;
  33828. /**
  33829. * An event triggered before animating the scene
  33830. */
  33831. onBeforeAnimationsObservable: Observable<Scene>;
  33832. /**
  33833. * An event triggered after animations processing
  33834. */
  33835. onAfterAnimationsObservable: Observable<Scene>;
  33836. /**
  33837. * An event triggered before draw calls are ready to be sent
  33838. */
  33839. onBeforeDrawPhaseObservable: Observable<Scene>;
  33840. /**
  33841. * An event triggered after draw calls have been sent
  33842. */
  33843. onAfterDrawPhaseObservable: Observable<Scene>;
  33844. /**
  33845. * An event triggered when the scene is ready
  33846. */
  33847. onReadyObservable: Observable<Scene>;
  33848. /**
  33849. * An event triggered before rendering a camera
  33850. */
  33851. onBeforeCameraRenderObservable: Observable<Camera>;
  33852. private _onBeforeCameraRenderObserver;
  33853. /** Sets a function to be executed before rendering a camera*/
  33854. beforeCameraRender: () => void;
  33855. /**
  33856. * An event triggered after rendering a camera
  33857. */
  33858. onAfterCameraRenderObservable: Observable<Camera>;
  33859. private _onAfterCameraRenderObserver;
  33860. /** Sets a function to be executed after rendering a camera*/
  33861. afterCameraRender: () => void;
  33862. /**
  33863. * An event triggered when active meshes evaluation is about to start
  33864. */
  33865. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33866. /**
  33867. * An event triggered when active meshes evaluation is done
  33868. */
  33869. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33870. /**
  33871. * An event triggered when particles rendering is about to start
  33872. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33873. */
  33874. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33875. /**
  33876. * An event triggered when particles rendering is done
  33877. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33878. */
  33879. onAfterParticlesRenderingObservable: Observable<Scene>;
  33880. /**
  33881. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33882. */
  33883. onDataLoadedObservable: Observable<Scene>;
  33884. /**
  33885. * An event triggered when a camera is created
  33886. */
  33887. onNewCameraAddedObservable: Observable<Camera>;
  33888. /**
  33889. * An event triggered when a camera is removed
  33890. */
  33891. onCameraRemovedObservable: Observable<Camera>;
  33892. /**
  33893. * An event triggered when a light is created
  33894. */
  33895. onNewLightAddedObservable: Observable<Light>;
  33896. /**
  33897. * An event triggered when a light is removed
  33898. */
  33899. onLightRemovedObservable: Observable<Light>;
  33900. /**
  33901. * An event triggered when a geometry is created
  33902. */
  33903. onNewGeometryAddedObservable: Observable<Geometry>;
  33904. /**
  33905. * An event triggered when a geometry is removed
  33906. */
  33907. onGeometryRemovedObservable: Observable<Geometry>;
  33908. /**
  33909. * An event triggered when a transform node is created
  33910. */
  33911. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33912. /**
  33913. * An event triggered when a transform node is removed
  33914. */
  33915. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33916. /**
  33917. * An event triggered when a mesh is created
  33918. */
  33919. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33920. /**
  33921. * An event triggered when a mesh is removed
  33922. */
  33923. onMeshRemovedObservable: Observable<AbstractMesh>;
  33924. /**
  33925. * An event triggered when a skeleton is created
  33926. */
  33927. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33928. /**
  33929. * An event triggered when a skeleton is removed
  33930. */
  33931. onSkeletonRemovedObservable: Observable<Skeleton>;
  33932. /**
  33933. * An event triggered when a material is created
  33934. */
  33935. onNewMaterialAddedObservable: Observable<Material>;
  33936. /**
  33937. * An event triggered when a material is removed
  33938. */
  33939. onMaterialRemovedObservable: Observable<Material>;
  33940. /**
  33941. * An event triggered when a texture is created
  33942. */
  33943. onNewTextureAddedObservable: Observable<BaseTexture>;
  33944. /**
  33945. * An event triggered when a texture is removed
  33946. */
  33947. onTextureRemovedObservable: Observable<BaseTexture>;
  33948. /**
  33949. * An event triggered when render targets are about to be rendered
  33950. * Can happen multiple times per frame.
  33951. */
  33952. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33953. /**
  33954. * An event triggered when render targets were rendered.
  33955. * Can happen multiple times per frame.
  33956. */
  33957. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33958. /**
  33959. * An event triggered before calculating deterministic simulation step
  33960. */
  33961. onBeforeStepObservable: Observable<Scene>;
  33962. /**
  33963. * An event triggered after calculating deterministic simulation step
  33964. */
  33965. onAfterStepObservable: Observable<Scene>;
  33966. /**
  33967. * An event triggered when the activeCamera property is updated
  33968. */
  33969. onActiveCameraChanged: Observable<Scene>;
  33970. /**
  33971. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33972. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33973. * 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)
  33974. */
  33975. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33976. /**
  33977. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33979. * 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)
  33980. */
  33981. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33982. /**
  33983. * This Observable will when a mesh has been imported into the scene.
  33984. */
  33985. onMeshImportedObservable: Observable<AbstractMesh>;
  33986. /**
  33987. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33988. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33989. */
  33990. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33991. /** @hidden */
  33992. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33993. /**
  33994. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33995. */
  33996. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33997. /**
  33998. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33999. */
  34000. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34001. /**
  34002. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34003. */
  34004. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34005. /** Callback called when a pointer move is detected */
  34006. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34007. /** Callback called when a pointer down is detected */
  34008. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34009. /** Callback called when a pointer up is detected */
  34010. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34011. /** Callback called when a pointer pick is detected */
  34012. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34013. /**
  34014. * 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).
  34015. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34016. */
  34017. onPrePointerObservable: Observable<PointerInfoPre>;
  34018. /**
  34019. * Observable event triggered each time an input event is received from the rendering canvas
  34020. */
  34021. onPointerObservable: Observable<PointerInfo>;
  34022. /**
  34023. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34024. */
  34025. readonly unTranslatedPointer: Vector2;
  34026. /**
  34027. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34028. */
  34029. static DragMovementThreshold: number;
  34030. /**
  34031. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34032. */
  34033. static LongPressDelay: number;
  34034. /**
  34035. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34036. */
  34037. static DoubleClickDelay: number;
  34038. /** If you need to check double click without raising a single click at first click, enable this flag */
  34039. static ExclusiveDoubleClickMode: boolean;
  34040. /** @hidden */
  34041. _mirroredCameraPosition: Nullable<Vector3>;
  34042. /**
  34043. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34044. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34045. */
  34046. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34047. /**
  34048. * Observable event triggered each time an keyboard event is received from the hosting window
  34049. */
  34050. onKeyboardObservable: Observable<KeyboardInfo>;
  34051. private _useRightHandedSystem;
  34052. /**
  34053. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34054. */
  34055. useRightHandedSystem: boolean;
  34056. private _timeAccumulator;
  34057. private _currentStepId;
  34058. private _currentInternalStep;
  34059. /**
  34060. * Sets the step Id used by deterministic lock step
  34061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34062. * @param newStepId defines the step Id
  34063. */
  34064. setStepId(newStepId: number): void;
  34065. /**
  34066. * Gets the step Id used by deterministic lock step
  34067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34068. * @returns the step Id
  34069. */
  34070. getStepId(): number;
  34071. /**
  34072. * Gets the internal step used by deterministic lock step
  34073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34074. * @returns the internal step
  34075. */
  34076. getInternalStep(): number;
  34077. private _fogEnabled;
  34078. /**
  34079. * Gets or sets a boolean indicating if fog is enabled on this scene
  34080. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34081. * (Default is true)
  34082. */
  34083. fogEnabled: boolean;
  34084. private _fogMode;
  34085. /**
  34086. * Gets or sets the fog mode to use
  34087. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34088. * | mode | value |
  34089. * | --- | --- |
  34090. * | FOGMODE_NONE | 0 |
  34091. * | FOGMODE_EXP | 1 |
  34092. * | FOGMODE_EXP2 | 2 |
  34093. * | FOGMODE_LINEAR | 3 |
  34094. */
  34095. fogMode: number;
  34096. /**
  34097. * Gets or sets the fog color to use
  34098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34099. * (Default is Color3(0.2, 0.2, 0.3))
  34100. */
  34101. fogColor: Color3;
  34102. /**
  34103. * Gets or sets the fog density to use
  34104. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34105. * (Default is 0.1)
  34106. */
  34107. fogDensity: number;
  34108. /**
  34109. * Gets or sets the fog start distance to use
  34110. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34111. * (Default is 0)
  34112. */
  34113. fogStart: number;
  34114. /**
  34115. * Gets or sets the fog end distance to use
  34116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34117. * (Default is 1000)
  34118. */
  34119. fogEnd: number;
  34120. private _shadowsEnabled;
  34121. /**
  34122. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34123. */
  34124. shadowsEnabled: boolean;
  34125. private _lightsEnabled;
  34126. /**
  34127. * Gets or sets a boolean indicating if lights are enabled on this scene
  34128. */
  34129. lightsEnabled: boolean;
  34130. /** All of the active cameras added to this scene. */
  34131. activeCameras: Camera[];
  34132. /** @hidden */
  34133. _activeCamera: Nullable<Camera>;
  34134. /** Gets or sets the current active camera */
  34135. activeCamera: Nullable<Camera>;
  34136. private _defaultMaterial;
  34137. /** The default material used on meshes when no material is affected */
  34138. /** The default material used on meshes when no material is affected */
  34139. defaultMaterial: Material;
  34140. private _texturesEnabled;
  34141. /**
  34142. * Gets or sets a boolean indicating if textures are enabled on this scene
  34143. */
  34144. texturesEnabled: boolean;
  34145. /**
  34146. * Gets or sets a boolean indicating if particles are enabled on this scene
  34147. */
  34148. particlesEnabled: boolean;
  34149. /**
  34150. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34151. */
  34152. spritesEnabled: boolean;
  34153. private _skeletonsEnabled;
  34154. /**
  34155. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34156. */
  34157. skeletonsEnabled: boolean;
  34158. /**
  34159. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34160. */
  34161. lensFlaresEnabled: boolean;
  34162. /**
  34163. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34165. */
  34166. collisionsEnabled: boolean;
  34167. private _collisionCoordinator;
  34168. /** @hidden */
  34169. readonly collisionCoordinator: ICollisionCoordinator;
  34170. /**
  34171. * Defines the gravity applied to this scene (used only for collisions)
  34172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34173. */
  34174. gravity: Vector3;
  34175. /**
  34176. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34177. */
  34178. postProcessesEnabled: boolean;
  34179. /**
  34180. * The list of postprocesses added to the scene
  34181. */
  34182. postProcesses: PostProcess[];
  34183. /**
  34184. * Gets the current postprocess manager
  34185. */
  34186. postProcessManager: PostProcessManager;
  34187. /**
  34188. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34189. */
  34190. renderTargetsEnabled: boolean;
  34191. /**
  34192. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34193. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34194. */
  34195. dumpNextRenderTargets: boolean;
  34196. /**
  34197. * The list of user defined render targets added to the scene
  34198. */
  34199. customRenderTargets: RenderTargetTexture[];
  34200. /**
  34201. * Defines if texture loading must be delayed
  34202. * If true, textures will only be loaded when they need to be rendered
  34203. */
  34204. useDelayedTextureLoading: boolean;
  34205. /**
  34206. * Gets the list of meshes imported to the scene through SceneLoader
  34207. */
  34208. importedMeshesFiles: String[];
  34209. /**
  34210. * Gets or sets a boolean indicating if probes are enabled on this scene
  34211. */
  34212. probesEnabled: boolean;
  34213. /**
  34214. * Gets or sets the current offline provider to use to store scene data
  34215. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34216. */
  34217. offlineProvider: IOfflineProvider;
  34218. /**
  34219. * Gets or sets the action manager associated with the scene
  34220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34221. */
  34222. actionManager: AbstractActionManager;
  34223. private _meshesForIntersections;
  34224. /**
  34225. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34226. */
  34227. proceduralTexturesEnabled: boolean;
  34228. private _engine;
  34229. private _totalVertices;
  34230. /** @hidden */
  34231. _activeIndices: PerfCounter;
  34232. /** @hidden */
  34233. _activeParticles: PerfCounter;
  34234. /** @hidden */
  34235. _activeBones: PerfCounter;
  34236. private _animationRatio;
  34237. /** @hidden */
  34238. _animationTimeLast: number;
  34239. /** @hidden */
  34240. _animationTime: number;
  34241. /**
  34242. * Gets or sets a general scale for animation speed
  34243. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34244. */
  34245. animationTimeScale: number;
  34246. /** @hidden */
  34247. _cachedMaterial: Nullable<Material>;
  34248. /** @hidden */
  34249. _cachedEffect: Nullable<Effect>;
  34250. /** @hidden */
  34251. _cachedVisibility: Nullable<number>;
  34252. private _renderId;
  34253. private _frameId;
  34254. private _executeWhenReadyTimeoutId;
  34255. private _intermediateRendering;
  34256. private _viewUpdateFlag;
  34257. private _projectionUpdateFlag;
  34258. /** @hidden */
  34259. _toBeDisposed: Nullable<IDisposable>[];
  34260. private _activeRequests;
  34261. /** @hidden */
  34262. _pendingData: any[];
  34263. private _isDisposed;
  34264. /**
  34265. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34266. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34267. */
  34268. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34269. private _activeMeshes;
  34270. private _processedMaterials;
  34271. private _renderTargets;
  34272. /** @hidden */
  34273. _activeParticleSystems: SmartArray<IParticleSystem>;
  34274. private _activeSkeletons;
  34275. private _softwareSkinnedMeshes;
  34276. private _renderingManager;
  34277. /** @hidden */
  34278. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34279. private _transformMatrix;
  34280. private _sceneUbo;
  34281. /** @hidden */
  34282. _viewMatrix: Matrix;
  34283. private _projectionMatrix;
  34284. /** @hidden */
  34285. _forcedViewPosition: Nullable<Vector3>;
  34286. /** @hidden */
  34287. _frustumPlanes: Plane[];
  34288. /**
  34289. * Gets the list of frustum planes (built from the active camera)
  34290. */
  34291. readonly frustumPlanes: Plane[];
  34292. /**
  34293. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34294. * This is useful if there are more lights that the maximum simulteanous authorized
  34295. */
  34296. requireLightSorting: boolean;
  34297. /** @hidden */
  34298. readonly useMaterialMeshMap: boolean;
  34299. /** @hidden */
  34300. readonly useClonedMeshhMap: boolean;
  34301. private _externalData;
  34302. private _uid;
  34303. /**
  34304. * @hidden
  34305. * Backing store of defined scene components.
  34306. */
  34307. _components: ISceneComponent[];
  34308. /**
  34309. * @hidden
  34310. * Backing store of defined scene components.
  34311. */
  34312. _serializableComponents: ISceneSerializableComponent[];
  34313. /**
  34314. * List of components to register on the next registration step.
  34315. */
  34316. private _transientComponents;
  34317. /**
  34318. * Registers the transient components if needed.
  34319. */
  34320. private _registerTransientComponents;
  34321. /**
  34322. * @hidden
  34323. * Add a component to the scene.
  34324. * Note that the ccomponent could be registered on th next frame if this is called after
  34325. * the register component stage.
  34326. * @param component Defines the component to add to the scene
  34327. */
  34328. _addComponent(component: ISceneComponent): void;
  34329. /**
  34330. * @hidden
  34331. * Gets a component from the scene.
  34332. * @param name defines the name of the component to retrieve
  34333. * @returns the component or null if not present
  34334. */
  34335. _getComponent(name: string): Nullable<ISceneComponent>;
  34336. /**
  34337. * @hidden
  34338. * Defines the actions happening before camera updates.
  34339. */
  34340. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34341. /**
  34342. * @hidden
  34343. * Defines the actions happening before clear the canvas.
  34344. */
  34345. _beforeClearStage: Stage<SimpleStageAction>;
  34346. /**
  34347. * @hidden
  34348. * Defines the actions when collecting render targets for the frame.
  34349. */
  34350. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34351. /**
  34352. * @hidden
  34353. * Defines the actions happening for one camera in the frame.
  34354. */
  34355. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34356. /**
  34357. * @hidden
  34358. * Defines the actions happening during the per mesh ready checks.
  34359. */
  34360. _isReadyForMeshStage: Stage<MeshStageAction>;
  34361. /**
  34362. * @hidden
  34363. * Defines the actions happening before evaluate active mesh checks.
  34364. */
  34365. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34366. /**
  34367. * @hidden
  34368. * Defines the actions happening during the evaluate sub mesh checks.
  34369. */
  34370. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34371. /**
  34372. * @hidden
  34373. * Defines the actions happening during the active mesh stage.
  34374. */
  34375. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34376. /**
  34377. * @hidden
  34378. * Defines the actions happening during the per camera render target step.
  34379. */
  34380. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34381. /**
  34382. * @hidden
  34383. * Defines the actions happening just before the active camera is drawing.
  34384. */
  34385. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34386. /**
  34387. * @hidden
  34388. * Defines the actions happening just before a render target is drawing.
  34389. */
  34390. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34391. /**
  34392. * @hidden
  34393. * Defines the actions happening just before a rendering group is drawing.
  34394. */
  34395. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34396. /**
  34397. * @hidden
  34398. * Defines the actions happening just before a mesh is drawing.
  34399. */
  34400. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34401. /**
  34402. * @hidden
  34403. * Defines the actions happening just after a mesh has been drawn.
  34404. */
  34405. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34406. /**
  34407. * @hidden
  34408. * Defines the actions happening just after a rendering group has been drawn.
  34409. */
  34410. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34411. /**
  34412. * @hidden
  34413. * Defines the actions happening just after the active camera has been drawn.
  34414. */
  34415. _afterCameraDrawStage: Stage<CameraStageAction>;
  34416. /**
  34417. * @hidden
  34418. * Defines the actions happening just after a render target has been drawn.
  34419. */
  34420. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34421. /**
  34422. * @hidden
  34423. * Defines the actions happening just after rendering all cameras and computing intersections.
  34424. */
  34425. _afterRenderStage: Stage<SimpleStageAction>;
  34426. /**
  34427. * @hidden
  34428. * Defines the actions happening when a pointer move event happens.
  34429. */
  34430. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34431. /**
  34432. * @hidden
  34433. * Defines the actions happening when a pointer down event happens.
  34434. */
  34435. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34436. /**
  34437. * @hidden
  34438. * Defines the actions happening when a pointer up event happens.
  34439. */
  34440. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34441. /**
  34442. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34443. */
  34444. private geometriesByUniqueId;
  34445. /**
  34446. * Creates a new Scene
  34447. * @param engine defines the engine to use to render this scene
  34448. * @param options defines the scene options
  34449. */
  34450. constructor(engine: Engine, options?: SceneOptions);
  34451. /**
  34452. * Gets a string idenfifying the name of the class
  34453. * @returns "Scene" string
  34454. */
  34455. getClassName(): string;
  34456. private _defaultMeshCandidates;
  34457. /**
  34458. * @hidden
  34459. */
  34460. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34461. private _defaultSubMeshCandidates;
  34462. /**
  34463. * @hidden
  34464. */
  34465. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34466. /**
  34467. * Sets the default candidate providers for the scene.
  34468. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34469. * and getCollidingSubMeshCandidates to their default function
  34470. */
  34471. setDefaultCandidateProviders(): void;
  34472. /**
  34473. * Gets the mesh that is currently under the pointer
  34474. */
  34475. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34476. /**
  34477. * Gets or sets the current on-screen X position of the pointer
  34478. */
  34479. pointerX: number;
  34480. /**
  34481. * Gets or sets the current on-screen Y position of the pointer
  34482. */
  34483. pointerY: number;
  34484. /**
  34485. * Gets the cached material (ie. the latest rendered one)
  34486. * @returns the cached material
  34487. */
  34488. getCachedMaterial(): Nullable<Material>;
  34489. /**
  34490. * Gets the cached effect (ie. the latest rendered one)
  34491. * @returns the cached effect
  34492. */
  34493. getCachedEffect(): Nullable<Effect>;
  34494. /**
  34495. * Gets the cached visibility state (ie. the latest rendered one)
  34496. * @returns the cached visibility state
  34497. */
  34498. getCachedVisibility(): Nullable<number>;
  34499. /**
  34500. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34501. * @param material defines the current material
  34502. * @param effect defines the current effect
  34503. * @param visibility defines the current visibility state
  34504. * @returns true if one parameter is not cached
  34505. */
  34506. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34507. /**
  34508. * Gets the engine associated with the scene
  34509. * @returns an Engine
  34510. */
  34511. getEngine(): Engine;
  34512. /**
  34513. * Gets the total number of vertices rendered per frame
  34514. * @returns the total number of vertices rendered per frame
  34515. */
  34516. getTotalVertices(): number;
  34517. /**
  34518. * Gets the performance counter for total vertices
  34519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34520. */
  34521. readonly totalVerticesPerfCounter: PerfCounter;
  34522. /**
  34523. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34524. * @returns the total number of active indices rendered per frame
  34525. */
  34526. getActiveIndices(): number;
  34527. /**
  34528. * Gets the performance counter for active indices
  34529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34530. */
  34531. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34532. /**
  34533. * Gets the total number of active particles rendered per frame
  34534. * @returns the total number of active particles rendered per frame
  34535. */
  34536. getActiveParticles(): number;
  34537. /**
  34538. * Gets the performance counter for active particles
  34539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34540. */
  34541. readonly activeParticlesPerfCounter: PerfCounter;
  34542. /**
  34543. * Gets the total number of active bones rendered per frame
  34544. * @returns the total number of active bones rendered per frame
  34545. */
  34546. getActiveBones(): number;
  34547. /**
  34548. * Gets the performance counter for active bones
  34549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34550. */
  34551. readonly activeBonesPerfCounter: PerfCounter;
  34552. /**
  34553. * Gets the array of active meshes
  34554. * @returns an array of AbstractMesh
  34555. */
  34556. getActiveMeshes(): SmartArray<AbstractMesh>;
  34557. /**
  34558. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34559. * @returns a number
  34560. */
  34561. getAnimationRatio(): number;
  34562. /**
  34563. * Gets an unique Id for the current render phase
  34564. * @returns a number
  34565. */
  34566. getRenderId(): number;
  34567. /**
  34568. * Gets an unique Id for the current frame
  34569. * @returns a number
  34570. */
  34571. getFrameId(): number;
  34572. /** Call this function if you want to manually increment the render Id*/
  34573. incrementRenderId(): void;
  34574. private _createUbo;
  34575. /**
  34576. * Use this method to simulate a pointer move on a mesh
  34577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34580. * @returns the current scene
  34581. */
  34582. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34583. /**
  34584. * Use this method to simulate a pointer down on a mesh
  34585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34588. * @returns the current scene
  34589. */
  34590. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34591. /**
  34592. * Use this method to simulate a pointer up on a mesh
  34593. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34594. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34595. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34596. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34597. * @returns the current scene
  34598. */
  34599. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34600. /**
  34601. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34602. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34603. * @returns true if the pointer was captured
  34604. */
  34605. isPointerCaptured(pointerId?: number): boolean;
  34606. /**
  34607. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34608. * @param attachUp defines if you want to attach events to pointerup
  34609. * @param attachDown defines if you want to attach events to pointerdown
  34610. * @param attachMove defines if you want to attach events to pointermove
  34611. */
  34612. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34613. /** Detaches all event handlers*/
  34614. detachControl(): void;
  34615. /**
  34616. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34617. * Delay loaded resources are not taking in account
  34618. * @return true if all required resources are ready
  34619. */
  34620. isReady(): boolean;
  34621. /** Resets all cached information relative to material (including effect and visibility) */
  34622. resetCachedMaterial(): void;
  34623. /**
  34624. * Registers a function to be called before every frame render
  34625. * @param func defines the function to register
  34626. */
  34627. registerBeforeRender(func: () => void): void;
  34628. /**
  34629. * Unregisters a function called before every frame render
  34630. * @param func defines the function to unregister
  34631. */
  34632. unregisterBeforeRender(func: () => void): void;
  34633. /**
  34634. * Registers a function to be called after every frame render
  34635. * @param func defines the function to register
  34636. */
  34637. registerAfterRender(func: () => void): void;
  34638. /**
  34639. * Unregisters a function called after every frame render
  34640. * @param func defines the function to unregister
  34641. */
  34642. unregisterAfterRender(func: () => void): void;
  34643. private _executeOnceBeforeRender;
  34644. /**
  34645. * The provided function will run before render once and will be disposed afterwards.
  34646. * A timeout delay can be provided so that the function will be executed in N ms.
  34647. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34648. * @param func The function to be executed.
  34649. * @param timeout optional delay in ms
  34650. */
  34651. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34652. /** @hidden */
  34653. _addPendingData(data: any): void;
  34654. /** @hidden */
  34655. _removePendingData(data: any): void;
  34656. /**
  34657. * Returns the number of items waiting to be loaded
  34658. * @returns the number of items waiting to be loaded
  34659. */
  34660. getWaitingItemsCount(): number;
  34661. /**
  34662. * Returns a boolean indicating if the scene is still loading data
  34663. */
  34664. readonly isLoading: boolean;
  34665. /**
  34666. * Registers a function to be executed when the scene is ready
  34667. * @param {Function} func - the function to be executed
  34668. */
  34669. executeWhenReady(func: () => void): void;
  34670. /**
  34671. * Returns a promise that resolves when the scene is ready
  34672. * @returns A promise that resolves when the scene is ready
  34673. */
  34674. whenReadyAsync(): Promise<void>;
  34675. /** @hidden */
  34676. _checkIsReady(): void;
  34677. /**
  34678. * Gets all animatable attached to the scene
  34679. */
  34680. readonly animatables: Animatable[];
  34681. /**
  34682. * Resets the last animation time frame.
  34683. * Useful to override when animations start running when loading a scene for the first time.
  34684. */
  34685. resetLastAnimationTimeFrame(): void;
  34686. /**
  34687. * Gets the current view matrix
  34688. * @returns a Matrix
  34689. */
  34690. getViewMatrix(): Matrix;
  34691. /**
  34692. * Gets the current projection matrix
  34693. * @returns a Matrix
  34694. */
  34695. getProjectionMatrix(): Matrix;
  34696. /**
  34697. * Gets the current transform matrix
  34698. * @returns a Matrix made of View * Projection
  34699. */
  34700. getTransformMatrix(): Matrix;
  34701. /**
  34702. * Sets the current transform matrix
  34703. * @param viewL defines the View matrix to use
  34704. * @param projectionL defines the Projection matrix to use
  34705. * @param viewR defines the right View matrix to use (if provided)
  34706. * @param projectionR defines the right Projection matrix to use (if provided)
  34707. */
  34708. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34709. /**
  34710. * Gets the uniform buffer used to store scene data
  34711. * @returns a UniformBuffer
  34712. */
  34713. getSceneUniformBuffer(): UniformBuffer;
  34714. /**
  34715. * Gets an unique (relatively to the current scene) Id
  34716. * @returns an unique number for the scene
  34717. */
  34718. getUniqueId(): number;
  34719. /**
  34720. * Add a mesh to the list of scene's meshes
  34721. * @param newMesh defines the mesh to add
  34722. * @param recursive if all child meshes should also be added to the scene
  34723. */
  34724. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34725. /**
  34726. * Remove a mesh for the list of scene's meshes
  34727. * @param toRemove defines the mesh to remove
  34728. * @param recursive if all child meshes should also be removed from the scene
  34729. * @returns the index where the mesh was in the mesh list
  34730. */
  34731. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34732. /**
  34733. * Add a transform node to the list of scene's transform nodes
  34734. * @param newTransformNode defines the transform node to add
  34735. */
  34736. addTransformNode(newTransformNode: TransformNode): void;
  34737. /**
  34738. * Remove a transform node for the list of scene's transform nodes
  34739. * @param toRemove defines the transform node to remove
  34740. * @returns the index where the transform node was in the transform node list
  34741. */
  34742. removeTransformNode(toRemove: TransformNode): number;
  34743. /**
  34744. * Remove a skeleton for the list of scene's skeletons
  34745. * @param toRemove defines the skeleton to remove
  34746. * @returns the index where the skeleton was in the skeleton list
  34747. */
  34748. removeSkeleton(toRemove: Skeleton): number;
  34749. /**
  34750. * Remove a morph target for the list of scene's morph targets
  34751. * @param toRemove defines the morph target to remove
  34752. * @returns the index where the morph target was in the morph target list
  34753. */
  34754. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34755. /**
  34756. * Remove a light for the list of scene's lights
  34757. * @param toRemove defines the light to remove
  34758. * @returns the index where the light was in the light list
  34759. */
  34760. removeLight(toRemove: Light): number;
  34761. /**
  34762. * Remove a camera for the list of scene's cameras
  34763. * @param toRemove defines the camera to remove
  34764. * @returns the index where the camera was in the camera list
  34765. */
  34766. removeCamera(toRemove: Camera): number;
  34767. /**
  34768. * Remove a particle system for the list of scene's particle systems
  34769. * @param toRemove defines the particle system to remove
  34770. * @returns the index where the particle system was in the particle system list
  34771. */
  34772. removeParticleSystem(toRemove: IParticleSystem): number;
  34773. /**
  34774. * Remove a animation for the list of scene's animations
  34775. * @param toRemove defines the animation to remove
  34776. * @returns the index where the animation was in the animation list
  34777. */
  34778. removeAnimation(toRemove: Animation): number;
  34779. /**
  34780. * Will stop the animation of the given target
  34781. * @param target - the target
  34782. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34783. * @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)
  34784. */
  34785. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34786. /**
  34787. * Removes the given animation group from this scene.
  34788. * @param toRemove The animation group to remove
  34789. * @returns The index of the removed animation group
  34790. */
  34791. removeAnimationGroup(toRemove: AnimationGroup): number;
  34792. /**
  34793. * Removes the given multi-material from this scene.
  34794. * @param toRemove The multi-material to remove
  34795. * @returns The index of the removed multi-material
  34796. */
  34797. removeMultiMaterial(toRemove: MultiMaterial): number;
  34798. /**
  34799. * Removes the given material from this scene.
  34800. * @param toRemove The material to remove
  34801. * @returns The index of the removed material
  34802. */
  34803. removeMaterial(toRemove: Material): number;
  34804. /**
  34805. * Removes the given action manager from this scene.
  34806. * @param toRemove The action manager to remove
  34807. * @returns The index of the removed action manager
  34808. */
  34809. removeActionManager(toRemove: AbstractActionManager): number;
  34810. /**
  34811. * Removes the given texture from this scene.
  34812. * @param toRemove The texture to remove
  34813. * @returns The index of the removed texture
  34814. */
  34815. removeTexture(toRemove: BaseTexture): number;
  34816. /**
  34817. * Adds the given light to this scene
  34818. * @param newLight The light to add
  34819. */
  34820. addLight(newLight: Light): void;
  34821. /**
  34822. * Sorts the list list based on light priorities
  34823. */
  34824. sortLightsByPriority(): void;
  34825. /**
  34826. * Adds the given camera to this scene
  34827. * @param newCamera The camera to add
  34828. */
  34829. addCamera(newCamera: Camera): void;
  34830. /**
  34831. * Adds the given skeleton to this scene
  34832. * @param newSkeleton The skeleton to add
  34833. */
  34834. addSkeleton(newSkeleton: Skeleton): void;
  34835. /**
  34836. * Adds the given particle system to this scene
  34837. * @param newParticleSystem The particle system to add
  34838. */
  34839. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34840. /**
  34841. * Adds the given animation to this scene
  34842. * @param newAnimation The animation to add
  34843. */
  34844. addAnimation(newAnimation: Animation): void;
  34845. /**
  34846. * Adds the given animation group to this scene.
  34847. * @param newAnimationGroup The animation group to add
  34848. */
  34849. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34850. /**
  34851. * Adds the given multi-material to this scene
  34852. * @param newMultiMaterial The multi-material to add
  34853. */
  34854. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34855. /**
  34856. * Adds the given material to this scene
  34857. * @param newMaterial The material to add
  34858. */
  34859. addMaterial(newMaterial: Material): void;
  34860. /**
  34861. * Adds the given morph target to this scene
  34862. * @param newMorphTargetManager The morph target to add
  34863. */
  34864. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34865. /**
  34866. * Adds the given geometry to this scene
  34867. * @param newGeometry The geometry to add
  34868. */
  34869. addGeometry(newGeometry: Geometry): void;
  34870. /**
  34871. * Adds the given action manager to this scene
  34872. * @param newActionManager The action manager to add
  34873. */
  34874. addActionManager(newActionManager: AbstractActionManager): void;
  34875. /**
  34876. * Adds the given texture to this scene.
  34877. * @param newTexture The texture to add
  34878. */
  34879. addTexture(newTexture: BaseTexture): void;
  34880. /**
  34881. * Switch active camera
  34882. * @param newCamera defines the new active camera
  34883. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34884. */
  34885. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34886. /**
  34887. * sets the active camera of the scene using its ID
  34888. * @param id defines the camera's ID
  34889. * @return the new active camera or null if none found.
  34890. */
  34891. setActiveCameraByID(id: string): Nullable<Camera>;
  34892. /**
  34893. * sets the active camera of the scene using its name
  34894. * @param name defines the camera's name
  34895. * @returns the new active camera or null if none found.
  34896. */
  34897. setActiveCameraByName(name: string): Nullable<Camera>;
  34898. /**
  34899. * get an animation group using its name
  34900. * @param name defines the material's name
  34901. * @return the animation group or null if none found.
  34902. */
  34903. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34904. /**
  34905. * Get a material using its unique id
  34906. * @param uniqueId defines the material's unique id
  34907. * @return the material or null if none found.
  34908. */
  34909. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34910. /**
  34911. * get a material using its id
  34912. * @param id defines the material's ID
  34913. * @return the material or null if none found.
  34914. */
  34915. getMaterialByID(id: string): Nullable<Material>;
  34916. /**
  34917. * Gets a the last added material using a given id
  34918. * @param id defines the material's ID
  34919. * @return the last material with the given id or null if none found.
  34920. */
  34921. getLastMaterialByID(id: string): Nullable<Material>;
  34922. /**
  34923. * Gets a material using its name
  34924. * @param name defines the material's name
  34925. * @return the material or null if none found.
  34926. */
  34927. getMaterialByName(name: string): Nullable<Material>;
  34928. /**
  34929. * Get a texture using its unique id
  34930. * @param uniqueId defines the texture's unique id
  34931. * @return the texture or null if none found.
  34932. */
  34933. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34934. /**
  34935. * Gets a camera using its id
  34936. * @param id defines the id to look for
  34937. * @returns the camera or null if not found
  34938. */
  34939. getCameraByID(id: string): Nullable<Camera>;
  34940. /**
  34941. * Gets a camera using its unique id
  34942. * @param uniqueId defines the unique id to look for
  34943. * @returns the camera or null if not found
  34944. */
  34945. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34946. /**
  34947. * Gets a camera using its name
  34948. * @param name defines the camera's name
  34949. * @return the camera or null if none found.
  34950. */
  34951. getCameraByName(name: string): Nullable<Camera>;
  34952. /**
  34953. * Gets a bone using its id
  34954. * @param id defines the bone's id
  34955. * @return the bone or null if not found
  34956. */
  34957. getBoneByID(id: string): Nullable<Bone>;
  34958. /**
  34959. * Gets a bone using its id
  34960. * @param name defines the bone's name
  34961. * @return the bone or null if not found
  34962. */
  34963. getBoneByName(name: string): Nullable<Bone>;
  34964. /**
  34965. * Gets a light node using its name
  34966. * @param name defines the the light's name
  34967. * @return the light or null if none found.
  34968. */
  34969. getLightByName(name: string): Nullable<Light>;
  34970. /**
  34971. * Gets a light node using its id
  34972. * @param id defines the light's id
  34973. * @return the light or null if none found.
  34974. */
  34975. getLightByID(id: string): Nullable<Light>;
  34976. /**
  34977. * Gets a light node using its scene-generated unique ID
  34978. * @param uniqueId defines the light's unique id
  34979. * @return the light or null if none found.
  34980. */
  34981. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34982. /**
  34983. * Gets a particle system by id
  34984. * @param id defines the particle system id
  34985. * @return the corresponding system or null if none found
  34986. */
  34987. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34988. /**
  34989. * Gets a geometry using its ID
  34990. * @param id defines the geometry's id
  34991. * @return the geometry or null if none found.
  34992. */
  34993. getGeometryByID(id: string): Nullable<Geometry>;
  34994. private _getGeometryByUniqueID;
  34995. /**
  34996. * Add a new geometry to this scene
  34997. * @param geometry defines the geometry to be added to the scene.
  34998. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34999. * @return a boolean defining if the geometry was added or not
  35000. */
  35001. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35002. /**
  35003. * Removes an existing geometry
  35004. * @param geometry defines the geometry to be removed from the scene
  35005. * @return a boolean defining if the geometry was removed or not
  35006. */
  35007. removeGeometry(geometry: Geometry): boolean;
  35008. /**
  35009. * Gets the list of geometries attached to the scene
  35010. * @returns an array of Geometry
  35011. */
  35012. getGeometries(): Geometry[];
  35013. /**
  35014. * Gets the first added mesh found of a given ID
  35015. * @param id defines the id to search for
  35016. * @return the mesh found or null if not found at all
  35017. */
  35018. getMeshByID(id: string): Nullable<AbstractMesh>;
  35019. /**
  35020. * Gets a list of meshes using their id
  35021. * @param id defines the id to search for
  35022. * @returns a list of meshes
  35023. */
  35024. getMeshesByID(id: string): Array<AbstractMesh>;
  35025. /**
  35026. * Gets the first added transform node found of a given ID
  35027. * @param id defines the id to search for
  35028. * @return the found transform node or null if not found at all.
  35029. */
  35030. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35031. /**
  35032. * Gets a transform node with its auto-generated unique id
  35033. * @param uniqueId efines the unique id to search for
  35034. * @return the found transform node or null if not found at all.
  35035. */
  35036. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35037. /**
  35038. * Gets a list of transform nodes using their id
  35039. * @param id defines the id to search for
  35040. * @returns a list of transform nodes
  35041. */
  35042. getTransformNodesByID(id: string): Array<TransformNode>;
  35043. /**
  35044. * Gets a mesh with its auto-generated unique id
  35045. * @param uniqueId defines the unique id to search for
  35046. * @return the found mesh or null if not found at all.
  35047. */
  35048. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35049. /**
  35050. * Gets a the last added mesh using a given id
  35051. * @param id defines the id to search for
  35052. * @return the found mesh or null if not found at all.
  35053. */
  35054. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35055. /**
  35056. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35057. * @param id defines the id to search for
  35058. * @return the found node or null if not found at all
  35059. */
  35060. getLastEntryByID(id: string): Nullable<Node>;
  35061. /**
  35062. * Gets a node (Mesh, Camera, Light) using a given id
  35063. * @param id defines the id to search for
  35064. * @return the found node or null if not found at all
  35065. */
  35066. getNodeByID(id: string): Nullable<Node>;
  35067. /**
  35068. * Gets a node (Mesh, Camera, Light) using a given name
  35069. * @param name defines the name to search for
  35070. * @return the found node or null if not found at all.
  35071. */
  35072. getNodeByName(name: string): Nullable<Node>;
  35073. /**
  35074. * Gets a mesh using a given name
  35075. * @param name defines the name to search for
  35076. * @return the found mesh or null if not found at all.
  35077. */
  35078. getMeshByName(name: string): Nullable<AbstractMesh>;
  35079. /**
  35080. * Gets a transform node using a given name
  35081. * @param name defines the name to search for
  35082. * @return the found transform node or null if not found at all.
  35083. */
  35084. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35085. /**
  35086. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35087. * @param id defines the id to search for
  35088. * @return the found skeleton or null if not found at all.
  35089. */
  35090. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35091. /**
  35092. * Gets a skeleton using a given auto generated unique id
  35093. * @param uniqueId defines the unique id to search for
  35094. * @return the found skeleton or null if not found at all.
  35095. */
  35096. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35097. /**
  35098. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35099. * @param id defines the id to search for
  35100. * @return the found skeleton or null if not found at all.
  35101. */
  35102. getSkeletonById(id: string): Nullable<Skeleton>;
  35103. /**
  35104. * Gets a skeleton using a given name
  35105. * @param name defines the name to search for
  35106. * @return the found skeleton or null if not found at all.
  35107. */
  35108. getSkeletonByName(name: string): Nullable<Skeleton>;
  35109. /**
  35110. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35111. * @param id defines the id to search for
  35112. * @return the found morph target manager or null if not found at all.
  35113. */
  35114. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35115. /**
  35116. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35117. * @param id defines the id to search for
  35118. * @return the found morph target or null if not found at all.
  35119. */
  35120. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35121. /**
  35122. * Gets a boolean indicating if the given mesh is active
  35123. * @param mesh defines the mesh to look for
  35124. * @returns true if the mesh is in the active list
  35125. */
  35126. isActiveMesh(mesh: AbstractMesh): boolean;
  35127. /**
  35128. * Return a unique id as a string which can serve as an identifier for the scene
  35129. */
  35130. readonly uid: string;
  35131. /**
  35132. * Add an externaly attached data from its key.
  35133. * This method call will fail and return false, if such key already exists.
  35134. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35135. * @param key the unique key that identifies the data
  35136. * @param data the data object to associate to the key for this Engine instance
  35137. * @return true if no such key were already present and the data was added successfully, false otherwise
  35138. */
  35139. addExternalData<T>(key: string, data: T): boolean;
  35140. /**
  35141. * Get an externaly attached data from its key
  35142. * @param key the unique key that identifies the data
  35143. * @return the associated data, if present (can be null), or undefined if not present
  35144. */
  35145. getExternalData<T>(key: string): Nullable<T>;
  35146. /**
  35147. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35148. * @param key the unique key that identifies the data
  35149. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35150. * @return the associated data, can be null if the factory returned null.
  35151. */
  35152. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35153. /**
  35154. * Remove an externaly attached data from the Engine instance
  35155. * @param key the unique key that identifies the data
  35156. * @return true if the data was successfully removed, false if it doesn't exist
  35157. */
  35158. removeExternalData(key: string): boolean;
  35159. private _evaluateSubMesh;
  35160. /**
  35161. * Clear the processed materials smart array preventing retention point in material dispose.
  35162. */
  35163. freeProcessedMaterials(): void;
  35164. private _preventFreeActiveMeshesAndRenderingGroups;
  35165. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35166. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35167. * when disposing several meshes in a row or a hierarchy of meshes.
  35168. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35169. */
  35170. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35171. /**
  35172. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35173. */
  35174. freeActiveMeshes(): void;
  35175. /**
  35176. * Clear the info related to rendering groups preventing retention points during dispose.
  35177. */
  35178. freeRenderingGroups(): void;
  35179. /** @hidden */
  35180. _isInIntermediateRendering(): boolean;
  35181. /**
  35182. * Lambda returning the list of potentially active meshes.
  35183. */
  35184. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35185. /**
  35186. * Lambda returning the list of potentially active sub meshes.
  35187. */
  35188. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35189. /**
  35190. * Lambda returning the list of potentially intersecting sub meshes.
  35191. */
  35192. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35193. /**
  35194. * Lambda returning the list of potentially colliding sub meshes.
  35195. */
  35196. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35197. private _activeMeshesFrozen;
  35198. /**
  35199. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35200. * @returns the current scene
  35201. */
  35202. freezeActiveMeshes(): Scene;
  35203. /**
  35204. * Use this function to restart evaluating active meshes on every frame
  35205. * @returns the current scene
  35206. */
  35207. unfreezeActiveMeshes(): Scene;
  35208. private _evaluateActiveMeshes;
  35209. private _activeMesh;
  35210. /**
  35211. * Update the transform matrix to update from the current active camera
  35212. * @param force defines a boolean used to force the update even if cache is up to date
  35213. */
  35214. updateTransformMatrix(force?: boolean): void;
  35215. private _bindFrameBuffer;
  35216. /** @hidden */
  35217. _allowPostProcessClearColor: boolean;
  35218. /** @hidden */
  35219. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35220. private _processSubCameras;
  35221. private _checkIntersections;
  35222. /** @hidden */
  35223. _advancePhysicsEngineStep(step: number): void;
  35224. /**
  35225. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35226. */
  35227. getDeterministicFrameTime: () => number;
  35228. /** @hidden */
  35229. _animate(): void;
  35230. /** Execute all animations (for a frame) */
  35231. animate(): void;
  35232. /**
  35233. * Render the scene
  35234. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35235. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35236. */
  35237. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35238. /**
  35239. * Freeze all materials
  35240. * A frozen material will not be updatable but should be faster to render
  35241. */
  35242. freezeMaterials(): void;
  35243. /**
  35244. * Unfreeze all materials
  35245. * A frozen material will not be updatable but should be faster to render
  35246. */
  35247. unfreezeMaterials(): void;
  35248. /**
  35249. * Releases all held ressources
  35250. */
  35251. dispose(): void;
  35252. /**
  35253. * Gets if the scene is already disposed
  35254. */
  35255. readonly isDisposed: boolean;
  35256. /**
  35257. * Call this function to reduce memory footprint of the scene.
  35258. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35259. */
  35260. clearCachedVertexData(): void;
  35261. /**
  35262. * This function will remove the local cached buffer data from texture.
  35263. * It will save memory but will prevent the texture from being rebuilt
  35264. */
  35265. cleanCachedTextureBuffer(): void;
  35266. /**
  35267. * Get the world extend vectors with an optional filter
  35268. *
  35269. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35270. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35271. */
  35272. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35273. min: Vector3;
  35274. max: Vector3;
  35275. };
  35276. /**
  35277. * Creates a ray that can be used to pick in the scene
  35278. * @param x defines the x coordinate of the origin (on-screen)
  35279. * @param y defines the y coordinate of the origin (on-screen)
  35280. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35281. * @param camera defines the camera to use for the picking
  35282. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35283. * @returns a Ray
  35284. */
  35285. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35286. /**
  35287. * Creates a ray that can be used to pick in the scene
  35288. * @param x defines the x coordinate of the origin (on-screen)
  35289. * @param y defines the y coordinate of the origin (on-screen)
  35290. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35291. * @param result defines the ray where to store the picking ray
  35292. * @param camera defines the camera to use for the picking
  35293. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35294. * @returns the current scene
  35295. */
  35296. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35297. /**
  35298. * Creates a ray that can be used to pick in the scene
  35299. * @param x defines the x coordinate of the origin (on-screen)
  35300. * @param y defines the y coordinate of the origin (on-screen)
  35301. * @param camera defines the camera to use for the picking
  35302. * @returns a Ray
  35303. */
  35304. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35305. /**
  35306. * Creates a ray that can be used to pick in the scene
  35307. * @param x defines the x coordinate of the origin (on-screen)
  35308. * @param y defines the y coordinate of the origin (on-screen)
  35309. * @param result defines the ray where to store the picking ray
  35310. * @param camera defines the camera to use for the picking
  35311. * @returns the current scene
  35312. */
  35313. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35314. /** Launch a ray to try to pick a mesh in the scene
  35315. * @param x position on screen
  35316. * @param y position on screen
  35317. * @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
  35318. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35319. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35320. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35321. * @returns a PickingInfo
  35322. */
  35323. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35324. /** Use the given ray to pick a mesh in the scene
  35325. * @param ray The ray to use to pick meshes
  35326. * @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
  35327. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35328. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35329. * @returns a PickingInfo
  35330. */
  35331. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35332. /**
  35333. * Launch a ray to try to pick a mesh in the scene
  35334. * @param x X position on screen
  35335. * @param y Y position on screen
  35336. * @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
  35337. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35338. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35339. * @returns an array of PickingInfo
  35340. */
  35341. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35342. /**
  35343. * Launch a ray to try to pick a mesh in the scene
  35344. * @param ray Ray to use
  35345. * @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
  35346. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35347. * @returns an array of PickingInfo
  35348. */
  35349. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35350. /**
  35351. * Force the value of meshUnderPointer
  35352. * @param mesh defines the mesh to use
  35353. */
  35354. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35355. /**
  35356. * Gets the mesh under the pointer
  35357. * @returns a Mesh or null if no mesh is under the pointer
  35358. */
  35359. getPointerOverMesh(): Nullable<AbstractMesh>;
  35360. /** @hidden */
  35361. _rebuildGeometries(): void;
  35362. /** @hidden */
  35363. _rebuildTextures(): void;
  35364. private _getByTags;
  35365. /**
  35366. * Get a list of meshes by tags
  35367. * @param tagsQuery defines the tags query to use
  35368. * @param forEach defines a predicate used to filter results
  35369. * @returns an array of Mesh
  35370. */
  35371. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35372. /**
  35373. * Get a list of cameras by tags
  35374. * @param tagsQuery defines the tags query to use
  35375. * @param forEach defines a predicate used to filter results
  35376. * @returns an array of Camera
  35377. */
  35378. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35379. /**
  35380. * Get a list of lights by tags
  35381. * @param tagsQuery defines the tags query to use
  35382. * @param forEach defines a predicate used to filter results
  35383. * @returns an array of Light
  35384. */
  35385. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35386. /**
  35387. * Get a list of materials by tags
  35388. * @param tagsQuery defines the tags query to use
  35389. * @param forEach defines a predicate used to filter results
  35390. * @returns an array of Material
  35391. */
  35392. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35393. /**
  35394. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35395. * This allowed control for front to back rendering or reversly depending of the special needs.
  35396. *
  35397. * @param renderingGroupId The rendering group id corresponding to its index
  35398. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35399. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35400. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35401. */
  35402. 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;
  35403. /**
  35404. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35405. *
  35406. * @param renderingGroupId The rendering group id corresponding to its index
  35407. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35408. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35409. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35410. */
  35411. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35412. /**
  35413. * Gets the current auto clear configuration for one rendering group of the rendering
  35414. * manager.
  35415. * @param index the rendering group index to get the information for
  35416. * @returns The auto clear setup for the requested rendering group
  35417. */
  35418. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35419. private _blockMaterialDirtyMechanism;
  35420. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35421. blockMaterialDirtyMechanism: boolean;
  35422. /**
  35423. * Will flag all materials as dirty to trigger new shader compilation
  35424. * @param flag defines the flag used to specify which material part must be marked as dirty
  35425. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35426. */
  35427. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35428. /** @hidden */
  35429. _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;
  35430. /** @hidden */
  35431. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35432. }
  35433. }
  35434. declare module "babylonjs/assetContainer" {
  35435. import { AbstractScene } from "babylonjs/abstractScene";
  35436. import { Scene } from "babylonjs/scene";
  35437. import { Mesh } from "babylonjs/Meshes/mesh";
  35438. /**
  35439. * Set of assets to keep when moving a scene into an asset container.
  35440. */
  35441. export class KeepAssets extends AbstractScene {
  35442. }
  35443. /**
  35444. * Container with a set of assets that can be added or removed from a scene.
  35445. */
  35446. export class AssetContainer extends AbstractScene {
  35447. /**
  35448. * The scene the AssetContainer belongs to.
  35449. */
  35450. scene: Scene;
  35451. /**
  35452. * Instantiates an AssetContainer.
  35453. * @param scene The scene the AssetContainer belongs to.
  35454. */
  35455. constructor(scene: Scene);
  35456. /**
  35457. * Adds all the assets from the container to the scene.
  35458. */
  35459. addAllToScene(): void;
  35460. /**
  35461. * Removes all the assets in the container from the scene
  35462. */
  35463. removeAllFromScene(): void;
  35464. /**
  35465. * Disposes all the assets in the container
  35466. */
  35467. dispose(): void;
  35468. private _moveAssets;
  35469. /**
  35470. * Removes all the assets contained in the scene and adds them to the container.
  35471. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35472. */
  35473. moveAllFromScene(keepAssets?: KeepAssets): void;
  35474. /**
  35475. * 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.
  35476. * @returns the root mesh
  35477. */
  35478. createRootMesh(): Mesh;
  35479. }
  35480. }
  35481. declare module "babylonjs/abstractScene" {
  35482. import { Scene } from "babylonjs/scene";
  35483. import { Nullable } from "babylonjs/types";
  35484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35486. import { Geometry } from "babylonjs/Meshes/geometry";
  35487. import { Skeleton } from "babylonjs/Bones/skeleton";
  35488. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35489. import { AssetContainer } from "babylonjs/assetContainer";
  35490. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35491. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35493. import { Material } from "babylonjs/Materials/material";
  35494. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35495. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35496. import { Camera } from "babylonjs/Cameras/camera";
  35497. import { Light } from "babylonjs/Lights/light";
  35498. import { Node } from "babylonjs/node";
  35499. import { Animation } from "babylonjs/Animations/animation";
  35500. /**
  35501. * Defines how the parser contract is defined.
  35502. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35503. */
  35504. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35505. /**
  35506. * Defines how the individual parser contract is defined.
  35507. * These parser can parse an individual asset
  35508. */
  35509. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35510. /**
  35511. * Base class of the scene acting as a container for the different elements composing a scene.
  35512. * This class is dynamically extended by the different components of the scene increasing
  35513. * flexibility and reducing coupling
  35514. */
  35515. export abstract class AbstractScene {
  35516. /**
  35517. * Stores the list of available parsers in the application.
  35518. */
  35519. private static _BabylonFileParsers;
  35520. /**
  35521. * Stores the list of available individual parsers in the application.
  35522. */
  35523. private static _IndividualBabylonFileParsers;
  35524. /**
  35525. * Adds a parser in the list of available ones
  35526. * @param name Defines the name of the parser
  35527. * @param parser Defines the parser to add
  35528. */
  35529. static AddParser(name: string, parser: BabylonFileParser): void;
  35530. /**
  35531. * Gets a general parser from the list of avaialble ones
  35532. * @param name Defines the name of the parser
  35533. * @returns the requested parser or null
  35534. */
  35535. static GetParser(name: string): Nullable<BabylonFileParser>;
  35536. /**
  35537. * Adds n individual parser in the list of available ones
  35538. * @param name Defines the name of the parser
  35539. * @param parser Defines the parser to add
  35540. */
  35541. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35542. /**
  35543. * Gets an individual parser from the list of avaialble ones
  35544. * @param name Defines the name of the parser
  35545. * @returns the requested parser or null
  35546. */
  35547. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35548. /**
  35549. * Parser json data and populate both a scene and its associated container object
  35550. * @param jsonData Defines the data to parse
  35551. * @param scene Defines the scene to parse the data for
  35552. * @param container Defines the container attached to the parsing sequence
  35553. * @param rootUrl Defines the root url of the data
  35554. */
  35555. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35556. /**
  35557. * Gets the list of root nodes (ie. nodes with no parent)
  35558. */
  35559. rootNodes: Node[];
  35560. /** All of the cameras added to this scene
  35561. * @see http://doc.babylonjs.com/babylon101/cameras
  35562. */
  35563. cameras: Camera[];
  35564. /**
  35565. * All of the lights added to this scene
  35566. * @see http://doc.babylonjs.com/babylon101/lights
  35567. */
  35568. lights: Light[];
  35569. /**
  35570. * All of the (abstract) meshes added to this scene
  35571. */
  35572. meshes: AbstractMesh[];
  35573. /**
  35574. * The list of skeletons added to the scene
  35575. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35576. */
  35577. skeletons: Skeleton[];
  35578. /**
  35579. * All of the particle systems added to this scene
  35580. * @see http://doc.babylonjs.com/babylon101/particles
  35581. */
  35582. particleSystems: IParticleSystem[];
  35583. /**
  35584. * Gets a list of Animations associated with the scene
  35585. */
  35586. animations: Animation[];
  35587. /**
  35588. * All of the animation groups added to this scene
  35589. * @see http://doc.babylonjs.com/how_to/group
  35590. */
  35591. animationGroups: AnimationGroup[];
  35592. /**
  35593. * All of the multi-materials added to this scene
  35594. * @see http://doc.babylonjs.com/how_to/multi_materials
  35595. */
  35596. multiMaterials: MultiMaterial[];
  35597. /**
  35598. * All of the materials added to this scene
  35599. * In the context of a Scene, it is not supposed to be modified manually.
  35600. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35601. * Note also that the order of the Material wihin the array is not significant and might change.
  35602. * @see http://doc.babylonjs.com/babylon101/materials
  35603. */
  35604. materials: Material[];
  35605. /**
  35606. * The list of morph target managers added to the scene
  35607. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35608. */
  35609. morphTargetManagers: MorphTargetManager[];
  35610. /**
  35611. * The list of geometries used in the scene.
  35612. */
  35613. geometries: Geometry[];
  35614. /**
  35615. * All of the tranform nodes added to this scene
  35616. * In the context of a Scene, it is not supposed to be modified manually.
  35617. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35618. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35619. * @see http://doc.babylonjs.com/how_to/transformnode
  35620. */
  35621. transformNodes: TransformNode[];
  35622. /**
  35623. * ActionManagers available on the scene.
  35624. */
  35625. actionManagers: AbstractActionManager[];
  35626. /**
  35627. * Textures to keep.
  35628. */
  35629. textures: BaseTexture[];
  35630. /**
  35631. * Environment texture for the scene
  35632. */
  35633. environmentTexture: Nullable<BaseTexture>;
  35634. }
  35635. }
  35636. declare module "babylonjs/Audio/sound" {
  35637. import { Observable } from "babylonjs/Misc/observable";
  35638. import { Vector3 } from "babylonjs/Maths/math.vector";
  35639. import { Nullable } from "babylonjs/types";
  35640. import { Scene } from "babylonjs/scene";
  35641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35642. /**
  35643. * Interface used to define options for Sound class
  35644. */
  35645. export interface ISoundOptions {
  35646. /**
  35647. * Does the sound autoplay once loaded.
  35648. */
  35649. autoplay?: boolean;
  35650. /**
  35651. * Does the sound loop after it finishes playing once.
  35652. */
  35653. loop?: boolean;
  35654. /**
  35655. * Sound's volume
  35656. */
  35657. volume?: number;
  35658. /**
  35659. * Is it a spatial sound?
  35660. */
  35661. spatialSound?: boolean;
  35662. /**
  35663. * Maximum distance to hear that sound
  35664. */
  35665. maxDistance?: number;
  35666. /**
  35667. * Uses user defined attenuation function
  35668. */
  35669. useCustomAttenuation?: boolean;
  35670. /**
  35671. * Define the roll off factor of spatial sounds.
  35672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35673. */
  35674. rolloffFactor?: number;
  35675. /**
  35676. * Define the reference distance the sound should be heard perfectly.
  35677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35678. */
  35679. refDistance?: number;
  35680. /**
  35681. * Define the distance attenuation model the sound will follow.
  35682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35683. */
  35684. distanceModel?: string;
  35685. /**
  35686. * Defines the playback speed (1 by default)
  35687. */
  35688. playbackRate?: number;
  35689. /**
  35690. * Defines if the sound is from a streaming source
  35691. */
  35692. streaming?: boolean;
  35693. /**
  35694. * Defines an optional length (in seconds) inside the sound file
  35695. */
  35696. length?: number;
  35697. /**
  35698. * Defines an optional offset (in seconds) inside the sound file
  35699. */
  35700. offset?: number;
  35701. /**
  35702. * If true, URLs will not be required to state the audio file codec to use.
  35703. */
  35704. skipCodecCheck?: boolean;
  35705. }
  35706. /**
  35707. * Defines a sound that can be played in the application.
  35708. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35710. */
  35711. export class Sound {
  35712. /**
  35713. * The name of the sound in the scene.
  35714. */
  35715. name: string;
  35716. /**
  35717. * Does the sound autoplay once loaded.
  35718. */
  35719. autoplay: boolean;
  35720. /**
  35721. * Does the sound loop after it finishes playing once.
  35722. */
  35723. loop: boolean;
  35724. /**
  35725. * Does the sound use a custom attenuation curve to simulate the falloff
  35726. * happening when the source gets further away from the camera.
  35727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35728. */
  35729. useCustomAttenuation: boolean;
  35730. /**
  35731. * The sound track id this sound belongs to.
  35732. */
  35733. soundTrackId: number;
  35734. /**
  35735. * Is this sound currently played.
  35736. */
  35737. isPlaying: boolean;
  35738. /**
  35739. * Is this sound currently paused.
  35740. */
  35741. isPaused: boolean;
  35742. /**
  35743. * Does this sound enables spatial sound.
  35744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35745. */
  35746. spatialSound: boolean;
  35747. /**
  35748. * Define the reference distance the sound should be heard perfectly.
  35749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35750. */
  35751. refDistance: number;
  35752. /**
  35753. * Define the roll off factor of spatial sounds.
  35754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35755. */
  35756. rolloffFactor: number;
  35757. /**
  35758. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35760. */
  35761. maxDistance: number;
  35762. /**
  35763. * Define the distance attenuation model the sound will follow.
  35764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35765. */
  35766. distanceModel: string;
  35767. /**
  35768. * @hidden
  35769. * Back Compat
  35770. **/
  35771. onended: () => any;
  35772. /**
  35773. * Observable event when the current playing sound finishes.
  35774. */
  35775. onEndedObservable: Observable<Sound>;
  35776. private _panningModel;
  35777. private _playbackRate;
  35778. private _streaming;
  35779. private _startTime;
  35780. private _startOffset;
  35781. private _position;
  35782. /** @hidden */
  35783. _positionInEmitterSpace: boolean;
  35784. private _localDirection;
  35785. private _volume;
  35786. private _isReadyToPlay;
  35787. private _isDirectional;
  35788. private _readyToPlayCallback;
  35789. private _audioBuffer;
  35790. private _soundSource;
  35791. private _streamingSource;
  35792. private _soundPanner;
  35793. private _soundGain;
  35794. private _inputAudioNode;
  35795. private _outputAudioNode;
  35796. private _coneInnerAngle;
  35797. private _coneOuterAngle;
  35798. private _coneOuterGain;
  35799. private _scene;
  35800. private _connectedTransformNode;
  35801. private _customAttenuationFunction;
  35802. private _registerFunc;
  35803. private _isOutputConnected;
  35804. private _htmlAudioElement;
  35805. private _urlType;
  35806. private _length?;
  35807. private _offset?;
  35808. /** @hidden */
  35809. static _SceneComponentInitialization: (scene: Scene) => void;
  35810. /**
  35811. * Create a sound and attach it to a scene
  35812. * @param name Name of your sound
  35813. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35814. * @param scene defines the scene the sound belongs to
  35815. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35816. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35817. */
  35818. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35819. /**
  35820. * Release the sound and its associated resources
  35821. */
  35822. dispose(): void;
  35823. /**
  35824. * Gets if the sounds is ready to be played or not.
  35825. * @returns true if ready, otherwise false
  35826. */
  35827. isReady(): boolean;
  35828. private _soundLoaded;
  35829. /**
  35830. * Sets the data of the sound from an audiobuffer
  35831. * @param audioBuffer The audioBuffer containing the data
  35832. */
  35833. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35834. /**
  35835. * Updates the current sounds options such as maxdistance, loop...
  35836. * @param options A JSON object containing values named as the object properties
  35837. */
  35838. updateOptions(options: ISoundOptions): void;
  35839. private _createSpatialParameters;
  35840. private _updateSpatialParameters;
  35841. /**
  35842. * Switch the panning model to HRTF:
  35843. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35845. */
  35846. switchPanningModelToHRTF(): void;
  35847. /**
  35848. * Switch the panning model to Equal Power:
  35849. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35851. */
  35852. switchPanningModelToEqualPower(): void;
  35853. private _switchPanningModel;
  35854. /**
  35855. * Connect this sound to a sound track audio node like gain...
  35856. * @param soundTrackAudioNode the sound track audio node to connect to
  35857. */
  35858. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35859. /**
  35860. * Transform this sound into a directional source
  35861. * @param coneInnerAngle Size of the inner cone in degree
  35862. * @param coneOuterAngle Size of the outer cone in degree
  35863. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35864. */
  35865. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35866. /**
  35867. * Gets or sets the inner angle for the directional cone.
  35868. */
  35869. /**
  35870. * Gets or sets the inner angle for the directional cone.
  35871. */
  35872. directionalConeInnerAngle: number;
  35873. /**
  35874. * Gets or sets the outer angle for the directional cone.
  35875. */
  35876. /**
  35877. * Gets or sets the outer angle for the directional cone.
  35878. */
  35879. directionalConeOuterAngle: number;
  35880. /**
  35881. * Sets the position of the emitter if spatial sound is enabled
  35882. * @param newPosition Defines the new posisiton
  35883. */
  35884. setPosition(newPosition: Vector3): void;
  35885. /**
  35886. * Sets the local direction of the emitter if spatial sound is enabled
  35887. * @param newLocalDirection Defines the new local direction
  35888. */
  35889. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35890. private _updateDirection;
  35891. /** @hidden */
  35892. updateDistanceFromListener(): void;
  35893. /**
  35894. * Sets a new custom attenuation function for the sound.
  35895. * @param callback Defines the function used for the attenuation
  35896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35897. */
  35898. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35899. /**
  35900. * Play the sound
  35901. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35902. * @param offset (optional) Start the sound at a specific time in seconds
  35903. * @param length (optional) Sound duration (in seconds)
  35904. */
  35905. play(time?: number, offset?: number, length?: number): void;
  35906. private _onended;
  35907. /**
  35908. * Stop the sound
  35909. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35910. */
  35911. stop(time?: number): void;
  35912. /**
  35913. * Put the sound in pause
  35914. */
  35915. pause(): void;
  35916. /**
  35917. * Sets a dedicated volume for this sounds
  35918. * @param newVolume Define the new volume of the sound
  35919. * @param time Define time for gradual change to new volume
  35920. */
  35921. setVolume(newVolume: number, time?: number): void;
  35922. /**
  35923. * Set the sound play back rate
  35924. * @param newPlaybackRate Define the playback rate the sound should be played at
  35925. */
  35926. setPlaybackRate(newPlaybackRate: number): void;
  35927. /**
  35928. * Gets the volume of the sound.
  35929. * @returns the volume of the sound
  35930. */
  35931. getVolume(): number;
  35932. /**
  35933. * Attach the sound to a dedicated mesh
  35934. * @param transformNode The transform node to connect the sound with
  35935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35936. */
  35937. attachToMesh(transformNode: TransformNode): void;
  35938. /**
  35939. * Detach the sound from the previously attached mesh
  35940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35941. */
  35942. detachFromMesh(): void;
  35943. private _onRegisterAfterWorldMatrixUpdate;
  35944. /**
  35945. * Clone the current sound in the scene.
  35946. * @returns the new sound clone
  35947. */
  35948. clone(): Nullable<Sound>;
  35949. /**
  35950. * Gets the current underlying audio buffer containing the data
  35951. * @returns the audio buffer
  35952. */
  35953. getAudioBuffer(): Nullable<AudioBuffer>;
  35954. /**
  35955. * Serializes the Sound in a JSON representation
  35956. * @returns the JSON representation of the sound
  35957. */
  35958. serialize(): any;
  35959. /**
  35960. * Parse a JSON representation of a sound to innstantiate in a given scene
  35961. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35962. * @param scene Define the scene the new parsed sound should be created in
  35963. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35964. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35965. * @returns the newly parsed sound
  35966. */
  35967. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35968. }
  35969. }
  35970. declare module "babylonjs/Actions/directAudioActions" {
  35971. import { Action } from "babylonjs/Actions/action";
  35972. import { Condition } from "babylonjs/Actions/condition";
  35973. import { Sound } from "babylonjs/Audio/sound";
  35974. /**
  35975. * This defines an action helpful to play a defined sound on a triggered action.
  35976. */
  35977. export class PlaySoundAction extends Action {
  35978. private _sound;
  35979. /**
  35980. * Instantiate the action
  35981. * @param triggerOptions defines the trigger options
  35982. * @param sound defines the sound to play
  35983. * @param condition defines the trigger related conditions
  35984. */
  35985. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35986. /** @hidden */
  35987. _prepare(): void;
  35988. /**
  35989. * Execute the action and play the sound.
  35990. */
  35991. execute(): void;
  35992. /**
  35993. * Serializes the actions and its related information.
  35994. * @param parent defines the object to serialize in
  35995. * @returns the serialized object
  35996. */
  35997. serialize(parent: any): any;
  35998. }
  35999. /**
  36000. * This defines an action helpful to stop a defined sound on a triggered action.
  36001. */
  36002. export class StopSoundAction extends Action {
  36003. private _sound;
  36004. /**
  36005. * Instantiate the action
  36006. * @param triggerOptions defines the trigger options
  36007. * @param sound defines the sound to stop
  36008. * @param condition defines the trigger related conditions
  36009. */
  36010. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36011. /** @hidden */
  36012. _prepare(): void;
  36013. /**
  36014. * Execute the action and stop the sound.
  36015. */
  36016. execute(): void;
  36017. /**
  36018. * Serializes the actions and its related information.
  36019. * @param parent defines the object to serialize in
  36020. * @returns the serialized object
  36021. */
  36022. serialize(parent: any): any;
  36023. }
  36024. }
  36025. declare module "babylonjs/Actions/interpolateValueAction" {
  36026. import { Action } from "babylonjs/Actions/action";
  36027. import { Condition } from "babylonjs/Actions/condition";
  36028. import { Observable } from "babylonjs/Misc/observable";
  36029. /**
  36030. * This defines an action responsible to change the value of a property
  36031. * by interpolating between its current value and the newly set one once triggered.
  36032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36033. */
  36034. export class InterpolateValueAction extends Action {
  36035. /**
  36036. * Defines the path of the property where the value should be interpolated
  36037. */
  36038. propertyPath: string;
  36039. /**
  36040. * Defines the target value at the end of the interpolation.
  36041. */
  36042. value: any;
  36043. /**
  36044. * Defines the time it will take for the property to interpolate to the value.
  36045. */
  36046. duration: number;
  36047. /**
  36048. * Defines if the other scene animations should be stopped when the action has been triggered
  36049. */
  36050. stopOtherAnimations?: boolean;
  36051. /**
  36052. * Defines a callback raised once the interpolation animation has been done.
  36053. */
  36054. onInterpolationDone?: () => void;
  36055. /**
  36056. * Observable triggered once the interpolation animation has been done.
  36057. */
  36058. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36059. private _target;
  36060. private _effectiveTarget;
  36061. private _property;
  36062. /**
  36063. * Instantiate the action
  36064. * @param triggerOptions defines the trigger options
  36065. * @param target defines the object containing the value to interpolate
  36066. * @param propertyPath defines the path to the property in the target object
  36067. * @param value defines the target value at the end of the interpolation
  36068. * @param duration deines the time it will take for the property to interpolate to the value.
  36069. * @param condition defines the trigger related conditions
  36070. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36071. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36072. */
  36073. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36074. /** @hidden */
  36075. _prepare(): void;
  36076. /**
  36077. * Execute the action starts the value interpolation.
  36078. */
  36079. execute(): void;
  36080. /**
  36081. * Serializes the actions and its related information.
  36082. * @param parent defines the object to serialize in
  36083. * @returns the serialized object
  36084. */
  36085. serialize(parent: any): any;
  36086. }
  36087. }
  36088. declare module "babylonjs/Actions/index" {
  36089. export * from "babylonjs/Actions/action";
  36090. export * from "babylonjs/Actions/actionEvent";
  36091. export * from "babylonjs/Actions/actionManager";
  36092. export * from "babylonjs/Actions/condition";
  36093. export * from "babylonjs/Actions/directActions";
  36094. export * from "babylonjs/Actions/directAudioActions";
  36095. export * from "babylonjs/Actions/interpolateValueAction";
  36096. }
  36097. declare module "babylonjs/Animations/index" {
  36098. export * from "babylonjs/Animations/animatable";
  36099. export * from "babylonjs/Animations/animation";
  36100. export * from "babylonjs/Animations/animationGroup";
  36101. export * from "babylonjs/Animations/animationPropertiesOverride";
  36102. export * from "babylonjs/Animations/easing";
  36103. export * from "babylonjs/Animations/runtimeAnimation";
  36104. export * from "babylonjs/Animations/animationEvent";
  36105. export * from "babylonjs/Animations/animationGroup";
  36106. export * from "babylonjs/Animations/animationKey";
  36107. export * from "babylonjs/Animations/animationRange";
  36108. export * from "babylonjs/Animations/animatable.interface";
  36109. }
  36110. declare module "babylonjs/Audio/soundTrack" {
  36111. import { Sound } from "babylonjs/Audio/sound";
  36112. import { Analyser } from "babylonjs/Audio/analyser";
  36113. import { Scene } from "babylonjs/scene";
  36114. /**
  36115. * Options allowed during the creation of a sound track.
  36116. */
  36117. export interface ISoundTrackOptions {
  36118. /**
  36119. * The volume the sound track should take during creation
  36120. */
  36121. volume?: number;
  36122. /**
  36123. * Define if the sound track is the main sound track of the scene
  36124. */
  36125. mainTrack?: boolean;
  36126. }
  36127. /**
  36128. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36129. * It will be also used in a future release to apply effects on a specific track.
  36130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36131. */
  36132. export class SoundTrack {
  36133. /**
  36134. * The unique identifier of the sound track in the scene.
  36135. */
  36136. id: number;
  36137. /**
  36138. * The list of sounds included in the sound track.
  36139. */
  36140. soundCollection: Array<Sound>;
  36141. private _outputAudioNode;
  36142. private _scene;
  36143. private _isMainTrack;
  36144. private _connectedAnalyser;
  36145. private _options;
  36146. private _isInitialized;
  36147. /**
  36148. * Creates a new sound track.
  36149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36150. * @param scene Define the scene the sound track belongs to
  36151. * @param options
  36152. */
  36153. constructor(scene: Scene, options?: ISoundTrackOptions);
  36154. private _initializeSoundTrackAudioGraph;
  36155. /**
  36156. * Release the sound track and its associated resources
  36157. */
  36158. dispose(): void;
  36159. /**
  36160. * Adds a sound to this sound track
  36161. * @param sound define the cound to add
  36162. * @ignoreNaming
  36163. */
  36164. AddSound(sound: Sound): void;
  36165. /**
  36166. * Removes a sound to this sound track
  36167. * @param sound define the cound to remove
  36168. * @ignoreNaming
  36169. */
  36170. RemoveSound(sound: Sound): void;
  36171. /**
  36172. * Set a global volume for the full sound track.
  36173. * @param newVolume Define the new volume of the sound track
  36174. */
  36175. setVolume(newVolume: number): void;
  36176. /**
  36177. * Switch the panning model to HRTF:
  36178. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36180. */
  36181. switchPanningModelToHRTF(): void;
  36182. /**
  36183. * Switch the panning model to Equal Power:
  36184. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36186. */
  36187. switchPanningModelToEqualPower(): void;
  36188. /**
  36189. * Connect the sound track to an audio analyser allowing some amazing
  36190. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36192. * @param analyser The analyser to connect to the engine
  36193. */
  36194. connectToAnalyser(analyser: Analyser): void;
  36195. }
  36196. }
  36197. declare module "babylonjs/Audio/audioSceneComponent" {
  36198. import { Sound } from "babylonjs/Audio/sound";
  36199. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36200. import { Nullable } from "babylonjs/types";
  36201. import { Vector3 } from "babylonjs/Maths/math.vector";
  36202. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36203. import { Scene } from "babylonjs/scene";
  36204. import { AbstractScene } from "babylonjs/abstractScene";
  36205. import "babylonjs/Audio/audioEngine";
  36206. module "babylonjs/abstractScene" {
  36207. interface AbstractScene {
  36208. /**
  36209. * The list of sounds used in the scene.
  36210. */
  36211. sounds: Nullable<Array<Sound>>;
  36212. }
  36213. }
  36214. module "babylonjs/scene" {
  36215. interface Scene {
  36216. /**
  36217. * @hidden
  36218. * Backing field
  36219. */
  36220. _mainSoundTrack: SoundTrack;
  36221. /**
  36222. * The main sound track played by the scene.
  36223. * It cotains your primary collection of sounds.
  36224. */
  36225. mainSoundTrack: SoundTrack;
  36226. /**
  36227. * The list of sound tracks added to the scene
  36228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36229. */
  36230. soundTracks: Nullable<Array<SoundTrack>>;
  36231. /**
  36232. * Gets a sound using a given name
  36233. * @param name defines the name to search for
  36234. * @return the found sound or null if not found at all.
  36235. */
  36236. getSoundByName(name: string): Nullable<Sound>;
  36237. /**
  36238. * Gets or sets if audio support is enabled
  36239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36240. */
  36241. audioEnabled: boolean;
  36242. /**
  36243. * Gets or sets if audio will be output to headphones
  36244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36245. */
  36246. headphone: boolean;
  36247. /**
  36248. * Gets or sets custom audio listener position provider
  36249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36250. */
  36251. audioListenerPositionProvider: Nullable<() => Vector3>;
  36252. }
  36253. }
  36254. /**
  36255. * Defines the sound scene component responsible to manage any sounds
  36256. * in a given scene.
  36257. */
  36258. export class AudioSceneComponent implements ISceneSerializableComponent {
  36259. /**
  36260. * The component name helpfull to identify the component in the list of scene components.
  36261. */
  36262. readonly name: string;
  36263. /**
  36264. * The scene the component belongs to.
  36265. */
  36266. scene: Scene;
  36267. private _audioEnabled;
  36268. /**
  36269. * Gets whether audio is enabled or not.
  36270. * Please use related enable/disable method to switch state.
  36271. */
  36272. readonly audioEnabled: boolean;
  36273. private _headphone;
  36274. /**
  36275. * Gets whether audio is outputing to headphone or not.
  36276. * Please use the according Switch methods to change output.
  36277. */
  36278. readonly headphone: boolean;
  36279. private _audioListenerPositionProvider;
  36280. /**
  36281. * Gets the current audio listener position provider
  36282. */
  36283. /**
  36284. * Sets a custom listener position for all sounds in the scene
  36285. * By default, this is the position of the first active camera
  36286. */
  36287. audioListenerPositionProvider: Nullable<() => Vector3>;
  36288. /**
  36289. * Creates a new instance of the component for the given scene
  36290. * @param scene Defines the scene to register the component in
  36291. */
  36292. constructor(scene: Scene);
  36293. /**
  36294. * Registers the component in a given scene
  36295. */
  36296. register(): void;
  36297. /**
  36298. * Rebuilds the elements related to this component in case of
  36299. * context lost for instance.
  36300. */
  36301. rebuild(): void;
  36302. /**
  36303. * Serializes the component data to the specified json object
  36304. * @param serializationObject The object to serialize to
  36305. */
  36306. serialize(serializationObject: any): void;
  36307. /**
  36308. * Adds all the elements from the container to the scene
  36309. * @param container the container holding the elements
  36310. */
  36311. addFromContainer(container: AbstractScene): void;
  36312. /**
  36313. * Removes all the elements in the container from the scene
  36314. * @param container contains the elements to remove
  36315. * @param dispose if the removed element should be disposed (default: false)
  36316. */
  36317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36318. /**
  36319. * Disposes the component and the associated ressources.
  36320. */
  36321. dispose(): void;
  36322. /**
  36323. * Disables audio in the associated scene.
  36324. */
  36325. disableAudio(): void;
  36326. /**
  36327. * Enables audio in the associated scene.
  36328. */
  36329. enableAudio(): void;
  36330. /**
  36331. * Switch audio to headphone output.
  36332. */
  36333. switchAudioModeForHeadphones(): void;
  36334. /**
  36335. * Switch audio to normal speakers.
  36336. */
  36337. switchAudioModeForNormalSpeakers(): void;
  36338. private _afterRender;
  36339. }
  36340. }
  36341. declare module "babylonjs/Audio/weightedsound" {
  36342. import { Sound } from "babylonjs/Audio/sound";
  36343. /**
  36344. * Wraps one or more Sound objects and selects one with random weight for playback.
  36345. */
  36346. export class WeightedSound {
  36347. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36348. loop: boolean;
  36349. private _coneInnerAngle;
  36350. private _coneOuterAngle;
  36351. private _volume;
  36352. /** A Sound is currently playing. */
  36353. isPlaying: boolean;
  36354. /** A Sound is currently paused. */
  36355. isPaused: boolean;
  36356. private _sounds;
  36357. private _weights;
  36358. private _currentIndex?;
  36359. /**
  36360. * Creates a new WeightedSound from the list of sounds given.
  36361. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36362. * @param sounds Array of Sounds that will be selected from.
  36363. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36364. */
  36365. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36366. /**
  36367. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36368. */
  36369. /**
  36370. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36371. */
  36372. directionalConeInnerAngle: number;
  36373. /**
  36374. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36375. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36376. */
  36377. /**
  36378. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36379. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36380. */
  36381. directionalConeOuterAngle: number;
  36382. /**
  36383. * Playback volume.
  36384. */
  36385. /**
  36386. * Playback volume.
  36387. */
  36388. volume: number;
  36389. private _onended;
  36390. /**
  36391. * Suspend playback
  36392. */
  36393. pause(): void;
  36394. /**
  36395. * Stop playback
  36396. */
  36397. stop(): void;
  36398. /**
  36399. * Start playback.
  36400. * @param startOffset Position the clip head at a specific time in seconds.
  36401. */
  36402. play(startOffset?: number): void;
  36403. }
  36404. }
  36405. declare module "babylonjs/Audio/index" {
  36406. export * from "babylonjs/Audio/analyser";
  36407. export * from "babylonjs/Audio/audioEngine";
  36408. export * from "babylonjs/Audio/audioSceneComponent";
  36409. export * from "babylonjs/Audio/sound";
  36410. export * from "babylonjs/Audio/soundTrack";
  36411. export * from "babylonjs/Audio/weightedsound";
  36412. }
  36413. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36414. import { Behavior } from "babylonjs/Behaviors/behavior";
  36415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36416. import { BackEase } from "babylonjs/Animations/easing";
  36417. /**
  36418. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36420. */
  36421. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36422. /**
  36423. * Gets the name of the behavior.
  36424. */
  36425. readonly name: string;
  36426. /**
  36427. * The easing function used by animations
  36428. */
  36429. static EasingFunction: BackEase;
  36430. /**
  36431. * The easing mode used by animations
  36432. */
  36433. static EasingMode: number;
  36434. /**
  36435. * The duration of the animation, in milliseconds
  36436. */
  36437. transitionDuration: number;
  36438. /**
  36439. * Length of the distance animated by the transition when lower radius is reached
  36440. */
  36441. lowerRadiusTransitionRange: number;
  36442. /**
  36443. * Length of the distance animated by the transition when upper radius is reached
  36444. */
  36445. upperRadiusTransitionRange: number;
  36446. private _autoTransitionRange;
  36447. /**
  36448. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36449. */
  36450. /**
  36451. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36452. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36453. */
  36454. autoTransitionRange: boolean;
  36455. private _attachedCamera;
  36456. private _onAfterCheckInputsObserver;
  36457. private _onMeshTargetChangedObserver;
  36458. /**
  36459. * Initializes the behavior.
  36460. */
  36461. init(): void;
  36462. /**
  36463. * Attaches the behavior to its arc rotate camera.
  36464. * @param camera Defines the camera to attach the behavior to
  36465. */
  36466. attach(camera: ArcRotateCamera): void;
  36467. /**
  36468. * Detaches the behavior from its current arc rotate camera.
  36469. */
  36470. detach(): void;
  36471. private _radiusIsAnimating;
  36472. private _radiusBounceTransition;
  36473. private _animatables;
  36474. private _cachedWheelPrecision;
  36475. /**
  36476. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36477. * @param radiusLimit The limit to check against.
  36478. * @return Bool to indicate if at limit.
  36479. */
  36480. private _isRadiusAtLimit;
  36481. /**
  36482. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36483. * @param radiusDelta The delta by which to animate to. Can be negative.
  36484. */
  36485. private _applyBoundRadiusAnimation;
  36486. /**
  36487. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36488. */
  36489. protected _clearAnimationLocks(): void;
  36490. /**
  36491. * Stops and removes all animations that have been applied to the camera
  36492. */
  36493. stopAllAnimations(): void;
  36494. }
  36495. }
  36496. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36497. import { Behavior } from "babylonjs/Behaviors/behavior";
  36498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36499. import { ExponentialEase } from "babylonjs/Animations/easing";
  36500. import { Nullable } from "babylonjs/types";
  36501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36502. import { Vector3 } from "babylonjs/Maths/math.vector";
  36503. /**
  36504. * 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.
  36505. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36506. */
  36507. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36508. /**
  36509. * Gets the name of the behavior.
  36510. */
  36511. readonly name: string;
  36512. private _mode;
  36513. private _radiusScale;
  36514. private _positionScale;
  36515. private _defaultElevation;
  36516. private _elevationReturnTime;
  36517. private _elevationReturnWaitTime;
  36518. private _zoomStopsAnimation;
  36519. private _framingTime;
  36520. /**
  36521. * The easing function used by animations
  36522. */
  36523. static EasingFunction: ExponentialEase;
  36524. /**
  36525. * The easing mode used by animations
  36526. */
  36527. static EasingMode: number;
  36528. /**
  36529. * Sets the current mode used by the behavior
  36530. */
  36531. /**
  36532. * Gets current mode used by the behavior.
  36533. */
  36534. mode: number;
  36535. /**
  36536. * Sets the scale applied to the radius (1 by default)
  36537. */
  36538. /**
  36539. * Gets the scale applied to the radius
  36540. */
  36541. radiusScale: number;
  36542. /**
  36543. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36544. */
  36545. /**
  36546. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36547. */
  36548. positionScale: number;
  36549. /**
  36550. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36551. * behaviour is triggered, in radians.
  36552. */
  36553. /**
  36554. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36555. * behaviour is triggered, in radians.
  36556. */
  36557. defaultElevation: number;
  36558. /**
  36559. * Sets the time (in milliseconds) taken to return to the default beta position.
  36560. * Negative value indicates camera should not return to default.
  36561. */
  36562. /**
  36563. * Gets the time (in milliseconds) taken to return to the default beta position.
  36564. * Negative value indicates camera should not return to default.
  36565. */
  36566. elevationReturnTime: number;
  36567. /**
  36568. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36569. */
  36570. /**
  36571. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36572. */
  36573. elevationReturnWaitTime: number;
  36574. /**
  36575. * Sets the flag that indicates if user zooming should stop animation.
  36576. */
  36577. /**
  36578. * Gets the flag that indicates if user zooming should stop animation.
  36579. */
  36580. zoomStopsAnimation: boolean;
  36581. /**
  36582. * Sets the transition time when framing the mesh, in milliseconds
  36583. */
  36584. /**
  36585. * Gets the transition time when framing the mesh, in milliseconds
  36586. */
  36587. framingTime: number;
  36588. /**
  36589. * Define if the behavior should automatically change the configured
  36590. * camera limits and sensibilities.
  36591. */
  36592. autoCorrectCameraLimitsAndSensibility: boolean;
  36593. private _onPrePointerObservableObserver;
  36594. private _onAfterCheckInputsObserver;
  36595. private _onMeshTargetChangedObserver;
  36596. private _attachedCamera;
  36597. private _isPointerDown;
  36598. private _lastInteractionTime;
  36599. /**
  36600. * Initializes the behavior.
  36601. */
  36602. init(): void;
  36603. /**
  36604. * Attaches the behavior to its arc rotate camera.
  36605. * @param camera Defines the camera to attach the behavior to
  36606. */
  36607. attach(camera: ArcRotateCamera): void;
  36608. /**
  36609. * Detaches the behavior from its current arc rotate camera.
  36610. */
  36611. detach(): void;
  36612. private _animatables;
  36613. private _betaIsAnimating;
  36614. private _betaTransition;
  36615. private _radiusTransition;
  36616. private _vectorTransition;
  36617. /**
  36618. * Targets the given mesh and updates zoom level accordingly.
  36619. * @param mesh The mesh to target.
  36620. * @param radius Optional. If a cached radius position already exists, overrides default.
  36621. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36622. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36623. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36624. */
  36625. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36626. /**
  36627. * Targets the given mesh with its children and updates zoom level accordingly.
  36628. * @param mesh The mesh to target.
  36629. * @param radius Optional. If a cached radius position already exists, overrides default.
  36630. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36631. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36632. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36633. */
  36634. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36635. /**
  36636. * Targets the given meshes with their children and updates zoom level accordingly.
  36637. * @param meshes The mesh to target.
  36638. * @param radius Optional. If a cached radius position already exists, overrides default.
  36639. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36640. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36641. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36642. */
  36643. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36644. /**
  36645. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36646. * @param minimumWorld Determines the smaller position of the bounding box extend
  36647. * @param maximumWorld Determines the bigger position of the bounding box extend
  36648. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36649. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36650. */
  36651. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36652. /**
  36653. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36654. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36655. * frustum width.
  36656. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36657. * to fully enclose the mesh in the viewing frustum.
  36658. */
  36659. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36660. /**
  36661. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36662. * is automatically returned to its default position (expected to be above ground plane).
  36663. */
  36664. private _maintainCameraAboveGround;
  36665. /**
  36666. * Returns the frustum slope based on the canvas ratio and camera FOV
  36667. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36668. */
  36669. private _getFrustumSlope;
  36670. /**
  36671. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36672. */
  36673. private _clearAnimationLocks;
  36674. /**
  36675. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36676. */
  36677. private _applyUserInteraction;
  36678. /**
  36679. * Stops and removes all animations that have been applied to the camera
  36680. */
  36681. stopAllAnimations(): void;
  36682. /**
  36683. * Gets a value indicating if the user is moving the camera
  36684. */
  36685. readonly isUserIsMoving: boolean;
  36686. /**
  36687. * The camera can move all the way towards the mesh.
  36688. */
  36689. static IgnoreBoundsSizeMode: number;
  36690. /**
  36691. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36692. */
  36693. static FitFrustumSidesMode: number;
  36694. }
  36695. }
  36696. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36697. import { Nullable } from "babylonjs/types";
  36698. import { Camera } from "babylonjs/Cameras/camera";
  36699. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36700. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36701. /**
  36702. * Base class for Camera Pointer Inputs.
  36703. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36704. * for example usage.
  36705. */
  36706. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36707. /**
  36708. * Defines the camera the input is attached to.
  36709. */
  36710. abstract camera: Camera;
  36711. /**
  36712. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36713. */
  36714. protected _altKey: boolean;
  36715. protected _ctrlKey: boolean;
  36716. protected _metaKey: boolean;
  36717. protected _shiftKey: boolean;
  36718. /**
  36719. * Which mouse buttons were pressed at time of last mouse event.
  36720. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36721. */
  36722. protected _buttonsPressed: number;
  36723. /**
  36724. * Defines the buttons associated with the input to handle camera move.
  36725. */
  36726. buttons: number[];
  36727. /**
  36728. * Attach the input controls to a specific dom element to get the input from.
  36729. * @param element Defines the element the controls should be listened from
  36730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36731. */
  36732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36733. /**
  36734. * Detach the current controls from the specified dom element.
  36735. * @param element Defines the element to stop listening the inputs from
  36736. */
  36737. detachControl(element: Nullable<HTMLElement>): void;
  36738. /**
  36739. * Gets the class name of the current input.
  36740. * @returns the class name
  36741. */
  36742. getClassName(): string;
  36743. /**
  36744. * Get the friendly name associated with the input class.
  36745. * @returns the input friendly name
  36746. */
  36747. getSimpleName(): string;
  36748. /**
  36749. * Called on pointer POINTERDOUBLETAP event.
  36750. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36751. */
  36752. protected onDoubleTap(type: string): void;
  36753. /**
  36754. * Called on pointer POINTERMOVE event if only a single touch is active.
  36755. * Override this method to provide functionality.
  36756. */
  36757. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36758. /**
  36759. * Called on pointer POINTERMOVE event if multiple touches are active.
  36760. * Override this method to provide functionality.
  36761. */
  36762. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36763. /**
  36764. * Called on JS contextmenu event.
  36765. * Override this method to provide functionality.
  36766. */
  36767. protected onContextMenu(evt: PointerEvent): void;
  36768. /**
  36769. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36770. * press.
  36771. * Override this method to provide functionality.
  36772. */
  36773. protected onButtonDown(evt: PointerEvent): void;
  36774. /**
  36775. * Called each time a new POINTERUP event occurs. Ie, for each button
  36776. * release.
  36777. * Override this method to provide functionality.
  36778. */
  36779. protected onButtonUp(evt: PointerEvent): void;
  36780. /**
  36781. * Called when window becomes inactive.
  36782. * Override this method to provide functionality.
  36783. */
  36784. protected onLostFocus(): void;
  36785. private _pointerInput;
  36786. private _observer;
  36787. private _onLostFocus;
  36788. private pointA;
  36789. private pointB;
  36790. }
  36791. }
  36792. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36793. import { Nullable } from "babylonjs/types";
  36794. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36795. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36796. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36797. /**
  36798. * Manage the pointers inputs to control an arc rotate camera.
  36799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36800. */
  36801. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36802. /**
  36803. * Defines the camera the input is attached to.
  36804. */
  36805. camera: ArcRotateCamera;
  36806. /**
  36807. * Gets the class name of the current input.
  36808. * @returns the class name
  36809. */
  36810. getClassName(): string;
  36811. /**
  36812. * Defines the buttons associated with the input to handle camera move.
  36813. */
  36814. buttons: number[];
  36815. /**
  36816. * Defines the pointer angular sensibility along the X axis or how fast is
  36817. * the camera rotating.
  36818. */
  36819. angularSensibilityX: number;
  36820. /**
  36821. * Defines the pointer angular sensibility along the Y axis or how fast is
  36822. * the camera rotating.
  36823. */
  36824. angularSensibilityY: number;
  36825. /**
  36826. * Defines the pointer pinch precision or how fast is the camera zooming.
  36827. */
  36828. pinchPrecision: number;
  36829. /**
  36830. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36831. * from 0.
  36832. * It defines the percentage of current camera.radius to use as delta when
  36833. * pinch zoom is used.
  36834. */
  36835. pinchDeltaPercentage: number;
  36836. /**
  36837. * Defines the pointer panning sensibility or how fast is the camera moving.
  36838. */
  36839. panningSensibility: number;
  36840. /**
  36841. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36842. */
  36843. multiTouchPanning: boolean;
  36844. /**
  36845. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36846. * zoom (pinch) through multitouch.
  36847. */
  36848. multiTouchPanAndZoom: boolean;
  36849. /**
  36850. * Revers pinch action direction.
  36851. */
  36852. pinchInwards: boolean;
  36853. private _isPanClick;
  36854. private _twoFingerActivityCount;
  36855. private _isPinching;
  36856. /**
  36857. * Called on pointer POINTERMOVE event if only a single touch is active.
  36858. */
  36859. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36860. /**
  36861. * Called on pointer POINTERDOUBLETAP event.
  36862. */
  36863. protected onDoubleTap(type: string): void;
  36864. /**
  36865. * Called on pointer POINTERMOVE event if multiple touches are active.
  36866. */
  36867. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36868. /**
  36869. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36870. * press.
  36871. */
  36872. protected onButtonDown(evt: PointerEvent): void;
  36873. /**
  36874. * Called each time a new POINTERUP event occurs. Ie, for each button
  36875. * release.
  36876. */
  36877. protected onButtonUp(evt: PointerEvent): void;
  36878. /**
  36879. * Called when window becomes inactive.
  36880. */
  36881. protected onLostFocus(): void;
  36882. }
  36883. }
  36884. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36885. import { Nullable } from "babylonjs/types";
  36886. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36887. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36888. /**
  36889. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36891. */
  36892. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36893. /**
  36894. * Defines the camera the input is attached to.
  36895. */
  36896. camera: ArcRotateCamera;
  36897. /**
  36898. * Defines the list of key codes associated with the up action (increase alpha)
  36899. */
  36900. keysUp: number[];
  36901. /**
  36902. * Defines the list of key codes associated with the down action (decrease alpha)
  36903. */
  36904. keysDown: number[];
  36905. /**
  36906. * Defines the list of key codes associated with the left action (increase beta)
  36907. */
  36908. keysLeft: number[];
  36909. /**
  36910. * Defines the list of key codes associated with the right action (decrease beta)
  36911. */
  36912. keysRight: number[];
  36913. /**
  36914. * Defines the list of key codes associated with the reset action.
  36915. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36916. */
  36917. keysReset: number[];
  36918. /**
  36919. * Defines the panning sensibility of the inputs.
  36920. * (How fast is the camera paning)
  36921. */
  36922. panningSensibility: number;
  36923. /**
  36924. * Defines the zooming sensibility of the inputs.
  36925. * (How fast is the camera zooming)
  36926. */
  36927. zoomingSensibility: number;
  36928. /**
  36929. * Defines wether maintaining the alt key down switch the movement mode from
  36930. * orientation to zoom.
  36931. */
  36932. useAltToZoom: boolean;
  36933. /**
  36934. * Rotation speed of the camera
  36935. */
  36936. angularSpeed: number;
  36937. private _keys;
  36938. private _ctrlPressed;
  36939. private _altPressed;
  36940. private _onCanvasBlurObserver;
  36941. private _onKeyboardObserver;
  36942. private _engine;
  36943. private _scene;
  36944. /**
  36945. * Attach the input controls to a specific dom element to get the input from.
  36946. * @param element Defines the element the controls should be listened from
  36947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36948. */
  36949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36950. /**
  36951. * Detach the current controls from the specified dom element.
  36952. * @param element Defines the element to stop listening the inputs from
  36953. */
  36954. detachControl(element: Nullable<HTMLElement>): void;
  36955. /**
  36956. * Update the current camera state depending on the inputs that have been used this frame.
  36957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36958. */
  36959. checkInputs(): void;
  36960. /**
  36961. * Gets the class name of the current intput.
  36962. * @returns the class name
  36963. */
  36964. getClassName(): string;
  36965. /**
  36966. * Get the friendly name associated with the input class.
  36967. * @returns the input friendly name
  36968. */
  36969. getSimpleName(): string;
  36970. }
  36971. }
  36972. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36973. import { Nullable } from "babylonjs/types";
  36974. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36975. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36976. /**
  36977. * Manage the mouse wheel inputs to control an arc rotate camera.
  36978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36979. */
  36980. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36981. /**
  36982. * Defines the camera the input is attached to.
  36983. */
  36984. camera: ArcRotateCamera;
  36985. /**
  36986. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36987. */
  36988. wheelPrecision: number;
  36989. /**
  36990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36992. */
  36993. wheelDeltaPercentage: number;
  36994. private _wheel;
  36995. private _observer;
  36996. private computeDeltaFromMouseWheelLegacyEvent;
  36997. /**
  36998. * Attach the input controls to a specific dom element to get the input from.
  36999. * @param element Defines the element the controls should be listened from
  37000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37001. */
  37002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37003. /**
  37004. * Detach the current controls from the specified dom element.
  37005. * @param element Defines the element to stop listening the inputs from
  37006. */
  37007. detachControl(element: Nullable<HTMLElement>): void;
  37008. /**
  37009. * Gets the class name of the current intput.
  37010. * @returns the class name
  37011. */
  37012. getClassName(): string;
  37013. /**
  37014. * Get the friendly name associated with the input class.
  37015. * @returns the input friendly name
  37016. */
  37017. getSimpleName(): string;
  37018. }
  37019. }
  37020. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37021. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37022. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37023. /**
  37024. * Default Inputs manager for the ArcRotateCamera.
  37025. * It groups all the default supported inputs for ease of use.
  37026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37027. */
  37028. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37029. /**
  37030. * Instantiates a new ArcRotateCameraInputsManager.
  37031. * @param camera Defines the camera the inputs belong to
  37032. */
  37033. constructor(camera: ArcRotateCamera);
  37034. /**
  37035. * Add mouse wheel input support to the input manager.
  37036. * @returns the current input manager
  37037. */
  37038. addMouseWheel(): ArcRotateCameraInputsManager;
  37039. /**
  37040. * Add pointers input support to the input manager.
  37041. * @returns the current input manager
  37042. */
  37043. addPointers(): ArcRotateCameraInputsManager;
  37044. /**
  37045. * Add keyboard input support to the input manager.
  37046. * @returns the current input manager
  37047. */
  37048. addKeyboard(): ArcRotateCameraInputsManager;
  37049. }
  37050. }
  37051. declare module "babylonjs/Cameras/arcRotateCamera" {
  37052. import { Observable } from "babylonjs/Misc/observable";
  37053. import { Nullable } from "babylonjs/types";
  37054. import { Scene } from "babylonjs/scene";
  37055. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37057. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37058. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37059. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37060. import { Camera } from "babylonjs/Cameras/camera";
  37061. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37062. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37063. import { Collider } from "babylonjs/Collisions/collider";
  37064. /**
  37065. * This represents an orbital type of camera.
  37066. *
  37067. * 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.
  37068. * 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.
  37069. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37070. */
  37071. export class ArcRotateCamera extends TargetCamera {
  37072. /**
  37073. * Defines the rotation angle of the camera along the longitudinal axis.
  37074. */
  37075. alpha: number;
  37076. /**
  37077. * Defines the rotation angle of the camera along the latitudinal axis.
  37078. */
  37079. beta: number;
  37080. /**
  37081. * Defines the radius of the camera from it s target point.
  37082. */
  37083. radius: number;
  37084. protected _target: Vector3;
  37085. protected _targetHost: Nullable<AbstractMesh>;
  37086. /**
  37087. * Defines the target point of the camera.
  37088. * The camera looks towards it form the radius distance.
  37089. */
  37090. target: Vector3;
  37091. /**
  37092. * Define the current local position of the camera in the scene
  37093. */
  37094. position: Vector3;
  37095. protected _upVector: Vector3;
  37096. protected _upToYMatrix: Matrix;
  37097. protected _YToUpMatrix: Matrix;
  37098. /**
  37099. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37100. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37101. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37102. */
  37103. upVector: Vector3;
  37104. /**
  37105. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37106. */
  37107. setMatUp(): void;
  37108. /**
  37109. * Current inertia value on the longitudinal axis.
  37110. * The bigger this number the longer it will take for the camera to stop.
  37111. */
  37112. inertialAlphaOffset: number;
  37113. /**
  37114. * Current inertia value on the latitudinal axis.
  37115. * The bigger this number the longer it will take for the camera to stop.
  37116. */
  37117. inertialBetaOffset: number;
  37118. /**
  37119. * Current inertia value on the radius axis.
  37120. * The bigger this number the longer it will take for the camera to stop.
  37121. */
  37122. inertialRadiusOffset: number;
  37123. /**
  37124. * Minimum allowed angle on the longitudinal axis.
  37125. * This can help limiting how the Camera is able to move in the scene.
  37126. */
  37127. lowerAlphaLimit: Nullable<number>;
  37128. /**
  37129. * Maximum allowed angle on the longitudinal axis.
  37130. * This can help limiting how the Camera is able to move in the scene.
  37131. */
  37132. upperAlphaLimit: Nullable<number>;
  37133. /**
  37134. * Minimum allowed angle on the latitudinal axis.
  37135. * This can help limiting how the Camera is able to move in the scene.
  37136. */
  37137. lowerBetaLimit: number;
  37138. /**
  37139. * Maximum allowed angle on the latitudinal axis.
  37140. * This can help limiting how the Camera is able to move in the scene.
  37141. */
  37142. upperBetaLimit: number;
  37143. /**
  37144. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37145. * This can help limiting how the Camera is able to move in the scene.
  37146. */
  37147. lowerRadiusLimit: Nullable<number>;
  37148. /**
  37149. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37150. * This can help limiting how the Camera is able to move in the scene.
  37151. */
  37152. upperRadiusLimit: Nullable<number>;
  37153. /**
  37154. * Defines the current inertia value used during panning of the camera along the X axis.
  37155. */
  37156. inertialPanningX: number;
  37157. /**
  37158. * Defines the current inertia value used during panning of the camera along the Y axis.
  37159. */
  37160. inertialPanningY: number;
  37161. /**
  37162. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37163. * Basically if your fingers moves away from more than this distance you will be considered
  37164. * in pinch mode.
  37165. */
  37166. pinchToPanMaxDistance: number;
  37167. /**
  37168. * Defines the maximum distance the camera can pan.
  37169. * This could help keeping the cammera always in your scene.
  37170. */
  37171. panningDistanceLimit: Nullable<number>;
  37172. /**
  37173. * Defines the target of the camera before paning.
  37174. */
  37175. panningOriginTarget: Vector3;
  37176. /**
  37177. * Defines the value of the inertia used during panning.
  37178. * 0 would mean stop inertia and one would mean no decelleration at all.
  37179. */
  37180. panningInertia: number;
  37181. /**
  37182. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37183. */
  37184. angularSensibilityX: number;
  37185. /**
  37186. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37187. */
  37188. angularSensibilityY: number;
  37189. /**
  37190. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37191. */
  37192. pinchPrecision: number;
  37193. /**
  37194. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37195. * It will be used instead of pinchDeltaPrecision if different from 0.
  37196. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37197. */
  37198. pinchDeltaPercentage: number;
  37199. /**
  37200. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37201. */
  37202. panningSensibility: number;
  37203. /**
  37204. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37205. */
  37206. keysUp: number[];
  37207. /**
  37208. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37209. */
  37210. keysDown: number[];
  37211. /**
  37212. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37213. */
  37214. keysLeft: number[];
  37215. /**
  37216. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37217. */
  37218. keysRight: number[];
  37219. /**
  37220. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37221. */
  37222. wheelPrecision: number;
  37223. /**
  37224. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37225. * It will be used instead of pinchDeltaPrecision if different from 0.
  37226. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37227. */
  37228. wheelDeltaPercentage: number;
  37229. /**
  37230. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37231. */
  37232. zoomOnFactor: number;
  37233. /**
  37234. * Defines a screen offset for the camera position.
  37235. */
  37236. targetScreenOffset: Vector2;
  37237. /**
  37238. * Allows the camera to be completely reversed.
  37239. * If false the camera can not arrive upside down.
  37240. */
  37241. allowUpsideDown: boolean;
  37242. /**
  37243. * Define if double tap/click is used to restore the previously saved state of the camera.
  37244. */
  37245. useInputToRestoreState: boolean;
  37246. /** @hidden */
  37247. _viewMatrix: Matrix;
  37248. /** @hidden */
  37249. _useCtrlForPanning: boolean;
  37250. /** @hidden */
  37251. _panningMouseButton: number;
  37252. /**
  37253. * Defines the input associated to the camera.
  37254. */
  37255. inputs: ArcRotateCameraInputsManager;
  37256. /** @hidden */
  37257. _reset: () => void;
  37258. /**
  37259. * Defines the allowed panning axis.
  37260. */
  37261. panningAxis: Vector3;
  37262. protected _localDirection: Vector3;
  37263. protected _transformedDirection: Vector3;
  37264. private _bouncingBehavior;
  37265. /**
  37266. * Gets the bouncing behavior of the camera if it has been enabled.
  37267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37268. */
  37269. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37270. /**
  37271. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37273. */
  37274. useBouncingBehavior: boolean;
  37275. private _framingBehavior;
  37276. /**
  37277. * Gets the framing behavior of the camera if it has been enabled.
  37278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37279. */
  37280. readonly framingBehavior: Nullable<FramingBehavior>;
  37281. /**
  37282. * Defines if the framing behavior of the camera is enabled on the camera.
  37283. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37284. */
  37285. useFramingBehavior: boolean;
  37286. private _autoRotationBehavior;
  37287. /**
  37288. * Gets the auto rotation behavior of the camera if it has been enabled.
  37289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37290. */
  37291. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37292. /**
  37293. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37295. */
  37296. useAutoRotationBehavior: boolean;
  37297. /**
  37298. * Observable triggered when the mesh target has been changed on the camera.
  37299. */
  37300. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37301. /**
  37302. * Event raised when the camera is colliding with a mesh.
  37303. */
  37304. onCollide: (collidedMesh: AbstractMesh) => void;
  37305. /**
  37306. * Defines whether the camera should check collision with the objects oh the scene.
  37307. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37308. */
  37309. checkCollisions: boolean;
  37310. /**
  37311. * Defines the collision radius of the camera.
  37312. * This simulates a sphere around the camera.
  37313. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37314. */
  37315. collisionRadius: Vector3;
  37316. protected _collider: Collider;
  37317. protected _previousPosition: Vector3;
  37318. protected _collisionVelocity: Vector3;
  37319. protected _newPosition: Vector3;
  37320. protected _previousAlpha: number;
  37321. protected _previousBeta: number;
  37322. protected _previousRadius: number;
  37323. protected _collisionTriggered: boolean;
  37324. protected _targetBoundingCenter: Nullable<Vector3>;
  37325. private _computationVector;
  37326. /**
  37327. * Instantiates a new ArcRotateCamera in a given scene
  37328. * @param name Defines the name of the camera
  37329. * @param alpha Defines the camera rotation along the logitudinal axis
  37330. * @param beta Defines the camera rotation along the latitudinal axis
  37331. * @param radius Defines the camera distance from its target
  37332. * @param target Defines the camera target
  37333. * @param scene Defines the scene the camera belongs to
  37334. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37335. */
  37336. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37337. /** @hidden */
  37338. _initCache(): void;
  37339. /** @hidden */
  37340. _updateCache(ignoreParentClass?: boolean): void;
  37341. protected _getTargetPosition(): Vector3;
  37342. private _storedAlpha;
  37343. private _storedBeta;
  37344. private _storedRadius;
  37345. private _storedTarget;
  37346. /**
  37347. * Stores the current state of the camera (alpha, beta, radius and target)
  37348. * @returns the camera itself
  37349. */
  37350. storeState(): Camera;
  37351. /**
  37352. * @hidden
  37353. * Restored camera state. You must call storeState() first
  37354. */
  37355. _restoreStateValues(): boolean;
  37356. /** @hidden */
  37357. _isSynchronizedViewMatrix(): boolean;
  37358. /**
  37359. * Attached controls to the current camera.
  37360. * @param element Defines the element the controls should be listened from
  37361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37362. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37363. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37364. */
  37365. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37366. /**
  37367. * Detach the current controls from the camera.
  37368. * The camera will stop reacting to inputs.
  37369. * @param element Defines the element to stop listening the inputs from
  37370. */
  37371. detachControl(element: HTMLElement): void;
  37372. /** @hidden */
  37373. _checkInputs(): void;
  37374. protected _checkLimits(): void;
  37375. /**
  37376. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37377. */
  37378. rebuildAnglesAndRadius(): void;
  37379. /**
  37380. * Use a position to define the current camera related information like aplha, beta and radius
  37381. * @param position Defines the position to set the camera at
  37382. */
  37383. setPosition(position: Vector3): void;
  37384. /**
  37385. * Defines the target the camera should look at.
  37386. * This will automatically adapt alpha beta and radius to fit within the new target.
  37387. * @param target Defines the new target as a Vector or a mesh
  37388. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37389. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37390. */
  37391. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37392. /** @hidden */
  37393. _getViewMatrix(): Matrix;
  37394. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37395. /**
  37396. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37397. * @param meshes Defines the mesh to zoom on
  37398. * @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)
  37399. */
  37400. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37401. /**
  37402. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37403. * The target will be changed but the radius
  37404. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37405. * @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)
  37406. */
  37407. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37408. min: Vector3;
  37409. max: Vector3;
  37410. distance: number;
  37411. }, doNotUpdateMaxZ?: boolean): void;
  37412. /**
  37413. * @override
  37414. * Override Camera.createRigCamera
  37415. */
  37416. createRigCamera(name: string, cameraIndex: number): Camera;
  37417. /**
  37418. * @hidden
  37419. * @override
  37420. * Override Camera._updateRigCameras
  37421. */
  37422. _updateRigCameras(): void;
  37423. /**
  37424. * Destroy the camera and release the current resources hold by it.
  37425. */
  37426. dispose(): void;
  37427. /**
  37428. * Gets the current object class name.
  37429. * @return the class name
  37430. */
  37431. getClassName(): string;
  37432. }
  37433. }
  37434. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37435. import { Behavior } from "babylonjs/Behaviors/behavior";
  37436. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37437. /**
  37438. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37440. */
  37441. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37442. /**
  37443. * Gets the name of the behavior.
  37444. */
  37445. readonly name: string;
  37446. private _zoomStopsAnimation;
  37447. private _idleRotationSpeed;
  37448. private _idleRotationWaitTime;
  37449. private _idleRotationSpinupTime;
  37450. /**
  37451. * Sets the flag that indicates if user zooming should stop animation.
  37452. */
  37453. /**
  37454. * Gets the flag that indicates if user zooming should stop animation.
  37455. */
  37456. zoomStopsAnimation: boolean;
  37457. /**
  37458. * Sets the default speed at which the camera rotates around the model.
  37459. */
  37460. /**
  37461. * Gets the default speed at which the camera rotates around the model.
  37462. */
  37463. idleRotationSpeed: number;
  37464. /**
  37465. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37466. */
  37467. /**
  37468. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37469. */
  37470. idleRotationWaitTime: number;
  37471. /**
  37472. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37473. */
  37474. /**
  37475. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37476. */
  37477. idleRotationSpinupTime: number;
  37478. /**
  37479. * Gets a value indicating if the camera is currently rotating because of this behavior
  37480. */
  37481. readonly rotationInProgress: boolean;
  37482. private _onPrePointerObservableObserver;
  37483. private _onAfterCheckInputsObserver;
  37484. private _attachedCamera;
  37485. private _isPointerDown;
  37486. private _lastFrameTime;
  37487. private _lastInteractionTime;
  37488. private _cameraRotationSpeed;
  37489. /**
  37490. * Initializes the behavior.
  37491. */
  37492. init(): void;
  37493. /**
  37494. * Attaches the behavior to its arc rotate camera.
  37495. * @param camera Defines the camera to attach the behavior to
  37496. */
  37497. attach(camera: ArcRotateCamera): void;
  37498. /**
  37499. * Detaches the behavior from its current arc rotate camera.
  37500. */
  37501. detach(): void;
  37502. /**
  37503. * Returns true if user is scrolling.
  37504. * @return true if user is scrolling.
  37505. */
  37506. private _userIsZooming;
  37507. private _lastFrameRadius;
  37508. private _shouldAnimationStopForInteraction;
  37509. /**
  37510. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37511. */
  37512. private _applyUserInteraction;
  37513. private _userIsMoving;
  37514. }
  37515. }
  37516. declare module "babylonjs/Behaviors/Cameras/index" {
  37517. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37518. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37519. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37520. }
  37521. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37522. import { Mesh } from "babylonjs/Meshes/mesh";
  37523. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37524. import { Behavior } from "babylonjs/Behaviors/behavior";
  37525. /**
  37526. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37527. */
  37528. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37529. private ui;
  37530. /**
  37531. * The name of the behavior
  37532. */
  37533. name: string;
  37534. /**
  37535. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37536. */
  37537. distanceAwayFromFace: number;
  37538. /**
  37539. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37540. */
  37541. distanceAwayFromBottomOfFace: number;
  37542. private _faceVectors;
  37543. private _target;
  37544. private _scene;
  37545. private _onRenderObserver;
  37546. private _tmpMatrix;
  37547. private _tmpVector;
  37548. /**
  37549. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37550. * @param ui The transform node that should be attched to the mesh
  37551. */
  37552. constructor(ui: TransformNode);
  37553. /**
  37554. * Initializes the behavior
  37555. */
  37556. init(): void;
  37557. private _closestFace;
  37558. private _zeroVector;
  37559. private _lookAtTmpMatrix;
  37560. private _lookAtToRef;
  37561. /**
  37562. * Attaches the AttachToBoxBehavior to the passed in mesh
  37563. * @param target The mesh that the specified node will be attached to
  37564. */
  37565. attach(target: Mesh): void;
  37566. /**
  37567. * Detaches the behavior from the mesh
  37568. */
  37569. detach(): void;
  37570. }
  37571. }
  37572. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37573. import { Behavior } from "babylonjs/Behaviors/behavior";
  37574. import { Mesh } from "babylonjs/Meshes/mesh";
  37575. /**
  37576. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37577. */
  37578. export class FadeInOutBehavior implements Behavior<Mesh> {
  37579. /**
  37580. * Time in milliseconds to delay before fading in (Default: 0)
  37581. */
  37582. delay: number;
  37583. /**
  37584. * Time in milliseconds for the mesh to fade in (Default: 300)
  37585. */
  37586. fadeInTime: number;
  37587. private _millisecondsPerFrame;
  37588. private _hovered;
  37589. private _hoverValue;
  37590. private _ownerNode;
  37591. /**
  37592. * Instatiates the FadeInOutBehavior
  37593. */
  37594. constructor();
  37595. /**
  37596. * The name of the behavior
  37597. */
  37598. readonly name: string;
  37599. /**
  37600. * Initializes the behavior
  37601. */
  37602. init(): void;
  37603. /**
  37604. * Attaches the fade behavior on the passed in mesh
  37605. * @param ownerNode The mesh that will be faded in/out once attached
  37606. */
  37607. attach(ownerNode: Mesh): void;
  37608. /**
  37609. * Detaches the behavior from the mesh
  37610. */
  37611. detach(): void;
  37612. /**
  37613. * Triggers the mesh to begin fading in or out
  37614. * @param value if the object should fade in or out (true to fade in)
  37615. */
  37616. fadeIn(value: boolean): void;
  37617. private _update;
  37618. private _setAllVisibility;
  37619. }
  37620. }
  37621. declare module "babylonjs/Misc/pivotTools" {
  37622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37623. /**
  37624. * Class containing a set of static utilities functions for managing Pivots
  37625. * @hidden
  37626. */
  37627. export class PivotTools {
  37628. private static _PivotCached;
  37629. private static _OldPivotPoint;
  37630. private static _PivotTranslation;
  37631. private static _PivotTmpVector;
  37632. /** @hidden */
  37633. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37634. /** @hidden */
  37635. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37636. }
  37637. }
  37638. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37639. import { Scene } from "babylonjs/scene";
  37640. import { Vector4 } from "babylonjs/Maths/math.vector";
  37641. import { Mesh } from "babylonjs/Meshes/mesh";
  37642. import { Nullable } from "babylonjs/types";
  37643. import { Plane } from "babylonjs/Maths/math.plane";
  37644. /**
  37645. * Class containing static functions to help procedurally build meshes
  37646. */
  37647. export class PlaneBuilder {
  37648. /**
  37649. * Creates a plane mesh
  37650. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37651. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37652. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37656. * @param name defines the name of the mesh
  37657. * @param options defines the options used to create the mesh
  37658. * @param scene defines the hosting scene
  37659. * @returns the plane mesh
  37660. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37661. */
  37662. static CreatePlane(name: string, options: {
  37663. size?: number;
  37664. width?: number;
  37665. height?: number;
  37666. sideOrientation?: number;
  37667. frontUVs?: Vector4;
  37668. backUVs?: Vector4;
  37669. updatable?: boolean;
  37670. sourcePlane?: Plane;
  37671. }, scene?: Nullable<Scene>): Mesh;
  37672. }
  37673. }
  37674. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37675. import { Behavior } from "babylonjs/Behaviors/behavior";
  37676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37677. import { Observable } from "babylonjs/Misc/observable";
  37678. import { Vector3 } from "babylonjs/Maths/math.vector";
  37679. import { Ray } from "babylonjs/Culling/ray";
  37680. import "babylonjs/Meshes/Builders/planeBuilder";
  37681. /**
  37682. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37683. */
  37684. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37685. private static _AnyMouseID;
  37686. /**
  37687. * Abstract mesh the behavior is set on
  37688. */
  37689. attachedNode: AbstractMesh;
  37690. private _dragPlane;
  37691. private _scene;
  37692. private _pointerObserver;
  37693. private _beforeRenderObserver;
  37694. private static _planeScene;
  37695. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37696. /**
  37697. * 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)
  37698. */
  37699. maxDragAngle: number;
  37700. /**
  37701. * @hidden
  37702. */
  37703. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37704. /**
  37705. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37706. */
  37707. currentDraggingPointerID: number;
  37708. /**
  37709. * The last position where the pointer hit the drag plane in world space
  37710. */
  37711. lastDragPosition: Vector3;
  37712. /**
  37713. * If the behavior is currently in a dragging state
  37714. */
  37715. dragging: boolean;
  37716. /**
  37717. * 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)
  37718. */
  37719. dragDeltaRatio: number;
  37720. /**
  37721. * If the drag plane orientation should be updated during the dragging (Default: true)
  37722. */
  37723. updateDragPlane: boolean;
  37724. private _debugMode;
  37725. private _moving;
  37726. /**
  37727. * Fires each time the attached mesh is dragged with the pointer
  37728. * * delta between last drag position and current drag position in world space
  37729. * * dragDistance along the drag axis
  37730. * * dragPlaneNormal normal of the current drag plane used during the drag
  37731. * * dragPlanePoint in world space where the drag intersects the drag plane
  37732. */
  37733. onDragObservable: Observable<{
  37734. delta: Vector3;
  37735. dragPlanePoint: Vector3;
  37736. dragPlaneNormal: Vector3;
  37737. dragDistance: number;
  37738. pointerId: number;
  37739. }>;
  37740. /**
  37741. * Fires each time a drag begins (eg. mouse down on mesh)
  37742. */
  37743. onDragStartObservable: Observable<{
  37744. dragPlanePoint: Vector3;
  37745. pointerId: number;
  37746. }>;
  37747. /**
  37748. * Fires each time a drag ends (eg. mouse release after drag)
  37749. */
  37750. onDragEndObservable: Observable<{
  37751. dragPlanePoint: Vector3;
  37752. pointerId: number;
  37753. }>;
  37754. /**
  37755. * If the attached mesh should be moved when dragged
  37756. */
  37757. moveAttached: boolean;
  37758. /**
  37759. * If the drag behavior will react to drag events (Default: true)
  37760. */
  37761. enabled: boolean;
  37762. /**
  37763. * If pointer events should start and release the drag (Default: true)
  37764. */
  37765. startAndReleaseDragOnPointerEvents: boolean;
  37766. /**
  37767. * If camera controls should be detached during the drag
  37768. */
  37769. detachCameraControls: boolean;
  37770. /**
  37771. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37772. */
  37773. useObjectOrienationForDragging: boolean;
  37774. private _options;
  37775. /**
  37776. * Creates a pointer drag behavior that can be attached to a mesh
  37777. * @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)
  37778. */
  37779. constructor(options?: {
  37780. dragAxis?: Vector3;
  37781. dragPlaneNormal?: Vector3;
  37782. });
  37783. /**
  37784. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37785. */
  37786. validateDrag: (targetPosition: Vector3) => boolean;
  37787. /**
  37788. * The name of the behavior
  37789. */
  37790. readonly name: string;
  37791. /**
  37792. * Initializes the behavior
  37793. */
  37794. init(): void;
  37795. private _tmpVector;
  37796. private _alternatePickedPoint;
  37797. private _worldDragAxis;
  37798. private _targetPosition;
  37799. private _attachedElement;
  37800. /**
  37801. * Attaches the drag behavior the passed in mesh
  37802. * @param ownerNode The mesh that will be dragged around once attached
  37803. */
  37804. attach(ownerNode: AbstractMesh): void;
  37805. /**
  37806. * Force relase the drag action by code.
  37807. */
  37808. releaseDrag(): void;
  37809. private _startDragRay;
  37810. private _lastPointerRay;
  37811. /**
  37812. * Simulates the start of a pointer drag event on the behavior
  37813. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37814. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37815. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37816. */
  37817. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37818. private _startDrag;
  37819. private _dragDelta;
  37820. private _moveDrag;
  37821. private _pickWithRayOnDragPlane;
  37822. private _pointA;
  37823. private _pointB;
  37824. private _pointC;
  37825. private _lineA;
  37826. private _lineB;
  37827. private _localAxis;
  37828. private _lookAt;
  37829. private _updateDragPlanePosition;
  37830. /**
  37831. * Detaches the behavior from the mesh
  37832. */
  37833. detach(): void;
  37834. }
  37835. }
  37836. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37837. import { Mesh } from "babylonjs/Meshes/mesh";
  37838. import { Behavior } from "babylonjs/Behaviors/behavior";
  37839. /**
  37840. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37841. */
  37842. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37843. private _dragBehaviorA;
  37844. private _dragBehaviorB;
  37845. private _startDistance;
  37846. private _initialScale;
  37847. private _targetScale;
  37848. private _ownerNode;
  37849. private _sceneRenderObserver;
  37850. /**
  37851. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37852. */
  37853. constructor();
  37854. /**
  37855. * The name of the behavior
  37856. */
  37857. readonly name: string;
  37858. /**
  37859. * Initializes the behavior
  37860. */
  37861. init(): void;
  37862. private _getCurrentDistance;
  37863. /**
  37864. * Attaches the scale behavior the passed in mesh
  37865. * @param ownerNode The mesh that will be scaled around once attached
  37866. */
  37867. attach(ownerNode: Mesh): void;
  37868. /**
  37869. * Detaches the behavior from the mesh
  37870. */
  37871. detach(): void;
  37872. }
  37873. }
  37874. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37875. import { Behavior } from "babylonjs/Behaviors/behavior";
  37876. import { Mesh } from "babylonjs/Meshes/mesh";
  37877. import { Observable } from "babylonjs/Misc/observable";
  37878. /**
  37879. * 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
  37880. */
  37881. export class SixDofDragBehavior implements Behavior<Mesh> {
  37882. private static _virtualScene;
  37883. private _ownerNode;
  37884. private _sceneRenderObserver;
  37885. private _scene;
  37886. private _targetPosition;
  37887. private _virtualOriginMesh;
  37888. private _virtualDragMesh;
  37889. private _pointerObserver;
  37890. private _moving;
  37891. private _startingOrientation;
  37892. /**
  37893. * 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)
  37894. */
  37895. private zDragFactor;
  37896. /**
  37897. * If the object should rotate to face the drag origin
  37898. */
  37899. rotateDraggedObject: boolean;
  37900. /**
  37901. * If the behavior is currently in a dragging state
  37902. */
  37903. dragging: boolean;
  37904. /**
  37905. * 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)
  37906. */
  37907. dragDeltaRatio: number;
  37908. /**
  37909. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37910. */
  37911. currentDraggingPointerID: number;
  37912. /**
  37913. * If camera controls should be detached during the drag
  37914. */
  37915. detachCameraControls: boolean;
  37916. /**
  37917. * Fires each time a drag starts
  37918. */
  37919. onDragStartObservable: Observable<{}>;
  37920. /**
  37921. * Fires each time a drag ends (eg. mouse release after drag)
  37922. */
  37923. onDragEndObservable: Observable<{}>;
  37924. /**
  37925. * 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
  37926. */
  37927. constructor();
  37928. /**
  37929. * The name of the behavior
  37930. */
  37931. readonly name: string;
  37932. /**
  37933. * Initializes the behavior
  37934. */
  37935. init(): void;
  37936. /**
  37937. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37938. */
  37939. private readonly _pointerCamera;
  37940. /**
  37941. * Attaches the scale behavior the passed in mesh
  37942. * @param ownerNode The mesh that will be scaled around once attached
  37943. */
  37944. attach(ownerNode: Mesh): void;
  37945. /**
  37946. * Detaches the behavior from the mesh
  37947. */
  37948. detach(): void;
  37949. }
  37950. }
  37951. declare module "babylonjs/Behaviors/Meshes/index" {
  37952. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37953. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37954. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37955. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37956. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37957. }
  37958. declare module "babylonjs/Behaviors/index" {
  37959. export * from "babylonjs/Behaviors/behavior";
  37960. export * from "babylonjs/Behaviors/Cameras/index";
  37961. export * from "babylonjs/Behaviors/Meshes/index";
  37962. }
  37963. declare module "babylonjs/Bones/boneIKController" {
  37964. import { Bone } from "babylonjs/Bones/bone";
  37965. import { Vector3 } from "babylonjs/Maths/math.vector";
  37966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37967. import { Nullable } from "babylonjs/types";
  37968. /**
  37969. * Class used to apply inverse kinematics to bones
  37970. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37971. */
  37972. export class BoneIKController {
  37973. private static _tmpVecs;
  37974. private static _tmpQuat;
  37975. private static _tmpMats;
  37976. /**
  37977. * Gets or sets the target mesh
  37978. */
  37979. targetMesh: AbstractMesh;
  37980. /** Gets or sets the mesh used as pole */
  37981. poleTargetMesh: AbstractMesh;
  37982. /**
  37983. * Gets or sets the bone used as pole
  37984. */
  37985. poleTargetBone: Nullable<Bone>;
  37986. /**
  37987. * Gets or sets the target position
  37988. */
  37989. targetPosition: Vector3;
  37990. /**
  37991. * Gets or sets the pole target position
  37992. */
  37993. poleTargetPosition: Vector3;
  37994. /**
  37995. * Gets or sets the pole target local offset
  37996. */
  37997. poleTargetLocalOffset: Vector3;
  37998. /**
  37999. * Gets or sets the pole angle
  38000. */
  38001. poleAngle: number;
  38002. /**
  38003. * Gets or sets the mesh associated with the controller
  38004. */
  38005. mesh: AbstractMesh;
  38006. /**
  38007. * 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)
  38008. */
  38009. slerpAmount: number;
  38010. private _bone1Quat;
  38011. private _bone1Mat;
  38012. private _bone2Ang;
  38013. private _bone1;
  38014. private _bone2;
  38015. private _bone1Length;
  38016. private _bone2Length;
  38017. private _maxAngle;
  38018. private _maxReach;
  38019. private _rightHandedSystem;
  38020. private _bendAxis;
  38021. private _slerping;
  38022. private _adjustRoll;
  38023. /**
  38024. * Gets or sets maximum allowed angle
  38025. */
  38026. maxAngle: number;
  38027. /**
  38028. * Creates a new BoneIKController
  38029. * @param mesh defines the mesh to control
  38030. * @param bone defines the bone to control
  38031. * @param options defines options to set up the controller
  38032. */
  38033. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38034. targetMesh?: AbstractMesh;
  38035. poleTargetMesh?: AbstractMesh;
  38036. poleTargetBone?: Bone;
  38037. poleTargetLocalOffset?: Vector3;
  38038. poleAngle?: number;
  38039. bendAxis?: Vector3;
  38040. maxAngle?: number;
  38041. slerpAmount?: number;
  38042. });
  38043. private _setMaxAngle;
  38044. /**
  38045. * Force the controller to update the bones
  38046. */
  38047. update(): void;
  38048. }
  38049. }
  38050. declare module "babylonjs/Bones/boneLookController" {
  38051. import { Vector3 } from "babylonjs/Maths/math.vector";
  38052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38053. import { Bone } from "babylonjs/Bones/bone";
  38054. import { Space } from "babylonjs/Maths/math.axis";
  38055. /**
  38056. * Class used to make a bone look toward a point in space
  38057. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38058. */
  38059. export class BoneLookController {
  38060. private static _tmpVecs;
  38061. private static _tmpQuat;
  38062. private static _tmpMats;
  38063. /**
  38064. * The target Vector3 that the bone will look at
  38065. */
  38066. target: Vector3;
  38067. /**
  38068. * The mesh that the bone is attached to
  38069. */
  38070. mesh: AbstractMesh;
  38071. /**
  38072. * The bone that will be looking to the target
  38073. */
  38074. bone: Bone;
  38075. /**
  38076. * The up axis of the coordinate system that is used when the bone is rotated
  38077. */
  38078. upAxis: Vector3;
  38079. /**
  38080. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38081. */
  38082. upAxisSpace: Space;
  38083. /**
  38084. * Used to make an adjustment to the yaw of the bone
  38085. */
  38086. adjustYaw: number;
  38087. /**
  38088. * Used to make an adjustment to the pitch of the bone
  38089. */
  38090. adjustPitch: number;
  38091. /**
  38092. * Used to make an adjustment to the roll of the bone
  38093. */
  38094. adjustRoll: number;
  38095. /**
  38096. * 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)
  38097. */
  38098. slerpAmount: number;
  38099. private _minYaw;
  38100. private _maxYaw;
  38101. private _minPitch;
  38102. private _maxPitch;
  38103. private _minYawSin;
  38104. private _minYawCos;
  38105. private _maxYawSin;
  38106. private _maxYawCos;
  38107. private _midYawConstraint;
  38108. private _minPitchTan;
  38109. private _maxPitchTan;
  38110. private _boneQuat;
  38111. private _slerping;
  38112. private _transformYawPitch;
  38113. private _transformYawPitchInv;
  38114. private _firstFrameSkipped;
  38115. private _yawRange;
  38116. private _fowardAxis;
  38117. /**
  38118. * Gets or sets the minimum yaw angle that the bone can look to
  38119. */
  38120. minYaw: number;
  38121. /**
  38122. * Gets or sets the maximum yaw angle that the bone can look to
  38123. */
  38124. maxYaw: number;
  38125. /**
  38126. * Gets or sets the minimum pitch angle that the bone can look to
  38127. */
  38128. minPitch: number;
  38129. /**
  38130. * Gets or sets the maximum pitch angle that the bone can look to
  38131. */
  38132. maxPitch: number;
  38133. /**
  38134. * Create a BoneLookController
  38135. * @param mesh the mesh that the bone belongs to
  38136. * @param bone the bone that will be looking to the target
  38137. * @param target the target Vector3 to look at
  38138. * @param options optional settings:
  38139. * * maxYaw: the maximum angle the bone will yaw to
  38140. * * minYaw: the minimum angle the bone will yaw to
  38141. * * maxPitch: the maximum angle the bone will pitch to
  38142. * * minPitch: the minimum angle the bone will yaw to
  38143. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38144. * * upAxis: the up axis of the coordinate system
  38145. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38146. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38147. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38148. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38149. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38150. * * adjustRoll: used to make an adjustment to the roll of the bone
  38151. **/
  38152. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38153. maxYaw?: number;
  38154. minYaw?: number;
  38155. maxPitch?: number;
  38156. minPitch?: number;
  38157. slerpAmount?: number;
  38158. upAxis?: Vector3;
  38159. upAxisSpace?: Space;
  38160. yawAxis?: Vector3;
  38161. pitchAxis?: Vector3;
  38162. adjustYaw?: number;
  38163. adjustPitch?: number;
  38164. adjustRoll?: number;
  38165. });
  38166. /**
  38167. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38168. */
  38169. update(): void;
  38170. private _getAngleDiff;
  38171. private _getAngleBetween;
  38172. private _isAngleBetween;
  38173. }
  38174. }
  38175. declare module "babylonjs/Bones/index" {
  38176. export * from "babylonjs/Bones/bone";
  38177. export * from "babylonjs/Bones/boneIKController";
  38178. export * from "babylonjs/Bones/boneLookController";
  38179. export * from "babylonjs/Bones/skeleton";
  38180. }
  38181. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38182. import { Nullable } from "babylonjs/types";
  38183. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38185. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38186. /**
  38187. * Manage the gamepad inputs to control an arc rotate camera.
  38188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38189. */
  38190. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38191. /**
  38192. * Defines the camera the input is attached to.
  38193. */
  38194. camera: ArcRotateCamera;
  38195. /**
  38196. * Defines the gamepad the input is gathering event from.
  38197. */
  38198. gamepad: Nullable<Gamepad>;
  38199. /**
  38200. * Defines the gamepad rotation sensiblity.
  38201. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38202. */
  38203. gamepadRotationSensibility: number;
  38204. /**
  38205. * Defines the gamepad move sensiblity.
  38206. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38207. */
  38208. gamepadMoveSensibility: number;
  38209. private _onGamepadConnectedObserver;
  38210. private _onGamepadDisconnectedObserver;
  38211. /**
  38212. * Attach the input controls to a specific dom element to get the input from.
  38213. * @param element Defines the element the controls should be listened from
  38214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38215. */
  38216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38217. /**
  38218. * Detach the current controls from the specified dom element.
  38219. * @param element Defines the element to stop listening the inputs from
  38220. */
  38221. detachControl(element: Nullable<HTMLElement>): void;
  38222. /**
  38223. * Update the current camera state depending on the inputs that have been used this frame.
  38224. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38225. */
  38226. checkInputs(): void;
  38227. /**
  38228. * Gets the class name of the current intput.
  38229. * @returns the class name
  38230. */
  38231. getClassName(): string;
  38232. /**
  38233. * Get the friendly name associated with the input class.
  38234. * @returns the input friendly name
  38235. */
  38236. getSimpleName(): string;
  38237. }
  38238. }
  38239. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38240. import { Nullable } from "babylonjs/types";
  38241. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38242. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38243. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38244. interface ArcRotateCameraInputsManager {
  38245. /**
  38246. * Add orientation input support to the input manager.
  38247. * @returns the current input manager
  38248. */
  38249. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38250. }
  38251. }
  38252. /**
  38253. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38255. */
  38256. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38257. /**
  38258. * Defines the camera the input is attached to.
  38259. */
  38260. camera: ArcRotateCamera;
  38261. /**
  38262. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38263. */
  38264. alphaCorrection: number;
  38265. /**
  38266. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38267. */
  38268. gammaCorrection: number;
  38269. private _alpha;
  38270. private _gamma;
  38271. private _dirty;
  38272. private _deviceOrientationHandler;
  38273. /**
  38274. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38275. */
  38276. constructor();
  38277. /**
  38278. * Attach the input controls to a specific dom element to get the input from.
  38279. * @param element Defines the element the controls should be listened from
  38280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38281. */
  38282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38283. /** @hidden */
  38284. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38285. /**
  38286. * Update the current camera state depending on the inputs that have been used this frame.
  38287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38288. */
  38289. checkInputs(): void;
  38290. /**
  38291. * Detach the current controls from the specified dom element.
  38292. * @param element Defines the element to stop listening the inputs from
  38293. */
  38294. detachControl(element: Nullable<HTMLElement>): void;
  38295. /**
  38296. * Gets the class name of the current intput.
  38297. * @returns the class name
  38298. */
  38299. getClassName(): string;
  38300. /**
  38301. * Get the friendly name associated with the input class.
  38302. * @returns the input friendly name
  38303. */
  38304. getSimpleName(): string;
  38305. }
  38306. }
  38307. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38308. import { Nullable } from "babylonjs/types";
  38309. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38310. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38311. /**
  38312. * Listen to mouse events to control the camera.
  38313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38314. */
  38315. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38316. /**
  38317. * Defines the camera the input is attached to.
  38318. */
  38319. camera: FlyCamera;
  38320. /**
  38321. * Defines if touch is enabled. (Default is true.)
  38322. */
  38323. touchEnabled: boolean;
  38324. /**
  38325. * Defines the buttons associated with the input to handle camera rotation.
  38326. */
  38327. buttons: number[];
  38328. /**
  38329. * Assign buttons for Yaw control.
  38330. */
  38331. buttonsYaw: number[];
  38332. /**
  38333. * Assign buttons for Pitch control.
  38334. */
  38335. buttonsPitch: number[];
  38336. /**
  38337. * Assign buttons for Roll control.
  38338. */
  38339. buttonsRoll: number[];
  38340. /**
  38341. * Detect if any button is being pressed while mouse is moved.
  38342. * -1 = Mouse locked.
  38343. * 0 = Left button.
  38344. * 1 = Middle Button.
  38345. * 2 = Right Button.
  38346. */
  38347. activeButton: number;
  38348. /**
  38349. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38350. * Higher values reduce its sensitivity.
  38351. */
  38352. angularSensibility: number;
  38353. private _mousemoveCallback;
  38354. private _observer;
  38355. private _rollObserver;
  38356. private previousPosition;
  38357. private noPreventDefault;
  38358. private element;
  38359. /**
  38360. * Listen to mouse events to control the camera.
  38361. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38363. */
  38364. constructor(touchEnabled?: boolean);
  38365. /**
  38366. * Attach the mouse control to the HTML DOM element.
  38367. * @param element Defines the element that listens to the input events.
  38368. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38369. */
  38370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38371. /**
  38372. * Detach the current controls from the specified dom element.
  38373. * @param element Defines the element to stop listening the inputs from
  38374. */
  38375. detachControl(element: Nullable<HTMLElement>): void;
  38376. /**
  38377. * Gets the class name of the current input.
  38378. * @returns the class name.
  38379. */
  38380. getClassName(): string;
  38381. /**
  38382. * Get the friendly name associated with the input class.
  38383. * @returns the input's friendly name.
  38384. */
  38385. getSimpleName(): string;
  38386. private _pointerInput;
  38387. private _onMouseMove;
  38388. /**
  38389. * Rotate camera by mouse offset.
  38390. */
  38391. private rotateCamera;
  38392. }
  38393. }
  38394. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38395. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38396. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38397. /**
  38398. * Default Inputs manager for the FlyCamera.
  38399. * It groups all the default supported inputs for ease of use.
  38400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38401. */
  38402. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38403. /**
  38404. * Instantiates a new FlyCameraInputsManager.
  38405. * @param camera Defines the camera the inputs belong to.
  38406. */
  38407. constructor(camera: FlyCamera);
  38408. /**
  38409. * Add keyboard input support to the input manager.
  38410. * @returns the new FlyCameraKeyboardMoveInput().
  38411. */
  38412. addKeyboard(): FlyCameraInputsManager;
  38413. /**
  38414. * Add mouse input support to the input manager.
  38415. * @param touchEnabled Enable touch screen support.
  38416. * @returns the new FlyCameraMouseInput().
  38417. */
  38418. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38419. }
  38420. }
  38421. declare module "babylonjs/Cameras/flyCamera" {
  38422. import { Scene } from "babylonjs/scene";
  38423. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38425. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38426. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38427. /**
  38428. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38429. * such as in a 3D Space Shooter or a Flight Simulator.
  38430. */
  38431. export class FlyCamera extends TargetCamera {
  38432. /**
  38433. * Define the collision ellipsoid of the camera.
  38434. * This is helpful for simulating a camera body, like a player's body.
  38435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38436. */
  38437. ellipsoid: Vector3;
  38438. /**
  38439. * Define an offset for the position of the ellipsoid around the camera.
  38440. * This can be helpful if the camera is attached away from the player's body center,
  38441. * such as at its head.
  38442. */
  38443. ellipsoidOffset: Vector3;
  38444. /**
  38445. * Enable or disable collisions of the camera with the rest of the scene objects.
  38446. */
  38447. checkCollisions: boolean;
  38448. /**
  38449. * Enable or disable gravity on the camera.
  38450. */
  38451. applyGravity: boolean;
  38452. /**
  38453. * Define the current direction the camera is moving to.
  38454. */
  38455. cameraDirection: Vector3;
  38456. /**
  38457. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38458. * This overrides and empties cameraRotation.
  38459. */
  38460. rotationQuaternion: Quaternion;
  38461. /**
  38462. * Track Roll to maintain the wanted Rolling when looking around.
  38463. */
  38464. _trackRoll: number;
  38465. /**
  38466. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38467. */
  38468. rollCorrect: number;
  38469. /**
  38470. * Mimic a banked turn, Rolling the camera when Yawing.
  38471. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38472. */
  38473. bankedTurn: boolean;
  38474. /**
  38475. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38476. */
  38477. bankedTurnLimit: number;
  38478. /**
  38479. * Value of 0 disables the banked Roll.
  38480. * Value of 1 is equal to the Yaw angle in radians.
  38481. */
  38482. bankedTurnMultiplier: number;
  38483. /**
  38484. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38485. */
  38486. inputs: FlyCameraInputsManager;
  38487. /**
  38488. * Gets the input sensibility for mouse input.
  38489. * Higher values reduce sensitivity.
  38490. */
  38491. /**
  38492. * Sets the input sensibility for a mouse input.
  38493. * Higher values reduce sensitivity.
  38494. */
  38495. angularSensibility: number;
  38496. /**
  38497. * Get the keys for camera movement forward.
  38498. */
  38499. /**
  38500. * Set the keys for camera movement forward.
  38501. */
  38502. keysForward: number[];
  38503. /**
  38504. * Get the keys for camera movement backward.
  38505. */
  38506. keysBackward: number[];
  38507. /**
  38508. * Get the keys for camera movement up.
  38509. */
  38510. /**
  38511. * Set the keys for camera movement up.
  38512. */
  38513. keysUp: number[];
  38514. /**
  38515. * Get the keys for camera movement down.
  38516. */
  38517. /**
  38518. * Set the keys for camera movement down.
  38519. */
  38520. keysDown: number[];
  38521. /**
  38522. * Get the keys for camera movement left.
  38523. */
  38524. /**
  38525. * Set the keys for camera movement left.
  38526. */
  38527. keysLeft: number[];
  38528. /**
  38529. * Set the keys for camera movement right.
  38530. */
  38531. /**
  38532. * Set the keys for camera movement right.
  38533. */
  38534. keysRight: number[];
  38535. /**
  38536. * Event raised when the camera collides with a mesh in the scene.
  38537. */
  38538. onCollide: (collidedMesh: AbstractMesh) => void;
  38539. private _collider;
  38540. private _needMoveForGravity;
  38541. private _oldPosition;
  38542. private _diffPosition;
  38543. private _newPosition;
  38544. /** @hidden */
  38545. _localDirection: Vector3;
  38546. /** @hidden */
  38547. _transformedDirection: Vector3;
  38548. /**
  38549. * Instantiates a FlyCamera.
  38550. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38551. * such as in a 3D Space Shooter or a Flight Simulator.
  38552. * @param name Define the name of the camera in the scene.
  38553. * @param position Define the starting position of the camera in the scene.
  38554. * @param scene Define the scene the camera belongs to.
  38555. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38556. */
  38557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38558. /**
  38559. * Attach a control to the HTML DOM element.
  38560. * @param element Defines the element that listens to the input events.
  38561. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38562. */
  38563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38564. /**
  38565. * Detach a control from the HTML DOM element.
  38566. * The camera will stop reacting to that input.
  38567. * @param element Defines the element that listens to the input events.
  38568. */
  38569. detachControl(element: HTMLElement): void;
  38570. private _collisionMask;
  38571. /**
  38572. * Get the mask that the camera ignores in collision events.
  38573. */
  38574. /**
  38575. * Set the mask that the camera ignores in collision events.
  38576. */
  38577. collisionMask: number;
  38578. /** @hidden */
  38579. _collideWithWorld(displacement: Vector3): void;
  38580. /** @hidden */
  38581. private _onCollisionPositionChange;
  38582. /** @hidden */
  38583. _checkInputs(): void;
  38584. /** @hidden */
  38585. _decideIfNeedsToMove(): boolean;
  38586. /** @hidden */
  38587. _updatePosition(): void;
  38588. /**
  38589. * Restore the Roll to its target value at the rate specified.
  38590. * @param rate - Higher means slower restoring.
  38591. * @hidden
  38592. */
  38593. restoreRoll(rate: number): void;
  38594. /**
  38595. * Destroy the camera and release the current resources held by it.
  38596. */
  38597. dispose(): void;
  38598. /**
  38599. * Get the current object class name.
  38600. * @returns the class name.
  38601. */
  38602. getClassName(): string;
  38603. }
  38604. }
  38605. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38606. import { Nullable } from "babylonjs/types";
  38607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38608. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38609. /**
  38610. * Listen to keyboard events to control the camera.
  38611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38612. */
  38613. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38614. /**
  38615. * Defines the camera the input is attached to.
  38616. */
  38617. camera: FlyCamera;
  38618. /**
  38619. * The list of keyboard keys used to control the forward move of the camera.
  38620. */
  38621. keysForward: number[];
  38622. /**
  38623. * The list of keyboard keys used to control the backward move of the camera.
  38624. */
  38625. keysBackward: number[];
  38626. /**
  38627. * The list of keyboard keys used to control the forward move of the camera.
  38628. */
  38629. keysUp: number[];
  38630. /**
  38631. * The list of keyboard keys used to control the backward move of the camera.
  38632. */
  38633. keysDown: number[];
  38634. /**
  38635. * The list of keyboard keys used to control the right strafe move of the camera.
  38636. */
  38637. keysRight: number[];
  38638. /**
  38639. * The list of keyboard keys used to control the left strafe move of the camera.
  38640. */
  38641. keysLeft: number[];
  38642. private _keys;
  38643. private _onCanvasBlurObserver;
  38644. private _onKeyboardObserver;
  38645. private _engine;
  38646. private _scene;
  38647. /**
  38648. * Attach the input controls to a specific dom element to get the input from.
  38649. * @param element Defines the element the controls should be listened from
  38650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38651. */
  38652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38653. /**
  38654. * Detach the current controls from the specified dom element.
  38655. * @param element Defines the element to stop listening the inputs from
  38656. */
  38657. detachControl(element: Nullable<HTMLElement>): void;
  38658. /**
  38659. * Gets the class name of the current intput.
  38660. * @returns the class name
  38661. */
  38662. getClassName(): string;
  38663. /** @hidden */
  38664. _onLostFocus(e: FocusEvent): void;
  38665. /**
  38666. * Get the friendly name associated with the input class.
  38667. * @returns the input friendly name
  38668. */
  38669. getSimpleName(): string;
  38670. /**
  38671. * Update the current camera state depending on the inputs that have been used this frame.
  38672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38673. */
  38674. checkInputs(): void;
  38675. }
  38676. }
  38677. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38678. import { Nullable } from "babylonjs/types";
  38679. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38680. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38681. /**
  38682. * Manage the mouse wheel inputs to control a follow camera.
  38683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38684. */
  38685. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38686. /**
  38687. * Defines the camera the input is attached to.
  38688. */
  38689. camera: FollowCamera;
  38690. /**
  38691. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38692. */
  38693. axisControlRadius: boolean;
  38694. /**
  38695. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38696. */
  38697. axisControlHeight: boolean;
  38698. /**
  38699. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38700. */
  38701. axisControlRotation: boolean;
  38702. /**
  38703. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38704. * relation to mouseWheel events.
  38705. */
  38706. wheelPrecision: number;
  38707. /**
  38708. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38709. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38710. */
  38711. wheelDeltaPercentage: number;
  38712. private _wheel;
  38713. private _observer;
  38714. /**
  38715. * Attach the input controls to a specific dom element to get the input from.
  38716. * @param element Defines the element the controls should be listened from
  38717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38718. */
  38719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38720. /**
  38721. * Detach the current controls from the specified dom element.
  38722. * @param element Defines the element to stop listening the inputs from
  38723. */
  38724. detachControl(element: Nullable<HTMLElement>): void;
  38725. /**
  38726. * Gets the class name of the current intput.
  38727. * @returns the class name
  38728. */
  38729. getClassName(): string;
  38730. /**
  38731. * Get the friendly name associated with the input class.
  38732. * @returns the input friendly name
  38733. */
  38734. getSimpleName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38738. import { Nullable } from "babylonjs/types";
  38739. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38740. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38741. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38742. /**
  38743. * Manage the pointers inputs to control an follow camera.
  38744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38745. */
  38746. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38747. /**
  38748. * Defines the camera the input is attached to.
  38749. */
  38750. camera: FollowCamera;
  38751. /**
  38752. * Gets the class name of the current input.
  38753. * @returns the class name
  38754. */
  38755. getClassName(): string;
  38756. /**
  38757. * Defines the pointer angular sensibility along the X axis or how fast is
  38758. * the camera rotating.
  38759. * A negative number will reverse the axis direction.
  38760. */
  38761. angularSensibilityX: number;
  38762. /**
  38763. * Defines the pointer angular sensibility along the Y axis or how fast is
  38764. * the camera rotating.
  38765. * A negative number will reverse the axis direction.
  38766. */
  38767. angularSensibilityY: number;
  38768. /**
  38769. * Defines the pointer pinch precision or how fast is the camera zooming.
  38770. * A negative number will reverse the axis direction.
  38771. */
  38772. pinchPrecision: number;
  38773. /**
  38774. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38775. * from 0.
  38776. * It defines the percentage of current camera.radius to use as delta when
  38777. * pinch zoom is used.
  38778. */
  38779. pinchDeltaPercentage: number;
  38780. /**
  38781. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38782. */
  38783. axisXControlRadius: boolean;
  38784. /**
  38785. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38786. */
  38787. axisXControlHeight: boolean;
  38788. /**
  38789. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38790. */
  38791. axisXControlRotation: boolean;
  38792. /**
  38793. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38794. */
  38795. axisYControlRadius: boolean;
  38796. /**
  38797. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38798. */
  38799. axisYControlHeight: boolean;
  38800. /**
  38801. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38802. */
  38803. axisYControlRotation: boolean;
  38804. /**
  38805. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38806. */
  38807. axisPinchControlRadius: boolean;
  38808. /**
  38809. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38810. */
  38811. axisPinchControlHeight: boolean;
  38812. /**
  38813. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38814. */
  38815. axisPinchControlRotation: boolean;
  38816. /**
  38817. * Log error messages if basic misconfiguration has occurred.
  38818. */
  38819. warningEnable: boolean;
  38820. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38821. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38822. private _warningCounter;
  38823. private _warning;
  38824. }
  38825. }
  38826. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38827. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38828. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38829. /**
  38830. * Default Inputs manager for the FollowCamera.
  38831. * It groups all the default supported inputs for ease of use.
  38832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38833. */
  38834. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38835. /**
  38836. * Instantiates a new FollowCameraInputsManager.
  38837. * @param camera Defines the camera the inputs belong to
  38838. */
  38839. constructor(camera: FollowCamera);
  38840. /**
  38841. * Add keyboard input support to the input manager.
  38842. * @returns the current input manager
  38843. */
  38844. addKeyboard(): FollowCameraInputsManager;
  38845. /**
  38846. * Add mouse wheel input support to the input manager.
  38847. * @returns the current input manager
  38848. */
  38849. addMouseWheel(): FollowCameraInputsManager;
  38850. /**
  38851. * Add pointers input support to the input manager.
  38852. * @returns the current input manager
  38853. */
  38854. addPointers(): FollowCameraInputsManager;
  38855. /**
  38856. * Add orientation input support to the input manager.
  38857. * @returns the current input manager
  38858. */
  38859. addVRDeviceOrientation(): FollowCameraInputsManager;
  38860. }
  38861. }
  38862. declare module "babylonjs/Cameras/followCamera" {
  38863. import { Nullable } from "babylonjs/types";
  38864. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38865. import { Scene } from "babylonjs/scene";
  38866. import { Vector3 } from "babylonjs/Maths/math.vector";
  38867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38868. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38869. /**
  38870. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38871. * an arc rotate version arcFollowCamera are available.
  38872. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38873. */
  38874. export class FollowCamera extends TargetCamera {
  38875. /**
  38876. * Distance the follow camera should follow an object at
  38877. */
  38878. radius: number;
  38879. /**
  38880. * Minimum allowed distance of the camera to the axis of rotation
  38881. * (The camera can not get closer).
  38882. * This can help limiting how the Camera is able to move in the scene.
  38883. */
  38884. lowerRadiusLimit: Nullable<number>;
  38885. /**
  38886. * Maximum allowed distance of the camera to the axis of rotation
  38887. * (The camera can not get further).
  38888. * This can help limiting how the Camera is able to move in the scene.
  38889. */
  38890. upperRadiusLimit: Nullable<number>;
  38891. /**
  38892. * Define a rotation offset between the camera and the object it follows
  38893. */
  38894. rotationOffset: number;
  38895. /**
  38896. * Minimum allowed angle to camera position relative to target object.
  38897. * This can help limiting how the Camera is able to move in the scene.
  38898. */
  38899. lowerRotationOffsetLimit: Nullable<number>;
  38900. /**
  38901. * Maximum allowed angle to camera position relative to target object.
  38902. * This can help limiting how the Camera is able to move in the scene.
  38903. */
  38904. upperRotationOffsetLimit: Nullable<number>;
  38905. /**
  38906. * Define a height offset between the camera and the object it follows.
  38907. * It can help following an object from the top (like a car chaing a plane)
  38908. */
  38909. heightOffset: number;
  38910. /**
  38911. * Minimum allowed height of camera position relative to target object.
  38912. * This can help limiting how the Camera is able to move in the scene.
  38913. */
  38914. lowerHeightOffsetLimit: Nullable<number>;
  38915. /**
  38916. * Maximum allowed height of camera position relative to target object.
  38917. * This can help limiting how the Camera is able to move in the scene.
  38918. */
  38919. upperHeightOffsetLimit: Nullable<number>;
  38920. /**
  38921. * Define how fast the camera can accelerate to follow it s target.
  38922. */
  38923. cameraAcceleration: number;
  38924. /**
  38925. * Define the speed limit of the camera following an object.
  38926. */
  38927. maxCameraSpeed: number;
  38928. /**
  38929. * Define the target of the camera.
  38930. */
  38931. lockedTarget: Nullable<AbstractMesh>;
  38932. /**
  38933. * Defines the input associated with the camera.
  38934. */
  38935. inputs: FollowCameraInputsManager;
  38936. /**
  38937. * Instantiates the follow camera.
  38938. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38939. * @param name Define the name of the camera in the scene
  38940. * @param position Define the position of the camera
  38941. * @param scene Define the scene the camera belong to
  38942. * @param lockedTarget Define the target of the camera
  38943. */
  38944. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38945. private _follow;
  38946. /**
  38947. * Attached controls to the current camera.
  38948. * @param element Defines the element the controls should be listened from
  38949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38950. */
  38951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38952. /**
  38953. * Detach the current controls from the camera.
  38954. * The camera will stop reacting to inputs.
  38955. * @param element Defines the element to stop listening the inputs from
  38956. */
  38957. detachControl(element: HTMLElement): void;
  38958. /** @hidden */
  38959. _checkInputs(): void;
  38960. private _checkLimits;
  38961. /**
  38962. * Gets the camera class name.
  38963. * @returns the class name
  38964. */
  38965. getClassName(): string;
  38966. }
  38967. /**
  38968. * Arc Rotate version of the follow camera.
  38969. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38971. */
  38972. export class ArcFollowCamera extends TargetCamera {
  38973. /** The longitudinal angle of the camera */
  38974. alpha: number;
  38975. /** The latitudinal angle of the camera */
  38976. beta: number;
  38977. /** The radius of the camera from its target */
  38978. radius: number;
  38979. /** Define the camera target (the messh it should follow) */
  38980. target: Nullable<AbstractMesh>;
  38981. private _cartesianCoordinates;
  38982. /**
  38983. * Instantiates a new ArcFollowCamera
  38984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38985. * @param name Define the name of the camera
  38986. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38987. * @param beta Define the rotation angle of the camera around the elevation axis
  38988. * @param radius Define the radius of the camera from its target point
  38989. * @param target Define the target of the camera
  38990. * @param scene Define the scene the camera belongs to
  38991. */
  38992. constructor(name: string,
  38993. /** The longitudinal angle of the camera */
  38994. alpha: number,
  38995. /** The latitudinal angle of the camera */
  38996. beta: number,
  38997. /** The radius of the camera from its target */
  38998. radius: number,
  38999. /** Define the camera target (the messh it should follow) */
  39000. target: Nullable<AbstractMesh>, scene: Scene);
  39001. private _follow;
  39002. /** @hidden */
  39003. _checkInputs(): void;
  39004. /**
  39005. * Returns the class name of the object.
  39006. * It is mostly used internally for serialization purposes.
  39007. */
  39008. getClassName(): string;
  39009. }
  39010. }
  39011. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39012. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39013. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39014. import { Nullable } from "babylonjs/types";
  39015. /**
  39016. * Manage the keyboard inputs to control the movement of a follow camera.
  39017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39018. */
  39019. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39020. /**
  39021. * Defines the camera the input is attached to.
  39022. */
  39023. camera: FollowCamera;
  39024. /**
  39025. * Defines the list of key codes associated with the up action (increase heightOffset)
  39026. */
  39027. keysHeightOffsetIncr: number[];
  39028. /**
  39029. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39030. */
  39031. keysHeightOffsetDecr: number[];
  39032. /**
  39033. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39034. */
  39035. keysHeightOffsetModifierAlt: boolean;
  39036. /**
  39037. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39038. */
  39039. keysHeightOffsetModifierCtrl: boolean;
  39040. /**
  39041. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39042. */
  39043. keysHeightOffsetModifierShift: boolean;
  39044. /**
  39045. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39046. */
  39047. keysRotationOffsetIncr: number[];
  39048. /**
  39049. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39050. */
  39051. keysRotationOffsetDecr: number[];
  39052. /**
  39053. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39054. */
  39055. keysRotationOffsetModifierAlt: boolean;
  39056. /**
  39057. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39058. */
  39059. keysRotationOffsetModifierCtrl: boolean;
  39060. /**
  39061. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39062. */
  39063. keysRotationOffsetModifierShift: boolean;
  39064. /**
  39065. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39066. */
  39067. keysRadiusIncr: number[];
  39068. /**
  39069. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39070. */
  39071. keysRadiusDecr: number[];
  39072. /**
  39073. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39074. */
  39075. keysRadiusModifierAlt: boolean;
  39076. /**
  39077. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39078. */
  39079. keysRadiusModifierCtrl: boolean;
  39080. /**
  39081. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39082. */
  39083. keysRadiusModifierShift: boolean;
  39084. /**
  39085. * Defines the rate of change of heightOffset.
  39086. */
  39087. heightSensibility: number;
  39088. /**
  39089. * Defines the rate of change of rotationOffset.
  39090. */
  39091. rotationSensibility: number;
  39092. /**
  39093. * Defines the rate of change of radius.
  39094. */
  39095. radiusSensibility: number;
  39096. private _keys;
  39097. private _ctrlPressed;
  39098. private _altPressed;
  39099. private _shiftPressed;
  39100. private _onCanvasBlurObserver;
  39101. private _onKeyboardObserver;
  39102. private _engine;
  39103. private _scene;
  39104. /**
  39105. * Attach the input controls to a specific dom element to get the input from.
  39106. * @param element Defines the element the controls should be listened from
  39107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39108. */
  39109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39110. /**
  39111. * Detach the current controls from the specified dom element.
  39112. * @param element Defines the element to stop listening the inputs from
  39113. */
  39114. detachControl(element: Nullable<HTMLElement>): void;
  39115. /**
  39116. * Update the current camera state depending on the inputs that have been used this frame.
  39117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39118. */
  39119. checkInputs(): void;
  39120. /**
  39121. * Gets the class name of the current input.
  39122. * @returns the class name
  39123. */
  39124. getClassName(): string;
  39125. /**
  39126. * Get the friendly name associated with the input class.
  39127. * @returns the input friendly name
  39128. */
  39129. getSimpleName(): string;
  39130. /**
  39131. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39132. * allow modification of the heightOffset value.
  39133. */
  39134. private _modifierHeightOffset;
  39135. /**
  39136. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39137. * allow modification of the rotationOffset value.
  39138. */
  39139. private _modifierRotationOffset;
  39140. /**
  39141. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39142. * allow modification of the radius value.
  39143. */
  39144. private _modifierRadius;
  39145. }
  39146. }
  39147. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39148. import { Nullable } from "babylonjs/types";
  39149. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39150. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39151. import { Observable } from "babylonjs/Misc/observable";
  39152. module "babylonjs/Cameras/freeCameraInputsManager" {
  39153. interface FreeCameraInputsManager {
  39154. /**
  39155. * @hidden
  39156. */
  39157. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39158. /**
  39159. * Add orientation input support to the input manager.
  39160. * @returns the current input manager
  39161. */
  39162. addDeviceOrientation(): FreeCameraInputsManager;
  39163. }
  39164. }
  39165. /**
  39166. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39167. * Screen rotation is taken into account.
  39168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39169. */
  39170. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39171. private _camera;
  39172. private _screenOrientationAngle;
  39173. private _constantTranform;
  39174. private _screenQuaternion;
  39175. private _alpha;
  39176. private _beta;
  39177. private _gamma;
  39178. /**
  39179. * Can be used to detect if a device orientation sensor is availible on a device
  39180. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39181. * @returns a promise that will resolve on orientation change
  39182. */
  39183. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39184. /**
  39185. * @hidden
  39186. */
  39187. _onDeviceOrientationChangedObservable: Observable<void>;
  39188. /**
  39189. * Instantiates a new input
  39190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39191. */
  39192. constructor();
  39193. /**
  39194. * Define the camera controlled by the input.
  39195. */
  39196. camera: FreeCamera;
  39197. /**
  39198. * Attach the input controls to a specific dom element to get the input from.
  39199. * @param element Defines the element the controls should be listened from
  39200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39201. */
  39202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39203. private _orientationChanged;
  39204. private _deviceOrientation;
  39205. /**
  39206. * Detach the current controls from the specified dom element.
  39207. * @param element Defines the element to stop listening the inputs from
  39208. */
  39209. detachControl(element: Nullable<HTMLElement>): void;
  39210. /**
  39211. * Update the current camera state depending on the inputs that have been used this frame.
  39212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39213. */
  39214. checkInputs(): void;
  39215. /**
  39216. * Gets the class name of the current intput.
  39217. * @returns the class name
  39218. */
  39219. getClassName(): string;
  39220. /**
  39221. * Get the friendly name associated with the input class.
  39222. * @returns the input friendly name
  39223. */
  39224. getSimpleName(): string;
  39225. }
  39226. }
  39227. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39228. import { Nullable } from "babylonjs/types";
  39229. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39230. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39231. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39232. /**
  39233. * Manage the gamepad inputs to control a free camera.
  39234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39235. */
  39236. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39237. /**
  39238. * Define the camera the input is attached to.
  39239. */
  39240. camera: FreeCamera;
  39241. /**
  39242. * Define the Gamepad controlling the input
  39243. */
  39244. gamepad: Nullable<Gamepad>;
  39245. /**
  39246. * Defines the gamepad rotation sensiblity.
  39247. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39248. */
  39249. gamepadAngularSensibility: number;
  39250. /**
  39251. * Defines the gamepad move sensiblity.
  39252. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39253. */
  39254. gamepadMoveSensibility: number;
  39255. private _onGamepadConnectedObserver;
  39256. private _onGamepadDisconnectedObserver;
  39257. private _cameraTransform;
  39258. private _deltaTransform;
  39259. private _vector3;
  39260. private _vector2;
  39261. /**
  39262. * Attach the input controls to a specific dom element to get the input from.
  39263. * @param element Defines the element the controls should be listened from
  39264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39265. */
  39266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39267. /**
  39268. * Detach the current controls from the specified dom element.
  39269. * @param element Defines the element to stop listening the inputs from
  39270. */
  39271. detachControl(element: Nullable<HTMLElement>): void;
  39272. /**
  39273. * Update the current camera state depending on the inputs that have been used this frame.
  39274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39275. */
  39276. checkInputs(): void;
  39277. /**
  39278. * Gets the class name of the current intput.
  39279. * @returns the class name
  39280. */
  39281. getClassName(): string;
  39282. /**
  39283. * Get the friendly name associated with the input class.
  39284. * @returns the input friendly name
  39285. */
  39286. getSimpleName(): string;
  39287. }
  39288. }
  39289. declare module "babylonjs/Misc/virtualJoystick" {
  39290. import { Nullable } from "babylonjs/types";
  39291. import { Vector3 } from "babylonjs/Maths/math.vector";
  39292. /**
  39293. * Defines the potential axis of a Joystick
  39294. */
  39295. export enum JoystickAxis {
  39296. /** X axis */
  39297. X = 0,
  39298. /** Y axis */
  39299. Y = 1,
  39300. /** Z axis */
  39301. Z = 2
  39302. }
  39303. /**
  39304. * Class used to define virtual joystick (used in touch mode)
  39305. */
  39306. export class VirtualJoystick {
  39307. /**
  39308. * Gets or sets a boolean indicating that left and right values must be inverted
  39309. */
  39310. reverseLeftRight: boolean;
  39311. /**
  39312. * Gets or sets a boolean indicating that up and down values must be inverted
  39313. */
  39314. reverseUpDown: boolean;
  39315. /**
  39316. * Gets the offset value for the position (ie. the change of the position value)
  39317. */
  39318. deltaPosition: Vector3;
  39319. /**
  39320. * Gets a boolean indicating if the virtual joystick was pressed
  39321. */
  39322. pressed: boolean;
  39323. /**
  39324. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39325. */
  39326. static Canvas: Nullable<HTMLCanvasElement>;
  39327. private static _globalJoystickIndex;
  39328. private static vjCanvasContext;
  39329. private static vjCanvasWidth;
  39330. private static vjCanvasHeight;
  39331. private static halfWidth;
  39332. private _action;
  39333. private _axisTargetedByLeftAndRight;
  39334. private _axisTargetedByUpAndDown;
  39335. private _joystickSensibility;
  39336. private _inversedSensibility;
  39337. private _joystickPointerID;
  39338. private _joystickColor;
  39339. private _joystickPointerPos;
  39340. private _joystickPreviousPointerPos;
  39341. private _joystickPointerStartPos;
  39342. private _deltaJoystickVector;
  39343. private _leftJoystick;
  39344. private _touches;
  39345. private _onPointerDownHandlerRef;
  39346. private _onPointerMoveHandlerRef;
  39347. private _onPointerUpHandlerRef;
  39348. private _onResize;
  39349. /**
  39350. * Creates a new virtual joystick
  39351. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39352. */
  39353. constructor(leftJoystick?: boolean);
  39354. /**
  39355. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39356. * @param newJoystickSensibility defines the new sensibility
  39357. */
  39358. setJoystickSensibility(newJoystickSensibility: number): void;
  39359. private _onPointerDown;
  39360. private _onPointerMove;
  39361. private _onPointerUp;
  39362. /**
  39363. * Change the color of the virtual joystick
  39364. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39365. */
  39366. setJoystickColor(newColor: string): void;
  39367. /**
  39368. * Defines a callback to call when the joystick is touched
  39369. * @param action defines the callback
  39370. */
  39371. setActionOnTouch(action: () => any): void;
  39372. /**
  39373. * Defines which axis you'd like to control for left & right
  39374. * @param axis defines the axis to use
  39375. */
  39376. setAxisForLeftRight(axis: JoystickAxis): void;
  39377. /**
  39378. * Defines which axis you'd like to control for up & down
  39379. * @param axis defines the axis to use
  39380. */
  39381. setAxisForUpDown(axis: JoystickAxis): void;
  39382. private _drawVirtualJoystick;
  39383. /**
  39384. * Release internal HTML canvas
  39385. */
  39386. releaseCanvas(): void;
  39387. }
  39388. }
  39389. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39390. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39391. import { Nullable } from "babylonjs/types";
  39392. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39393. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39394. module "babylonjs/Cameras/freeCameraInputsManager" {
  39395. interface FreeCameraInputsManager {
  39396. /**
  39397. * Add virtual joystick input support to the input manager.
  39398. * @returns the current input manager
  39399. */
  39400. addVirtualJoystick(): FreeCameraInputsManager;
  39401. }
  39402. }
  39403. /**
  39404. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39406. */
  39407. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39408. /**
  39409. * Defines the camera the input is attached to.
  39410. */
  39411. camera: FreeCamera;
  39412. private _leftjoystick;
  39413. private _rightjoystick;
  39414. /**
  39415. * Gets the left stick of the virtual joystick.
  39416. * @returns The virtual Joystick
  39417. */
  39418. getLeftJoystick(): VirtualJoystick;
  39419. /**
  39420. * Gets the right stick of the virtual joystick.
  39421. * @returns The virtual Joystick
  39422. */
  39423. getRightJoystick(): VirtualJoystick;
  39424. /**
  39425. * Update the current camera state depending on the inputs that have been used this frame.
  39426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39427. */
  39428. checkInputs(): void;
  39429. /**
  39430. * Attach the input controls to a specific dom element to get the input from.
  39431. * @param element Defines the element the controls should be listened from
  39432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39433. */
  39434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39435. /**
  39436. * Detach the current controls from the specified dom element.
  39437. * @param element Defines the element to stop listening the inputs from
  39438. */
  39439. detachControl(element: Nullable<HTMLElement>): void;
  39440. /**
  39441. * Gets the class name of the current intput.
  39442. * @returns the class name
  39443. */
  39444. getClassName(): string;
  39445. /**
  39446. * Get the friendly name associated with the input class.
  39447. * @returns the input friendly name
  39448. */
  39449. getSimpleName(): string;
  39450. }
  39451. }
  39452. declare module "babylonjs/Cameras/Inputs/index" {
  39453. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39454. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39455. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39456. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39457. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39458. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39459. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39460. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39461. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39462. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39463. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39464. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39465. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39466. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39467. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39468. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39469. }
  39470. declare module "babylonjs/Cameras/touchCamera" {
  39471. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39472. import { Scene } from "babylonjs/scene";
  39473. import { Vector3 } from "babylonjs/Maths/math.vector";
  39474. /**
  39475. * This represents a FPS type of camera controlled by touch.
  39476. * This is like a universal camera minus the Gamepad controls.
  39477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39478. */
  39479. export class TouchCamera extends FreeCamera {
  39480. /**
  39481. * Defines the touch sensibility for rotation.
  39482. * The higher the faster.
  39483. */
  39484. touchAngularSensibility: number;
  39485. /**
  39486. * Defines the touch sensibility for move.
  39487. * The higher the faster.
  39488. */
  39489. touchMoveSensibility: number;
  39490. /**
  39491. * Instantiates a new touch camera.
  39492. * This represents a FPS type of camera controlled by touch.
  39493. * This is like a universal camera minus the Gamepad controls.
  39494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39495. * @param name Define the name of the camera in the scene
  39496. * @param position Define the start position of the camera in the scene
  39497. * @param scene Define the scene the camera belongs to
  39498. */
  39499. constructor(name: string, position: Vector3, scene: Scene);
  39500. /**
  39501. * Gets the current object class name.
  39502. * @return the class name
  39503. */
  39504. getClassName(): string;
  39505. /** @hidden */
  39506. _setupInputs(): void;
  39507. }
  39508. }
  39509. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39510. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39511. import { Scene } from "babylonjs/scene";
  39512. import { Vector3 } from "babylonjs/Maths/math.vector";
  39513. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39514. import { Axis } from "babylonjs/Maths/math.axis";
  39515. /**
  39516. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39517. * being tilted forward or back and left or right.
  39518. */
  39519. export class DeviceOrientationCamera extends FreeCamera {
  39520. private _initialQuaternion;
  39521. private _quaternionCache;
  39522. private _tmpDragQuaternion;
  39523. private _disablePointerInputWhenUsingDeviceOrientation;
  39524. /**
  39525. * Creates a new device orientation camera
  39526. * @param name The name of the camera
  39527. * @param position The start position camera
  39528. * @param scene The scene the camera belongs to
  39529. */
  39530. constructor(name: string, position: Vector3, scene: Scene);
  39531. /**
  39532. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39533. */
  39534. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39535. private _dragFactor;
  39536. /**
  39537. * Enabled turning on the y axis when the orientation sensor is active
  39538. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39539. */
  39540. enableHorizontalDragging(dragFactor?: number): void;
  39541. /**
  39542. * Gets the current instance class name ("DeviceOrientationCamera").
  39543. * This helps avoiding instanceof at run time.
  39544. * @returns the class name
  39545. */
  39546. getClassName(): string;
  39547. /**
  39548. * @hidden
  39549. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39550. */
  39551. _checkInputs(): void;
  39552. /**
  39553. * Reset the camera to its default orientation on the specified axis only.
  39554. * @param axis The axis to reset
  39555. */
  39556. resetToCurrentRotation(axis?: Axis): void;
  39557. }
  39558. }
  39559. declare module "babylonjs/Gamepads/xboxGamepad" {
  39560. import { Observable } from "babylonjs/Misc/observable";
  39561. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39562. /**
  39563. * Defines supported buttons for XBox360 compatible gamepads
  39564. */
  39565. export enum Xbox360Button {
  39566. /** A */
  39567. A = 0,
  39568. /** B */
  39569. B = 1,
  39570. /** X */
  39571. X = 2,
  39572. /** Y */
  39573. Y = 3,
  39574. /** Start */
  39575. Start = 4,
  39576. /** Back */
  39577. Back = 5,
  39578. /** Left button */
  39579. LB = 6,
  39580. /** Right button */
  39581. RB = 7,
  39582. /** Left stick */
  39583. LeftStick = 8,
  39584. /** Right stick */
  39585. RightStick = 9
  39586. }
  39587. /** Defines values for XBox360 DPad */
  39588. export enum Xbox360Dpad {
  39589. /** Up */
  39590. Up = 0,
  39591. /** Down */
  39592. Down = 1,
  39593. /** Left */
  39594. Left = 2,
  39595. /** Right */
  39596. Right = 3
  39597. }
  39598. /**
  39599. * Defines a XBox360 gamepad
  39600. */
  39601. export class Xbox360Pad extends Gamepad {
  39602. private _leftTrigger;
  39603. private _rightTrigger;
  39604. private _onlefttriggerchanged;
  39605. private _onrighttriggerchanged;
  39606. private _onbuttondown;
  39607. private _onbuttonup;
  39608. private _ondpaddown;
  39609. private _ondpadup;
  39610. /** Observable raised when a button is pressed */
  39611. onButtonDownObservable: Observable<Xbox360Button>;
  39612. /** Observable raised when a button is released */
  39613. onButtonUpObservable: Observable<Xbox360Button>;
  39614. /** Observable raised when a pad is pressed */
  39615. onPadDownObservable: Observable<Xbox360Dpad>;
  39616. /** Observable raised when a pad is released */
  39617. onPadUpObservable: Observable<Xbox360Dpad>;
  39618. private _buttonA;
  39619. private _buttonB;
  39620. private _buttonX;
  39621. private _buttonY;
  39622. private _buttonBack;
  39623. private _buttonStart;
  39624. private _buttonLB;
  39625. private _buttonRB;
  39626. private _buttonLeftStick;
  39627. private _buttonRightStick;
  39628. private _dPadUp;
  39629. private _dPadDown;
  39630. private _dPadLeft;
  39631. private _dPadRight;
  39632. private _isXboxOnePad;
  39633. /**
  39634. * Creates a new XBox360 gamepad object
  39635. * @param id defines the id of this gamepad
  39636. * @param index defines its index
  39637. * @param gamepad defines the internal HTML gamepad object
  39638. * @param xboxOne defines if it is a XBox One gamepad
  39639. */
  39640. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39641. /**
  39642. * Defines the callback to call when left trigger is pressed
  39643. * @param callback defines the callback to use
  39644. */
  39645. onlefttriggerchanged(callback: (value: number) => void): void;
  39646. /**
  39647. * Defines the callback to call when right trigger is pressed
  39648. * @param callback defines the callback to use
  39649. */
  39650. onrighttriggerchanged(callback: (value: number) => void): void;
  39651. /**
  39652. * Gets the left trigger value
  39653. */
  39654. /**
  39655. * Sets the left trigger value
  39656. */
  39657. leftTrigger: number;
  39658. /**
  39659. * Gets the right trigger value
  39660. */
  39661. /**
  39662. * Sets the right trigger value
  39663. */
  39664. rightTrigger: number;
  39665. /**
  39666. * Defines the callback to call when a button is pressed
  39667. * @param callback defines the callback to use
  39668. */
  39669. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39670. /**
  39671. * Defines the callback to call when a button is released
  39672. * @param callback defines the callback to use
  39673. */
  39674. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39675. /**
  39676. * Defines the callback to call when a pad is pressed
  39677. * @param callback defines the callback to use
  39678. */
  39679. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39680. /**
  39681. * Defines the callback to call when a pad is released
  39682. * @param callback defines the callback to use
  39683. */
  39684. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39685. private _setButtonValue;
  39686. private _setDPadValue;
  39687. /**
  39688. * Gets the value of the `A` button
  39689. */
  39690. /**
  39691. * Sets the value of the `A` button
  39692. */
  39693. buttonA: number;
  39694. /**
  39695. * Gets the value of the `B` button
  39696. */
  39697. /**
  39698. * Sets the value of the `B` button
  39699. */
  39700. buttonB: number;
  39701. /**
  39702. * Gets the value of the `X` button
  39703. */
  39704. /**
  39705. * Sets the value of the `X` button
  39706. */
  39707. buttonX: number;
  39708. /**
  39709. * Gets the value of the `Y` button
  39710. */
  39711. /**
  39712. * Sets the value of the `Y` button
  39713. */
  39714. buttonY: number;
  39715. /**
  39716. * Gets the value of the `Start` button
  39717. */
  39718. /**
  39719. * Sets the value of the `Start` button
  39720. */
  39721. buttonStart: number;
  39722. /**
  39723. * Gets the value of the `Back` button
  39724. */
  39725. /**
  39726. * Sets the value of the `Back` button
  39727. */
  39728. buttonBack: number;
  39729. /**
  39730. * Gets the value of the `Left` button
  39731. */
  39732. /**
  39733. * Sets the value of the `Left` button
  39734. */
  39735. buttonLB: number;
  39736. /**
  39737. * Gets the value of the `Right` button
  39738. */
  39739. /**
  39740. * Sets the value of the `Right` button
  39741. */
  39742. buttonRB: number;
  39743. /**
  39744. * Gets the value of the Left joystick
  39745. */
  39746. /**
  39747. * Sets the value of the Left joystick
  39748. */
  39749. buttonLeftStick: number;
  39750. /**
  39751. * Gets the value of the Right joystick
  39752. */
  39753. /**
  39754. * Sets the value of the Right joystick
  39755. */
  39756. buttonRightStick: number;
  39757. /**
  39758. * Gets the value of D-pad up
  39759. */
  39760. /**
  39761. * Sets the value of D-pad up
  39762. */
  39763. dPadUp: number;
  39764. /**
  39765. * Gets the value of D-pad down
  39766. */
  39767. /**
  39768. * Sets the value of D-pad down
  39769. */
  39770. dPadDown: number;
  39771. /**
  39772. * Gets the value of D-pad left
  39773. */
  39774. /**
  39775. * Sets the value of D-pad left
  39776. */
  39777. dPadLeft: number;
  39778. /**
  39779. * Gets the value of D-pad right
  39780. */
  39781. /**
  39782. * Sets the value of D-pad right
  39783. */
  39784. dPadRight: number;
  39785. /**
  39786. * Force the gamepad to synchronize with device values
  39787. */
  39788. update(): void;
  39789. /**
  39790. * Disposes the gamepad
  39791. */
  39792. dispose(): void;
  39793. }
  39794. }
  39795. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39796. import { Observable } from "babylonjs/Misc/observable";
  39797. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39798. /**
  39799. * Defines supported buttons for DualShock compatible gamepads
  39800. */
  39801. export enum DualShockButton {
  39802. /** Cross */
  39803. Cross = 0,
  39804. /** Circle */
  39805. Circle = 1,
  39806. /** Square */
  39807. Square = 2,
  39808. /** Triangle */
  39809. Triangle = 3,
  39810. /** Options */
  39811. Options = 4,
  39812. /** Share */
  39813. Share = 5,
  39814. /** L1 */
  39815. L1 = 6,
  39816. /** R1 */
  39817. R1 = 7,
  39818. /** Left stick */
  39819. LeftStick = 8,
  39820. /** Right stick */
  39821. RightStick = 9
  39822. }
  39823. /** Defines values for DualShock DPad */
  39824. export enum DualShockDpad {
  39825. /** Up */
  39826. Up = 0,
  39827. /** Down */
  39828. Down = 1,
  39829. /** Left */
  39830. Left = 2,
  39831. /** Right */
  39832. Right = 3
  39833. }
  39834. /**
  39835. * Defines a DualShock gamepad
  39836. */
  39837. export class DualShockPad extends Gamepad {
  39838. private _leftTrigger;
  39839. private _rightTrigger;
  39840. private _onlefttriggerchanged;
  39841. private _onrighttriggerchanged;
  39842. private _onbuttondown;
  39843. private _onbuttonup;
  39844. private _ondpaddown;
  39845. private _ondpadup;
  39846. /** Observable raised when a button is pressed */
  39847. onButtonDownObservable: Observable<DualShockButton>;
  39848. /** Observable raised when a button is released */
  39849. onButtonUpObservable: Observable<DualShockButton>;
  39850. /** Observable raised when a pad is pressed */
  39851. onPadDownObservable: Observable<DualShockDpad>;
  39852. /** Observable raised when a pad is released */
  39853. onPadUpObservable: Observable<DualShockDpad>;
  39854. private _buttonCross;
  39855. private _buttonCircle;
  39856. private _buttonSquare;
  39857. private _buttonTriangle;
  39858. private _buttonShare;
  39859. private _buttonOptions;
  39860. private _buttonL1;
  39861. private _buttonR1;
  39862. private _buttonLeftStick;
  39863. private _buttonRightStick;
  39864. private _dPadUp;
  39865. private _dPadDown;
  39866. private _dPadLeft;
  39867. private _dPadRight;
  39868. /**
  39869. * Creates a new DualShock gamepad object
  39870. * @param id defines the id of this gamepad
  39871. * @param index defines its index
  39872. * @param gamepad defines the internal HTML gamepad object
  39873. */
  39874. constructor(id: string, index: number, gamepad: any);
  39875. /**
  39876. * Defines the callback to call when left trigger is pressed
  39877. * @param callback defines the callback to use
  39878. */
  39879. onlefttriggerchanged(callback: (value: number) => void): void;
  39880. /**
  39881. * Defines the callback to call when right trigger is pressed
  39882. * @param callback defines the callback to use
  39883. */
  39884. onrighttriggerchanged(callback: (value: number) => void): void;
  39885. /**
  39886. * Gets the left trigger value
  39887. */
  39888. /**
  39889. * Sets the left trigger value
  39890. */
  39891. leftTrigger: number;
  39892. /**
  39893. * Gets the right trigger value
  39894. */
  39895. /**
  39896. * Sets the right trigger value
  39897. */
  39898. rightTrigger: number;
  39899. /**
  39900. * Defines the callback to call when a button is pressed
  39901. * @param callback defines the callback to use
  39902. */
  39903. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39904. /**
  39905. * Defines the callback to call when a button is released
  39906. * @param callback defines the callback to use
  39907. */
  39908. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39909. /**
  39910. * Defines the callback to call when a pad is pressed
  39911. * @param callback defines the callback to use
  39912. */
  39913. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39914. /**
  39915. * Defines the callback to call when a pad is released
  39916. * @param callback defines the callback to use
  39917. */
  39918. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39919. private _setButtonValue;
  39920. private _setDPadValue;
  39921. /**
  39922. * Gets the value of the `Cross` button
  39923. */
  39924. /**
  39925. * Sets the value of the `Cross` button
  39926. */
  39927. buttonCross: number;
  39928. /**
  39929. * Gets the value of the `Circle` button
  39930. */
  39931. /**
  39932. * Sets the value of the `Circle` button
  39933. */
  39934. buttonCircle: number;
  39935. /**
  39936. * Gets the value of the `Square` button
  39937. */
  39938. /**
  39939. * Sets the value of the `Square` button
  39940. */
  39941. buttonSquare: number;
  39942. /**
  39943. * Gets the value of the `Triangle` button
  39944. */
  39945. /**
  39946. * Sets the value of the `Triangle` button
  39947. */
  39948. buttonTriangle: number;
  39949. /**
  39950. * Gets the value of the `Options` button
  39951. */
  39952. /**
  39953. * Sets the value of the `Options` button
  39954. */
  39955. buttonOptions: number;
  39956. /**
  39957. * Gets the value of the `Share` button
  39958. */
  39959. /**
  39960. * Sets the value of the `Share` button
  39961. */
  39962. buttonShare: number;
  39963. /**
  39964. * Gets the value of the `L1` button
  39965. */
  39966. /**
  39967. * Sets the value of the `L1` button
  39968. */
  39969. buttonL1: number;
  39970. /**
  39971. * Gets the value of the `R1` button
  39972. */
  39973. /**
  39974. * Sets the value of the `R1` button
  39975. */
  39976. buttonR1: number;
  39977. /**
  39978. * Gets the value of the Left joystick
  39979. */
  39980. /**
  39981. * Sets the value of the Left joystick
  39982. */
  39983. buttonLeftStick: number;
  39984. /**
  39985. * Gets the value of the Right joystick
  39986. */
  39987. /**
  39988. * Sets the value of the Right joystick
  39989. */
  39990. buttonRightStick: number;
  39991. /**
  39992. * Gets the value of D-pad up
  39993. */
  39994. /**
  39995. * Sets the value of D-pad up
  39996. */
  39997. dPadUp: number;
  39998. /**
  39999. * Gets the value of D-pad down
  40000. */
  40001. /**
  40002. * Sets the value of D-pad down
  40003. */
  40004. dPadDown: number;
  40005. /**
  40006. * Gets the value of D-pad left
  40007. */
  40008. /**
  40009. * Sets the value of D-pad left
  40010. */
  40011. dPadLeft: number;
  40012. /**
  40013. * Gets the value of D-pad right
  40014. */
  40015. /**
  40016. * Sets the value of D-pad right
  40017. */
  40018. dPadRight: number;
  40019. /**
  40020. * Force the gamepad to synchronize with device values
  40021. */
  40022. update(): void;
  40023. /**
  40024. * Disposes the gamepad
  40025. */
  40026. dispose(): void;
  40027. }
  40028. }
  40029. declare module "babylonjs/Gamepads/gamepadManager" {
  40030. import { Observable } from "babylonjs/Misc/observable";
  40031. import { Nullable } from "babylonjs/types";
  40032. import { Scene } from "babylonjs/scene";
  40033. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40034. /**
  40035. * Manager for handling gamepads
  40036. */
  40037. export class GamepadManager {
  40038. private _scene?;
  40039. private _babylonGamepads;
  40040. private _oneGamepadConnected;
  40041. /** @hidden */
  40042. _isMonitoring: boolean;
  40043. private _gamepadEventSupported;
  40044. private _gamepadSupport;
  40045. /**
  40046. * observable to be triggered when the gamepad controller has been connected
  40047. */
  40048. onGamepadConnectedObservable: Observable<Gamepad>;
  40049. /**
  40050. * observable to be triggered when the gamepad controller has been disconnected
  40051. */
  40052. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40053. private _onGamepadConnectedEvent;
  40054. private _onGamepadDisconnectedEvent;
  40055. /**
  40056. * Initializes the gamepad manager
  40057. * @param _scene BabylonJS scene
  40058. */
  40059. constructor(_scene?: Scene | undefined);
  40060. /**
  40061. * The gamepads in the game pad manager
  40062. */
  40063. readonly gamepads: Gamepad[];
  40064. /**
  40065. * Get the gamepad controllers based on type
  40066. * @param type The type of gamepad controller
  40067. * @returns Nullable gamepad
  40068. */
  40069. getGamepadByType(type?: number): Nullable<Gamepad>;
  40070. /**
  40071. * Disposes the gamepad manager
  40072. */
  40073. dispose(): void;
  40074. private _addNewGamepad;
  40075. private _startMonitoringGamepads;
  40076. private _stopMonitoringGamepads;
  40077. /** @hidden */
  40078. _checkGamepadsStatus(): void;
  40079. private _updateGamepadObjects;
  40080. }
  40081. }
  40082. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40083. import { Nullable } from "babylonjs/types";
  40084. import { Scene } from "babylonjs/scene";
  40085. import { ISceneComponent } from "babylonjs/sceneComponent";
  40086. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40087. module "babylonjs/scene" {
  40088. interface Scene {
  40089. /** @hidden */
  40090. _gamepadManager: Nullable<GamepadManager>;
  40091. /**
  40092. * Gets the gamepad manager associated with the scene
  40093. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40094. */
  40095. gamepadManager: GamepadManager;
  40096. }
  40097. }
  40098. module "babylonjs/Cameras/freeCameraInputsManager" {
  40099. /**
  40100. * Interface representing a free camera inputs manager
  40101. */
  40102. interface FreeCameraInputsManager {
  40103. /**
  40104. * Adds gamepad input support to the FreeCameraInputsManager.
  40105. * @returns the FreeCameraInputsManager
  40106. */
  40107. addGamepad(): FreeCameraInputsManager;
  40108. }
  40109. }
  40110. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40111. /**
  40112. * Interface representing an arc rotate camera inputs manager
  40113. */
  40114. interface ArcRotateCameraInputsManager {
  40115. /**
  40116. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40117. * @returns the camera inputs manager
  40118. */
  40119. addGamepad(): ArcRotateCameraInputsManager;
  40120. }
  40121. }
  40122. /**
  40123. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40124. */
  40125. export class GamepadSystemSceneComponent implements ISceneComponent {
  40126. /**
  40127. * The component name helpfull to identify the component in the list of scene components.
  40128. */
  40129. readonly name: string;
  40130. /**
  40131. * The scene the component belongs to.
  40132. */
  40133. scene: Scene;
  40134. /**
  40135. * Creates a new instance of the component for the given scene
  40136. * @param scene Defines the scene to register the component in
  40137. */
  40138. constructor(scene: Scene);
  40139. /**
  40140. * Registers the component in a given scene
  40141. */
  40142. register(): void;
  40143. /**
  40144. * Rebuilds the elements related to this component in case of
  40145. * context lost for instance.
  40146. */
  40147. rebuild(): void;
  40148. /**
  40149. * Disposes the component and the associated ressources
  40150. */
  40151. dispose(): void;
  40152. private _beforeCameraUpdate;
  40153. }
  40154. }
  40155. declare module "babylonjs/Cameras/universalCamera" {
  40156. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40157. import { Scene } from "babylonjs/scene";
  40158. import { Vector3 } from "babylonjs/Maths/math.vector";
  40159. import "babylonjs/Gamepads/gamepadSceneComponent";
  40160. /**
  40161. * 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,
  40162. * which still works and will still be found in many Playgrounds.
  40163. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40164. */
  40165. export class UniversalCamera extends TouchCamera {
  40166. /**
  40167. * Defines the gamepad rotation sensiblity.
  40168. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40169. */
  40170. gamepadAngularSensibility: number;
  40171. /**
  40172. * Defines the gamepad move sensiblity.
  40173. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40174. */
  40175. gamepadMoveSensibility: number;
  40176. /**
  40177. * 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,
  40178. * which still works and will still be found in many Playgrounds.
  40179. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40180. * @param name Define the name of the camera in the scene
  40181. * @param position Define the start position of the camera in the scene
  40182. * @param scene Define the scene the camera belongs to
  40183. */
  40184. constructor(name: string, position: Vector3, scene: Scene);
  40185. /**
  40186. * Gets the current object class name.
  40187. * @return the class name
  40188. */
  40189. getClassName(): string;
  40190. }
  40191. }
  40192. declare module "babylonjs/Cameras/gamepadCamera" {
  40193. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40194. import { Scene } from "babylonjs/scene";
  40195. import { Vector3 } from "babylonjs/Maths/math.vector";
  40196. /**
  40197. * This represents a FPS type of camera. This is only here for back compat purpose.
  40198. * Please use the UniversalCamera instead as both are identical.
  40199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40200. */
  40201. export class GamepadCamera extends UniversalCamera {
  40202. /**
  40203. * Instantiates a new Gamepad Camera
  40204. * This represents a FPS type of camera. This is only here for back compat purpose.
  40205. * Please use the UniversalCamera instead as both are identical.
  40206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40207. * @param name Define the name of the camera in the scene
  40208. * @param position Define the start position of the camera in the scene
  40209. * @param scene Define the scene the camera belongs to
  40210. */
  40211. constructor(name: string, position: Vector3, scene: Scene);
  40212. /**
  40213. * Gets the current object class name.
  40214. * @return the class name
  40215. */
  40216. getClassName(): string;
  40217. }
  40218. }
  40219. declare module "babylonjs/Shaders/pass.fragment" {
  40220. /** @hidden */
  40221. export var passPixelShader: {
  40222. name: string;
  40223. shader: string;
  40224. };
  40225. }
  40226. declare module "babylonjs/Shaders/passCube.fragment" {
  40227. /** @hidden */
  40228. export var passCubePixelShader: {
  40229. name: string;
  40230. shader: string;
  40231. };
  40232. }
  40233. declare module "babylonjs/PostProcesses/passPostProcess" {
  40234. import { Nullable } from "babylonjs/types";
  40235. import { Camera } from "babylonjs/Cameras/camera";
  40236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40237. import { Engine } from "babylonjs/Engines/engine";
  40238. import "babylonjs/Shaders/pass.fragment";
  40239. import "babylonjs/Shaders/passCube.fragment";
  40240. /**
  40241. * PassPostProcess which produces an output the same as it's input
  40242. */
  40243. export class PassPostProcess extends PostProcess {
  40244. /**
  40245. * Creates the PassPostProcess
  40246. * @param name The name of the effect.
  40247. * @param options The required width/height ratio to downsize to before computing the render pass.
  40248. * @param camera The camera to apply the render pass to.
  40249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40250. * @param engine The engine which the post process will be applied. (default: current engine)
  40251. * @param reusable If the post process can be reused on the same frame. (default: false)
  40252. * @param textureType The type of texture to be used when performing the post processing.
  40253. * @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)
  40254. */
  40255. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40256. }
  40257. /**
  40258. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40259. */
  40260. export class PassCubePostProcess extends PostProcess {
  40261. private _face;
  40262. /**
  40263. * Gets or sets the cube face to display.
  40264. * * 0 is +X
  40265. * * 1 is -X
  40266. * * 2 is +Y
  40267. * * 3 is -Y
  40268. * * 4 is +Z
  40269. * * 5 is -Z
  40270. */
  40271. face: number;
  40272. /**
  40273. * Creates the PassCubePostProcess
  40274. * @param name The name of the effect.
  40275. * @param options The required width/height ratio to downsize to before computing the render pass.
  40276. * @param camera The camera to apply the render pass to.
  40277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40278. * @param engine The engine which the post process will be applied. (default: current engine)
  40279. * @param reusable If the post process can be reused on the same frame. (default: false)
  40280. * @param textureType The type of texture to be used when performing the post processing.
  40281. * @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)
  40282. */
  40283. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40284. }
  40285. }
  40286. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40287. /** @hidden */
  40288. export var anaglyphPixelShader: {
  40289. name: string;
  40290. shader: string;
  40291. };
  40292. }
  40293. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40294. import { Engine } from "babylonjs/Engines/engine";
  40295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40296. import { Camera } from "babylonjs/Cameras/camera";
  40297. import "babylonjs/Shaders/anaglyph.fragment";
  40298. /**
  40299. * Postprocess used to generate anaglyphic rendering
  40300. */
  40301. export class AnaglyphPostProcess extends PostProcess {
  40302. private _passedProcess;
  40303. /**
  40304. * Creates a new AnaglyphPostProcess
  40305. * @param name defines postprocess name
  40306. * @param options defines creation options or target ratio scale
  40307. * @param rigCameras defines cameras using this postprocess
  40308. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40309. * @param engine defines hosting engine
  40310. * @param reusable defines if the postprocess will be reused multiple times per frame
  40311. */
  40312. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40313. }
  40314. }
  40315. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40316. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40317. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40318. import { Scene } from "babylonjs/scene";
  40319. import { Vector3 } from "babylonjs/Maths/math.vector";
  40320. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40321. /**
  40322. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40323. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40324. */
  40325. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40326. /**
  40327. * Creates a new AnaglyphArcRotateCamera
  40328. * @param name defines camera name
  40329. * @param alpha defines alpha angle (in radians)
  40330. * @param beta defines beta angle (in radians)
  40331. * @param radius defines radius
  40332. * @param target defines camera target
  40333. * @param interaxialDistance defines distance between each color axis
  40334. * @param scene defines the hosting scene
  40335. */
  40336. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40337. /**
  40338. * Gets camera class name
  40339. * @returns AnaglyphArcRotateCamera
  40340. */
  40341. getClassName(): string;
  40342. }
  40343. }
  40344. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40345. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40346. import { Scene } from "babylonjs/scene";
  40347. import { Vector3 } from "babylonjs/Maths/math.vector";
  40348. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40349. /**
  40350. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40351. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40352. */
  40353. export class AnaglyphFreeCamera extends FreeCamera {
  40354. /**
  40355. * Creates a new AnaglyphFreeCamera
  40356. * @param name defines camera name
  40357. * @param position defines initial position
  40358. * @param interaxialDistance defines distance between each color axis
  40359. * @param scene defines the hosting scene
  40360. */
  40361. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40362. /**
  40363. * Gets camera class name
  40364. * @returns AnaglyphFreeCamera
  40365. */
  40366. getClassName(): string;
  40367. }
  40368. }
  40369. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40370. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40371. import { Scene } from "babylonjs/scene";
  40372. import { Vector3 } from "babylonjs/Maths/math.vector";
  40373. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40374. /**
  40375. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40376. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40377. */
  40378. export class AnaglyphGamepadCamera extends GamepadCamera {
  40379. /**
  40380. * Creates a new AnaglyphGamepadCamera
  40381. * @param name defines camera name
  40382. * @param position defines initial position
  40383. * @param interaxialDistance defines distance between each color axis
  40384. * @param scene defines the hosting scene
  40385. */
  40386. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40387. /**
  40388. * Gets camera class name
  40389. * @returns AnaglyphGamepadCamera
  40390. */
  40391. getClassName(): string;
  40392. }
  40393. }
  40394. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40395. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40396. import { Scene } from "babylonjs/scene";
  40397. import { Vector3 } from "babylonjs/Maths/math.vector";
  40398. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40399. /**
  40400. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40401. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40402. */
  40403. export class AnaglyphUniversalCamera extends UniversalCamera {
  40404. /**
  40405. * Creates a new AnaglyphUniversalCamera
  40406. * @param name defines camera name
  40407. * @param position defines initial position
  40408. * @param interaxialDistance defines distance between each color axis
  40409. * @param scene defines the hosting scene
  40410. */
  40411. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40412. /**
  40413. * Gets camera class name
  40414. * @returns AnaglyphUniversalCamera
  40415. */
  40416. getClassName(): string;
  40417. }
  40418. }
  40419. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40420. /** @hidden */
  40421. export var stereoscopicInterlacePixelShader: {
  40422. name: string;
  40423. shader: string;
  40424. };
  40425. }
  40426. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40427. import { Camera } from "babylonjs/Cameras/camera";
  40428. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40429. import { Engine } from "babylonjs/Engines/engine";
  40430. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40431. /**
  40432. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40433. */
  40434. export class StereoscopicInterlacePostProcess extends PostProcess {
  40435. private _stepSize;
  40436. private _passedProcess;
  40437. /**
  40438. * Initializes a StereoscopicInterlacePostProcess
  40439. * @param name The name of the effect.
  40440. * @param rigCameras The rig cameras to be appled to the post process
  40441. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40443. * @param engine The engine which the post process will be applied. (default: current engine)
  40444. * @param reusable If the post process can be reused on the same frame. (default: false)
  40445. */
  40446. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40447. }
  40448. }
  40449. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40450. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40452. import { Scene } from "babylonjs/scene";
  40453. import { Vector3 } from "babylonjs/Maths/math.vector";
  40454. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40455. /**
  40456. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40457. * @see http://doc.babylonjs.com/features/cameras
  40458. */
  40459. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40460. /**
  40461. * Creates a new StereoscopicArcRotateCamera
  40462. * @param name defines camera name
  40463. * @param alpha defines alpha angle (in radians)
  40464. * @param beta defines beta angle (in radians)
  40465. * @param radius defines radius
  40466. * @param target defines camera target
  40467. * @param interaxialDistance defines distance between each color axis
  40468. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40469. * @param scene defines the hosting scene
  40470. */
  40471. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40472. /**
  40473. * Gets camera class name
  40474. * @returns StereoscopicArcRotateCamera
  40475. */
  40476. getClassName(): string;
  40477. }
  40478. }
  40479. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40480. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40481. import { Scene } from "babylonjs/scene";
  40482. import { Vector3 } from "babylonjs/Maths/math.vector";
  40483. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40484. /**
  40485. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40486. * @see http://doc.babylonjs.com/features/cameras
  40487. */
  40488. export class StereoscopicFreeCamera extends FreeCamera {
  40489. /**
  40490. * Creates a new StereoscopicFreeCamera
  40491. * @param name defines camera name
  40492. * @param position defines initial position
  40493. * @param interaxialDistance defines distance between each color axis
  40494. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40495. * @param scene defines the hosting scene
  40496. */
  40497. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40498. /**
  40499. * Gets camera class name
  40500. * @returns StereoscopicFreeCamera
  40501. */
  40502. getClassName(): string;
  40503. }
  40504. }
  40505. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40506. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40507. import { Scene } from "babylonjs/scene";
  40508. import { Vector3 } from "babylonjs/Maths/math.vector";
  40509. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40510. /**
  40511. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40512. * @see http://doc.babylonjs.com/features/cameras
  40513. */
  40514. export class StereoscopicGamepadCamera extends GamepadCamera {
  40515. /**
  40516. * Creates a new StereoscopicGamepadCamera
  40517. * @param name defines camera name
  40518. * @param position defines initial position
  40519. * @param interaxialDistance defines distance between each color axis
  40520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40521. * @param scene defines the hosting scene
  40522. */
  40523. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40524. /**
  40525. * Gets camera class name
  40526. * @returns StereoscopicGamepadCamera
  40527. */
  40528. getClassName(): string;
  40529. }
  40530. }
  40531. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40532. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40533. import { Scene } from "babylonjs/scene";
  40534. import { Vector3 } from "babylonjs/Maths/math.vector";
  40535. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40536. /**
  40537. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40538. * @see http://doc.babylonjs.com/features/cameras
  40539. */
  40540. export class StereoscopicUniversalCamera extends UniversalCamera {
  40541. /**
  40542. * Creates a new StereoscopicUniversalCamera
  40543. * @param name defines camera name
  40544. * @param position defines initial position
  40545. * @param interaxialDistance defines distance between each color axis
  40546. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40547. * @param scene defines the hosting scene
  40548. */
  40549. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40550. /**
  40551. * Gets camera class name
  40552. * @returns StereoscopicUniversalCamera
  40553. */
  40554. getClassName(): string;
  40555. }
  40556. }
  40557. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40558. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40559. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40560. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40561. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40562. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40563. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40564. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40565. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40566. }
  40567. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40568. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40569. import { Scene } from "babylonjs/scene";
  40570. import { Vector3 } from "babylonjs/Maths/math.vector";
  40571. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40572. /**
  40573. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40574. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40575. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40576. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40577. */
  40578. export class VirtualJoysticksCamera extends FreeCamera {
  40579. /**
  40580. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40581. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40582. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40583. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40584. * @param name Define the name of the camera in the scene
  40585. * @param position Define the start position of the camera in the scene
  40586. * @param scene Define the scene the camera belongs to
  40587. */
  40588. constructor(name: string, position: Vector3, scene: Scene);
  40589. /**
  40590. * Gets the current object class name.
  40591. * @return the class name
  40592. */
  40593. getClassName(): string;
  40594. }
  40595. }
  40596. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40597. import { Matrix } from "babylonjs/Maths/math.vector";
  40598. /**
  40599. * This represents all the required metrics to create a VR camera.
  40600. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40601. */
  40602. export class VRCameraMetrics {
  40603. /**
  40604. * Define the horizontal resolution off the screen.
  40605. */
  40606. hResolution: number;
  40607. /**
  40608. * Define the vertical resolution off the screen.
  40609. */
  40610. vResolution: number;
  40611. /**
  40612. * Define the horizontal screen size.
  40613. */
  40614. hScreenSize: number;
  40615. /**
  40616. * Define the vertical screen size.
  40617. */
  40618. vScreenSize: number;
  40619. /**
  40620. * Define the vertical screen center position.
  40621. */
  40622. vScreenCenter: number;
  40623. /**
  40624. * Define the distance of the eyes to the screen.
  40625. */
  40626. eyeToScreenDistance: number;
  40627. /**
  40628. * Define the distance between both lenses
  40629. */
  40630. lensSeparationDistance: number;
  40631. /**
  40632. * Define the distance between both viewer's eyes.
  40633. */
  40634. interpupillaryDistance: number;
  40635. /**
  40636. * Define the distortion factor of the VR postprocess.
  40637. * Please, touch with care.
  40638. */
  40639. distortionK: number[];
  40640. /**
  40641. * Define the chromatic aberration correction factors for the VR post process.
  40642. */
  40643. chromaAbCorrection: number[];
  40644. /**
  40645. * Define the scale factor of the post process.
  40646. * The smaller the better but the slower.
  40647. */
  40648. postProcessScaleFactor: number;
  40649. /**
  40650. * Define an offset for the lens center.
  40651. */
  40652. lensCenterOffset: number;
  40653. /**
  40654. * Define if the current vr camera should compensate the distortion of the lense or not.
  40655. */
  40656. compensateDistortion: boolean;
  40657. /**
  40658. * Defines if multiview should be enabled when rendering (Default: false)
  40659. */
  40660. multiviewEnabled: boolean;
  40661. /**
  40662. * Gets the rendering aspect ratio based on the provided resolutions.
  40663. */
  40664. readonly aspectRatio: number;
  40665. /**
  40666. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40667. */
  40668. readonly aspectRatioFov: number;
  40669. /**
  40670. * @hidden
  40671. */
  40672. readonly leftHMatrix: Matrix;
  40673. /**
  40674. * @hidden
  40675. */
  40676. readonly rightHMatrix: Matrix;
  40677. /**
  40678. * @hidden
  40679. */
  40680. readonly leftPreViewMatrix: Matrix;
  40681. /**
  40682. * @hidden
  40683. */
  40684. readonly rightPreViewMatrix: Matrix;
  40685. /**
  40686. * Get the default VRMetrics based on the most generic setup.
  40687. * @returns the default vr metrics
  40688. */
  40689. static GetDefault(): VRCameraMetrics;
  40690. }
  40691. }
  40692. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40693. /** @hidden */
  40694. export var vrDistortionCorrectionPixelShader: {
  40695. name: string;
  40696. shader: string;
  40697. };
  40698. }
  40699. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40700. import { Camera } from "babylonjs/Cameras/camera";
  40701. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40702. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40703. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40704. /**
  40705. * VRDistortionCorrectionPostProcess used for mobile VR
  40706. */
  40707. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40708. private _isRightEye;
  40709. private _distortionFactors;
  40710. private _postProcessScaleFactor;
  40711. private _lensCenterOffset;
  40712. private _scaleIn;
  40713. private _scaleFactor;
  40714. private _lensCenter;
  40715. /**
  40716. * Initializes the VRDistortionCorrectionPostProcess
  40717. * @param name The name of the effect.
  40718. * @param camera The camera to apply the render pass to.
  40719. * @param isRightEye If this is for the right eye distortion
  40720. * @param vrMetrics All the required metrics for the VR camera
  40721. */
  40722. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40723. }
  40724. }
  40725. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40726. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40728. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40729. import { Scene } from "babylonjs/scene";
  40730. import { Vector3 } from "babylonjs/Maths/math.vector";
  40731. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40732. import "babylonjs/Cameras/RigModes/vrRigMode";
  40733. /**
  40734. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40735. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40736. */
  40737. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40738. /**
  40739. * Creates a new VRDeviceOrientationArcRotateCamera
  40740. * @param name defines camera name
  40741. * @param alpha defines the camera rotation along the logitudinal axis
  40742. * @param beta defines the camera rotation along the latitudinal axis
  40743. * @param radius defines the camera distance from its target
  40744. * @param target defines the camera target
  40745. * @param scene defines the scene the camera belongs to
  40746. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40747. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40748. */
  40749. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40750. /**
  40751. * Gets camera class name
  40752. * @returns VRDeviceOrientationArcRotateCamera
  40753. */
  40754. getClassName(): string;
  40755. }
  40756. }
  40757. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40758. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40759. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40760. import { Scene } from "babylonjs/scene";
  40761. import { Vector3 } from "babylonjs/Maths/math.vector";
  40762. import "babylonjs/Cameras/RigModes/vrRigMode";
  40763. /**
  40764. * Camera used to simulate VR rendering (based on FreeCamera)
  40765. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40766. */
  40767. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40768. /**
  40769. * Creates a new VRDeviceOrientationFreeCamera
  40770. * @param name defines camera name
  40771. * @param position defines the start position of the camera
  40772. * @param scene defines the scene the camera belongs to
  40773. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40774. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40775. */
  40776. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40777. /**
  40778. * Gets camera class name
  40779. * @returns VRDeviceOrientationFreeCamera
  40780. */
  40781. getClassName(): string;
  40782. }
  40783. }
  40784. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40785. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40786. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40787. import { Scene } from "babylonjs/scene";
  40788. import { Vector3 } from "babylonjs/Maths/math.vector";
  40789. import "babylonjs/Gamepads/gamepadSceneComponent";
  40790. /**
  40791. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40792. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40793. */
  40794. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40795. /**
  40796. * Creates a new VRDeviceOrientationGamepadCamera
  40797. * @param name defines camera name
  40798. * @param position defines the start position of the camera
  40799. * @param scene defines the scene the camera belongs to
  40800. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40801. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40802. */
  40803. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40804. /**
  40805. * Gets camera class name
  40806. * @returns VRDeviceOrientationGamepadCamera
  40807. */
  40808. getClassName(): string;
  40809. }
  40810. }
  40811. declare module "babylonjs/Materials/pushMaterial" {
  40812. import { Nullable } from "babylonjs/types";
  40813. import { Scene } from "babylonjs/scene";
  40814. import { Matrix } from "babylonjs/Maths/math.vector";
  40815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40816. import { Mesh } from "babylonjs/Meshes/mesh";
  40817. import { Material } from "babylonjs/Materials/material";
  40818. import { Effect } from "babylonjs/Materials/effect";
  40819. /**
  40820. * Base class of materials working in push mode in babylon JS
  40821. * @hidden
  40822. */
  40823. export class PushMaterial extends Material {
  40824. protected _activeEffect: Effect;
  40825. protected _normalMatrix: Matrix;
  40826. /**
  40827. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40828. * This means that the material can keep using a previous shader while a new one is being compiled.
  40829. * This is mostly used when shader parallel compilation is supported (true by default)
  40830. */
  40831. allowShaderHotSwapping: boolean;
  40832. constructor(name: string, scene: Scene);
  40833. getEffect(): Effect;
  40834. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40835. /**
  40836. * Binds the given world matrix to the active effect
  40837. *
  40838. * @param world the matrix to bind
  40839. */
  40840. bindOnlyWorldMatrix(world: Matrix): void;
  40841. /**
  40842. * Binds the given normal matrix to the active effect
  40843. *
  40844. * @param normalMatrix the matrix to bind
  40845. */
  40846. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40847. bind(world: Matrix, mesh?: Mesh): void;
  40848. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40849. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40850. }
  40851. }
  40852. declare module "babylonjs/Materials/materialFlags" {
  40853. /**
  40854. * This groups all the flags used to control the materials channel.
  40855. */
  40856. export class MaterialFlags {
  40857. private static _DiffuseTextureEnabled;
  40858. /**
  40859. * Are diffuse textures enabled in the application.
  40860. */
  40861. static DiffuseTextureEnabled: boolean;
  40862. private static _AmbientTextureEnabled;
  40863. /**
  40864. * Are ambient textures enabled in the application.
  40865. */
  40866. static AmbientTextureEnabled: boolean;
  40867. private static _OpacityTextureEnabled;
  40868. /**
  40869. * Are opacity textures enabled in the application.
  40870. */
  40871. static OpacityTextureEnabled: boolean;
  40872. private static _ReflectionTextureEnabled;
  40873. /**
  40874. * Are reflection textures enabled in the application.
  40875. */
  40876. static ReflectionTextureEnabled: boolean;
  40877. private static _EmissiveTextureEnabled;
  40878. /**
  40879. * Are emissive textures enabled in the application.
  40880. */
  40881. static EmissiveTextureEnabled: boolean;
  40882. private static _SpecularTextureEnabled;
  40883. /**
  40884. * Are specular textures enabled in the application.
  40885. */
  40886. static SpecularTextureEnabled: boolean;
  40887. private static _BumpTextureEnabled;
  40888. /**
  40889. * Are bump textures enabled in the application.
  40890. */
  40891. static BumpTextureEnabled: boolean;
  40892. private static _LightmapTextureEnabled;
  40893. /**
  40894. * Are lightmap textures enabled in the application.
  40895. */
  40896. static LightmapTextureEnabled: boolean;
  40897. private static _RefractionTextureEnabled;
  40898. /**
  40899. * Are refraction textures enabled in the application.
  40900. */
  40901. static RefractionTextureEnabled: boolean;
  40902. private static _ColorGradingTextureEnabled;
  40903. /**
  40904. * Are color grading textures enabled in the application.
  40905. */
  40906. static ColorGradingTextureEnabled: boolean;
  40907. private static _FresnelEnabled;
  40908. /**
  40909. * Are fresnels enabled in the application.
  40910. */
  40911. static FresnelEnabled: boolean;
  40912. private static _ClearCoatTextureEnabled;
  40913. /**
  40914. * Are clear coat textures enabled in the application.
  40915. */
  40916. static ClearCoatTextureEnabled: boolean;
  40917. private static _ClearCoatBumpTextureEnabled;
  40918. /**
  40919. * Are clear coat bump textures enabled in the application.
  40920. */
  40921. static ClearCoatBumpTextureEnabled: boolean;
  40922. private static _ClearCoatTintTextureEnabled;
  40923. /**
  40924. * Are clear coat tint textures enabled in the application.
  40925. */
  40926. static ClearCoatTintTextureEnabled: boolean;
  40927. private static _SheenTextureEnabled;
  40928. /**
  40929. * Are sheen textures enabled in the application.
  40930. */
  40931. static SheenTextureEnabled: boolean;
  40932. private static _AnisotropicTextureEnabled;
  40933. /**
  40934. * Are anisotropic textures enabled in the application.
  40935. */
  40936. static AnisotropicTextureEnabled: boolean;
  40937. private static _ThicknessTextureEnabled;
  40938. /**
  40939. * Are thickness textures enabled in the application.
  40940. */
  40941. static ThicknessTextureEnabled: boolean;
  40942. }
  40943. }
  40944. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40945. /** @hidden */
  40946. export var defaultFragmentDeclaration: {
  40947. name: string;
  40948. shader: string;
  40949. };
  40950. }
  40951. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40952. /** @hidden */
  40953. export var defaultUboDeclaration: {
  40954. name: string;
  40955. shader: string;
  40956. };
  40957. }
  40958. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40959. /** @hidden */
  40960. export var lightFragmentDeclaration: {
  40961. name: string;
  40962. shader: string;
  40963. };
  40964. }
  40965. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40966. /** @hidden */
  40967. export var lightUboDeclaration: {
  40968. name: string;
  40969. shader: string;
  40970. };
  40971. }
  40972. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40973. /** @hidden */
  40974. export var lightsFragmentFunctions: {
  40975. name: string;
  40976. shader: string;
  40977. };
  40978. }
  40979. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40980. /** @hidden */
  40981. export var shadowsFragmentFunctions: {
  40982. name: string;
  40983. shader: string;
  40984. };
  40985. }
  40986. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40987. /** @hidden */
  40988. export var fresnelFunction: {
  40989. name: string;
  40990. shader: string;
  40991. };
  40992. }
  40993. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40994. /** @hidden */
  40995. export var reflectionFunction: {
  40996. name: string;
  40997. shader: string;
  40998. };
  40999. }
  41000. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41001. /** @hidden */
  41002. export var bumpFragmentFunctions: {
  41003. name: string;
  41004. shader: string;
  41005. };
  41006. }
  41007. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41008. /** @hidden */
  41009. export var logDepthDeclaration: {
  41010. name: string;
  41011. shader: string;
  41012. };
  41013. }
  41014. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41015. /** @hidden */
  41016. export var bumpFragment: {
  41017. name: string;
  41018. shader: string;
  41019. };
  41020. }
  41021. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41022. /** @hidden */
  41023. export var depthPrePass: {
  41024. name: string;
  41025. shader: string;
  41026. };
  41027. }
  41028. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41029. /** @hidden */
  41030. export var lightFragment: {
  41031. name: string;
  41032. shader: string;
  41033. };
  41034. }
  41035. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41036. /** @hidden */
  41037. export var logDepthFragment: {
  41038. name: string;
  41039. shader: string;
  41040. };
  41041. }
  41042. declare module "babylonjs/Shaders/default.fragment" {
  41043. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41044. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41045. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41046. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41047. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41048. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41049. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41050. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41051. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41052. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41053. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41054. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41055. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41056. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41057. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41059. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41060. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41061. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41062. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41063. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41064. /** @hidden */
  41065. export var defaultPixelShader: {
  41066. name: string;
  41067. shader: string;
  41068. };
  41069. }
  41070. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41071. /** @hidden */
  41072. export var defaultVertexDeclaration: {
  41073. name: string;
  41074. shader: string;
  41075. };
  41076. }
  41077. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41078. /** @hidden */
  41079. export var bumpVertexDeclaration: {
  41080. name: string;
  41081. shader: string;
  41082. };
  41083. }
  41084. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41085. /** @hidden */
  41086. export var bumpVertex: {
  41087. name: string;
  41088. shader: string;
  41089. };
  41090. }
  41091. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41092. /** @hidden */
  41093. export var fogVertex: {
  41094. name: string;
  41095. shader: string;
  41096. };
  41097. }
  41098. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41099. /** @hidden */
  41100. export var shadowsVertex: {
  41101. name: string;
  41102. shader: string;
  41103. };
  41104. }
  41105. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41106. /** @hidden */
  41107. export var pointCloudVertex: {
  41108. name: string;
  41109. shader: string;
  41110. };
  41111. }
  41112. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41113. /** @hidden */
  41114. export var logDepthVertex: {
  41115. name: string;
  41116. shader: string;
  41117. };
  41118. }
  41119. declare module "babylonjs/Shaders/default.vertex" {
  41120. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41121. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41123. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41124. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41125. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41126. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41127. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41128. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41129. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41131. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41132. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41133. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41134. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41135. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41136. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41137. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41138. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41139. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41140. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41141. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41142. /** @hidden */
  41143. export var defaultVertexShader: {
  41144. name: string;
  41145. shader: string;
  41146. };
  41147. }
  41148. declare module "babylonjs/Materials/standardMaterial" {
  41149. import { SmartArray } from "babylonjs/Misc/smartArray";
  41150. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41151. import { Nullable } from "babylonjs/types";
  41152. import { Scene } from "babylonjs/scene";
  41153. import { Matrix } from "babylonjs/Maths/math.vector";
  41154. import { Color3 } from "babylonjs/Maths/math.color";
  41155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41157. import { Mesh } from "babylonjs/Meshes/mesh";
  41158. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41159. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41160. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41161. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41162. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41165. import "babylonjs/Shaders/default.fragment";
  41166. import "babylonjs/Shaders/default.vertex";
  41167. /** @hidden */
  41168. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41169. MAINUV1: boolean;
  41170. MAINUV2: boolean;
  41171. DIFFUSE: boolean;
  41172. DIFFUSEDIRECTUV: number;
  41173. AMBIENT: boolean;
  41174. AMBIENTDIRECTUV: number;
  41175. OPACITY: boolean;
  41176. OPACITYDIRECTUV: number;
  41177. OPACITYRGB: boolean;
  41178. REFLECTION: boolean;
  41179. EMISSIVE: boolean;
  41180. EMISSIVEDIRECTUV: number;
  41181. SPECULAR: boolean;
  41182. SPECULARDIRECTUV: number;
  41183. BUMP: boolean;
  41184. BUMPDIRECTUV: number;
  41185. PARALLAX: boolean;
  41186. PARALLAXOCCLUSION: boolean;
  41187. SPECULAROVERALPHA: boolean;
  41188. CLIPPLANE: boolean;
  41189. CLIPPLANE2: boolean;
  41190. CLIPPLANE3: boolean;
  41191. CLIPPLANE4: boolean;
  41192. ALPHATEST: boolean;
  41193. DEPTHPREPASS: boolean;
  41194. ALPHAFROMDIFFUSE: boolean;
  41195. POINTSIZE: boolean;
  41196. FOG: boolean;
  41197. SPECULARTERM: boolean;
  41198. DIFFUSEFRESNEL: boolean;
  41199. OPACITYFRESNEL: boolean;
  41200. REFLECTIONFRESNEL: boolean;
  41201. REFRACTIONFRESNEL: boolean;
  41202. EMISSIVEFRESNEL: boolean;
  41203. FRESNEL: boolean;
  41204. NORMAL: boolean;
  41205. UV1: boolean;
  41206. UV2: boolean;
  41207. VERTEXCOLOR: boolean;
  41208. VERTEXALPHA: boolean;
  41209. NUM_BONE_INFLUENCERS: number;
  41210. BonesPerMesh: number;
  41211. BONETEXTURE: boolean;
  41212. INSTANCES: boolean;
  41213. GLOSSINESS: boolean;
  41214. ROUGHNESS: boolean;
  41215. EMISSIVEASILLUMINATION: boolean;
  41216. LINKEMISSIVEWITHDIFFUSE: boolean;
  41217. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41218. LIGHTMAP: boolean;
  41219. LIGHTMAPDIRECTUV: number;
  41220. OBJECTSPACE_NORMALMAP: boolean;
  41221. USELIGHTMAPASSHADOWMAP: boolean;
  41222. REFLECTIONMAP_3D: boolean;
  41223. REFLECTIONMAP_SPHERICAL: boolean;
  41224. REFLECTIONMAP_PLANAR: boolean;
  41225. REFLECTIONMAP_CUBIC: boolean;
  41226. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41227. REFLECTIONMAP_PROJECTION: boolean;
  41228. REFLECTIONMAP_SKYBOX: boolean;
  41229. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41230. REFLECTIONMAP_EXPLICIT: boolean;
  41231. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41232. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41233. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41234. INVERTCUBICMAP: boolean;
  41235. LOGARITHMICDEPTH: boolean;
  41236. REFRACTION: boolean;
  41237. REFRACTIONMAP_3D: boolean;
  41238. REFLECTIONOVERALPHA: boolean;
  41239. TWOSIDEDLIGHTING: boolean;
  41240. SHADOWFLOAT: boolean;
  41241. MORPHTARGETS: boolean;
  41242. MORPHTARGETS_NORMAL: boolean;
  41243. MORPHTARGETS_TANGENT: boolean;
  41244. MORPHTARGETS_UV: boolean;
  41245. NUM_MORPH_INFLUENCERS: number;
  41246. NONUNIFORMSCALING: boolean;
  41247. PREMULTIPLYALPHA: boolean;
  41248. IMAGEPROCESSING: boolean;
  41249. VIGNETTE: boolean;
  41250. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41251. VIGNETTEBLENDMODEOPAQUE: boolean;
  41252. TONEMAPPING: boolean;
  41253. TONEMAPPING_ACES: boolean;
  41254. CONTRAST: boolean;
  41255. COLORCURVES: boolean;
  41256. COLORGRADING: boolean;
  41257. COLORGRADING3D: boolean;
  41258. SAMPLER3DGREENDEPTH: boolean;
  41259. SAMPLER3DBGRMAP: boolean;
  41260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41261. MULTIVIEW: boolean;
  41262. /**
  41263. * If the reflection texture on this material is in linear color space
  41264. * @hidden
  41265. */
  41266. IS_REFLECTION_LINEAR: boolean;
  41267. /**
  41268. * If the refraction texture on this material is in linear color space
  41269. * @hidden
  41270. */
  41271. IS_REFRACTION_LINEAR: boolean;
  41272. EXPOSURE: boolean;
  41273. constructor();
  41274. setReflectionMode(modeToEnable: string): void;
  41275. }
  41276. /**
  41277. * This is the default material used in Babylon. It is the best trade off between quality
  41278. * and performances.
  41279. * @see http://doc.babylonjs.com/babylon101/materials
  41280. */
  41281. export class StandardMaterial extends PushMaterial {
  41282. private _diffuseTexture;
  41283. /**
  41284. * The basic texture of the material as viewed under a light.
  41285. */
  41286. diffuseTexture: Nullable<BaseTexture>;
  41287. private _ambientTexture;
  41288. /**
  41289. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41290. */
  41291. ambientTexture: Nullable<BaseTexture>;
  41292. private _opacityTexture;
  41293. /**
  41294. * Define the transparency of the material from a texture.
  41295. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41296. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41297. */
  41298. opacityTexture: Nullable<BaseTexture>;
  41299. private _reflectionTexture;
  41300. /**
  41301. * Define the texture used to display the reflection.
  41302. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41303. */
  41304. reflectionTexture: Nullable<BaseTexture>;
  41305. private _emissiveTexture;
  41306. /**
  41307. * Define texture of the material as if self lit.
  41308. * This will be mixed in the final result even in the absence of light.
  41309. */
  41310. emissiveTexture: Nullable<BaseTexture>;
  41311. private _specularTexture;
  41312. /**
  41313. * Define how the color and intensity of the highlight given by the light in the material.
  41314. */
  41315. specularTexture: Nullable<BaseTexture>;
  41316. private _bumpTexture;
  41317. /**
  41318. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41319. * 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.
  41320. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41321. */
  41322. bumpTexture: Nullable<BaseTexture>;
  41323. private _lightmapTexture;
  41324. /**
  41325. * Complex lighting can be computationally expensive to compute at runtime.
  41326. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41327. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41328. */
  41329. lightmapTexture: Nullable<BaseTexture>;
  41330. private _refractionTexture;
  41331. /**
  41332. * Define the texture used to display the refraction.
  41333. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41334. */
  41335. refractionTexture: Nullable<BaseTexture>;
  41336. /**
  41337. * The color of the material lit by the environmental background lighting.
  41338. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41339. */
  41340. ambientColor: Color3;
  41341. /**
  41342. * The basic color of the material as viewed under a light.
  41343. */
  41344. diffuseColor: Color3;
  41345. /**
  41346. * Define how the color and intensity of the highlight given by the light in the material.
  41347. */
  41348. specularColor: Color3;
  41349. /**
  41350. * Define the color of the material as if self lit.
  41351. * This will be mixed in the final result even in the absence of light.
  41352. */
  41353. emissiveColor: Color3;
  41354. /**
  41355. * Defines how sharp are the highlights in the material.
  41356. * The bigger the value the sharper giving a more glossy feeling to the result.
  41357. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41358. */
  41359. specularPower: number;
  41360. private _useAlphaFromDiffuseTexture;
  41361. /**
  41362. * Does the transparency come from the diffuse texture alpha channel.
  41363. */
  41364. useAlphaFromDiffuseTexture: boolean;
  41365. private _useEmissiveAsIllumination;
  41366. /**
  41367. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41368. */
  41369. useEmissiveAsIllumination: boolean;
  41370. private _linkEmissiveWithDiffuse;
  41371. /**
  41372. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41373. * the emissive level when the final color is close to one.
  41374. */
  41375. linkEmissiveWithDiffuse: boolean;
  41376. private _useSpecularOverAlpha;
  41377. /**
  41378. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41379. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41380. */
  41381. useSpecularOverAlpha: boolean;
  41382. private _useReflectionOverAlpha;
  41383. /**
  41384. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41385. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41386. */
  41387. useReflectionOverAlpha: boolean;
  41388. private _disableLighting;
  41389. /**
  41390. * Does lights from the scene impacts this material.
  41391. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41392. */
  41393. disableLighting: boolean;
  41394. private _useObjectSpaceNormalMap;
  41395. /**
  41396. * Allows using an object space normal map (instead of tangent space).
  41397. */
  41398. useObjectSpaceNormalMap: boolean;
  41399. private _useParallax;
  41400. /**
  41401. * Is parallax enabled or not.
  41402. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41403. */
  41404. useParallax: boolean;
  41405. private _useParallaxOcclusion;
  41406. /**
  41407. * Is parallax occlusion enabled or not.
  41408. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41409. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41410. */
  41411. useParallaxOcclusion: boolean;
  41412. /**
  41413. * 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.
  41414. */
  41415. parallaxScaleBias: number;
  41416. private _roughness;
  41417. /**
  41418. * Helps to define how blurry the reflections should appears in the material.
  41419. */
  41420. roughness: number;
  41421. /**
  41422. * In case of refraction, define the value of the index of refraction.
  41423. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41424. */
  41425. indexOfRefraction: number;
  41426. /**
  41427. * Invert the refraction texture alongside the y axis.
  41428. * It can be useful with procedural textures or probe for instance.
  41429. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41430. */
  41431. invertRefractionY: boolean;
  41432. /**
  41433. * Defines the alpha limits in alpha test mode.
  41434. */
  41435. alphaCutOff: number;
  41436. private _useLightmapAsShadowmap;
  41437. /**
  41438. * In case of light mapping, define whether the map contains light or shadow informations.
  41439. */
  41440. useLightmapAsShadowmap: boolean;
  41441. private _diffuseFresnelParameters;
  41442. /**
  41443. * Define the diffuse fresnel parameters of the material.
  41444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41445. */
  41446. diffuseFresnelParameters: FresnelParameters;
  41447. private _opacityFresnelParameters;
  41448. /**
  41449. * Define the opacity fresnel parameters of the material.
  41450. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41451. */
  41452. opacityFresnelParameters: FresnelParameters;
  41453. private _reflectionFresnelParameters;
  41454. /**
  41455. * Define the reflection fresnel parameters of the material.
  41456. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41457. */
  41458. reflectionFresnelParameters: FresnelParameters;
  41459. private _refractionFresnelParameters;
  41460. /**
  41461. * Define the refraction fresnel parameters of the material.
  41462. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41463. */
  41464. refractionFresnelParameters: FresnelParameters;
  41465. private _emissiveFresnelParameters;
  41466. /**
  41467. * Define the emissive fresnel parameters of the material.
  41468. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41469. */
  41470. emissiveFresnelParameters: FresnelParameters;
  41471. private _useReflectionFresnelFromSpecular;
  41472. /**
  41473. * If true automatically deducts the fresnels values from the material specularity.
  41474. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41475. */
  41476. useReflectionFresnelFromSpecular: boolean;
  41477. private _useGlossinessFromSpecularMapAlpha;
  41478. /**
  41479. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41480. */
  41481. useGlossinessFromSpecularMapAlpha: boolean;
  41482. private _maxSimultaneousLights;
  41483. /**
  41484. * Defines the maximum number of lights that can be used in the material
  41485. */
  41486. maxSimultaneousLights: number;
  41487. private _invertNormalMapX;
  41488. /**
  41489. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41490. */
  41491. invertNormalMapX: boolean;
  41492. private _invertNormalMapY;
  41493. /**
  41494. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41495. */
  41496. invertNormalMapY: boolean;
  41497. private _twoSidedLighting;
  41498. /**
  41499. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41500. */
  41501. twoSidedLighting: boolean;
  41502. /**
  41503. * Default configuration related to image processing available in the standard Material.
  41504. */
  41505. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41506. /**
  41507. * Gets the image processing configuration used either in this material.
  41508. */
  41509. /**
  41510. * Sets the Default image processing configuration used either in the this material.
  41511. *
  41512. * If sets to null, the scene one is in use.
  41513. */
  41514. imageProcessingConfiguration: ImageProcessingConfiguration;
  41515. /**
  41516. * Keep track of the image processing observer to allow dispose and replace.
  41517. */
  41518. private _imageProcessingObserver;
  41519. /**
  41520. * Attaches a new image processing configuration to the Standard Material.
  41521. * @param configuration
  41522. */
  41523. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41524. /**
  41525. * Gets wether the color curves effect is enabled.
  41526. */
  41527. /**
  41528. * Sets wether the color curves effect is enabled.
  41529. */
  41530. cameraColorCurvesEnabled: boolean;
  41531. /**
  41532. * Gets wether the color grading effect is enabled.
  41533. */
  41534. /**
  41535. * Gets wether the color grading effect is enabled.
  41536. */
  41537. cameraColorGradingEnabled: boolean;
  41538. /**
  41539. * Gets wether tonemapping is enabled or not.
  41540. */
  41541. /**
  41542. * Sets wether tonemapping is enabled or not
  41543. */
  41544. cameraToneMappingEnabled: boolean;
  41545. /**
  41546. * The camera exposure used on this material.
  41547. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41548. * This corresponds to a photographic exposure.
  41549. */
  41550. /**
  41551. * The camera exposure used on this material.
  41552. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41553. * This corresponds to a photographic exposure.
  41554. */
  41555. cameraExposure: number;
  41556. /**
  41557. * Gets The camera contrast used on this material.
  41558. */
  41559. /**
  41560. * Sets The camera contrast used on this material.
  41561. */
  41562. cameraContrast: number;
  41563. /**
  41564. * Gets the Color Grading 2D Lookup Texture.
  41565. */
  41566. /**
  41567. * Sets the Color Grading 2D Lookup Texture.
  41568. */
  41569. cameraColorGradingTexture: Nullable<BaseTexture>;
  41570. /**
  41571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41573. * 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;
  41574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41575. */
  41576. /**
  41577. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41578. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41579. * 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;
  41580. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41581. */
  41582. cameraColorCurves: Nullable<ColorCurves>;
  41583. /**
  41584. * Custom callback helping to override the default shader used in the material.
  41585. */
  41586. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41587. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41588. protected _worldViewProjectionMatrix: Matrix;
  41589. protected _globalAmbientColor: Color3;
  41590. protected _useLogarithmicDepth: boolean;
  41591. /**
  41592. * Instantiates a new standard material.
  41593. * This is the default material used in Babylon. It is the best trade off between quality
  41594. * and performances.
  41595. * @see http://doc.babylonjs.com/babylon101/materials
  41596. * @param name Define the name of the material in the scene
  41597. * @param scene Define the scene the material belong to
  41598. */
  41599. constructor(name: string, scene: Scene);
  41600. /**
  41601. * Gets a boolean indicating that current material needs to register RTT
  41602. */
  41603. readonly hasRenderTargetTextures: boolean;
  41604. /**
  41605. * Gets the current class name of the material e.g. "StandardMaterial"
  41606. * Mainly use in serialization.
  41607. * @returns the class name
  41608. */
  41609. getClassName(): string;
  41610. /**
  41611. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41612. * You can try switching to logarithmic depth.
  41613. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41614. */
  41615. useLogarithmicDepth: boolean;
  41616. /**
  41617. * Specifies if the material will require alpha blending
  41618. * @returns a boolean specifying if alpha blending is needed
  41619. */
  41620. needAlphaBlending(): boolean;
  41621. /**
  41622. * Specifies if this material should be rendered in alpha test mode
  41623. * @returns a boolean specifying if an alpha test is needed.
  41624. */
  41625. needAlphaTesting(): boolean;
  41626. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41627. /**
  41628. * Get the texture used for alpha test purpose.
  41629. * @returns the diffuse texture in case of the standard material.
  41630. */
  41631. getAlphaTestTexture(): Nullable<BaseTexture>;
  41632. /**
  41633. * Get if the submesh is ready to be used and all its information available.
  41634. * Child classes can use it to update shaders
  41635. * @param mesh defines the mesh to check
  41636. * @param subMesh defines which submesh to check
  41637. * @param useInstances specifies that instances should be used
  41638. * @returns a boolean indicating that the submesh is ready or not
  41639. */
  41640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41641. /**
  41642. * Builds the material UBO layouts.
  41643. * Used internally during the effect preparation.
  41644. */
  41645. buildUniformLayout(): void;
  41646. /**
  41647. * Unbinds the material from the mesh
  41648. */
  41649. unbind(): void;
  41650. /**
  41651. * Binds the submesh to this material by preparing the effect and shader to draw
  41652. * @param world defines the world transformation matrix
  41653. * @param mesh defines the mesh containing the submesh
  41654. * @param subMesh defines the submesh to bind the material to
  41655. */
  41656. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41657. /**
  41658. * Get the list of animatables in the material.
  41659. * @returns the list of animatables object used in the material
  41660. */
  41661. getAnimatables(): IAnimatable[];
  41662. /**
  41663. * Gets the active textures from the material
  41664. * @returns an array of textures
  41665. */
  41666. getActiveTextures(): BaseTexture[];
  41667. /**
  41668. * Specifies if the material uses a texture
  41669. * @param texture defines the texture to check against the material
  41670. * @returns a boolean specifying if the material uses the texture
  41671. */
  41672. hasTexture(texture: BaseTexture): boolean;
  41673. /**
  41674. * Disposes the material
  41675. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41676. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41677. */
  41678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41679. /**
  41680. * Makes a duplicate of the material, and gives it a new name
  41681. * @param name defines the new name for the duplicated material
  41682. * @returns the cloned material
  41683. */
  41684. clone(name: string): StandardMaterial;
  41685. /**
  41686. * Serializes this material in a JSON representation
  41687. * @returns the serialized material object
  41688. */
  41689. serialize(): any;
  41690. /**
  41691. * Creates a standard material from parsed material data
  41692. * @param source defines the JSON representation of the material
  41693. * @param scene defines the hosting scene
  41694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41695. * @returns a new standard material
  41696. */
  41697. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41698. /**
  41699. * Are diffuse textures enabled in the application.
  41700. */
  41701. static DiffuseTextureEnabled: boolean;
  41702. /**
  41703. * Are ambient textures enabled in the application.
  41704. */
  41705. static AmbientTextureEnabled: boolean;
  41706. /**
  41707. * Are opacity textures enabled in the application.
  41708. */
  41709. static OpacityTextureEnabled: boolean;
  41710. /**
  41711. * Are reflection textures enabled in the application.
  41712. */
  41713. static ReflectionTextureEnabled: boolean;
  41714. /**
  41715. * Are emissive textures enabled in the application.
  41716. */
  41717. static EmissiveTextureEnabled: boolean;
  41718. /**
  41719. * Are specular textures enabled in the application.
  41720. */
  41721. static SpecularTextureEnabled: boolean;
  41722. /**
  41723. * Are bump textures enabled in the application.
  41724. */
  41725. static BumpTextureEnabled: boolean;
  41726. /**
  41727. * Are lightmap textures enabled in the application.
  41728. */
  41729. static LightmapTextureEnabled: boolean;
  41730. /**
  41731. * Are refraction textures enabled in the application.
  41732. */
  41733. static RefractionTextureEnabled: boolean;
  41734. /**
  41735. * Are color grading textures enabled in the application.
  41736. */
  41737. static ColorGradingTextureEnabled: boolean;
  41738. /**
  41739. * Are fresnels enabled in the application.
  41740. */
  41741. static FresnelEnabled: boolean;
  41742. }
  41743. }
  41744. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41745. import { Scene } from "babylonjs/scene";
  41746. import { Texture } from "babylonjs/Materials/Textures/texture";
  41747. /**
  41748. * A class extending Texture allowing drawing on a texture
  41749. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41750. */
  41751. export class DynamicTexture extends Texture {
  41752. private _generateMipMaps;
  41753. private _canvas;
  41754. private _context;
  41755. private _engine;
  41756. /**
  41757. * Creates a DynamicTexture
  41758. * @param name defines the name of the texture
  41759. * @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
  41760. * @param scene defines the scene where you want the texture
  41761. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41762. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41763. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41764. */
  41765. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41766. /**
  41767. * Get the current class name of the texture useful for serialization or dynamic coding.
  41768. * @returns "DynamicTexture"
  41769. */
  41770. getClassName(): string;
  41771. /**
  41772. * Gets the current state of canRescale
  41773. */
  41774. readonly canRescale: boolean;
  41775. private _recreate;
  41776. /**
  41777. * Scales the texture
  41778. * @param ratio the scale factor to apply to both width and height
  41779. */
  41780. scale(ratio: number): void;
  41781. /**
  41782. * Resizes the texture
  41783. * @param width the new width
  41784. * @param height the new height
  41785. */
  41786. scaleTo(width: number, height: number): void;
  41787. /**
  41788. * Gets the context of the canvas used by the texture
  41789. * @returns the canvas context of the dynamic texture
  41790. */
  41791. getContext(): CanvasRenderingContext2D;
  41792. /**
  41793. * Clears the texture
  41794. */
  41795. clear(): void;
  41796. /**
  41797. * Updates the texture
  41798. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41799. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41800. */
  41801. update(invertY?: boolean, premulAlpha?: boolean): void;
  41802. /**
  41803. * Draws text onto the texture
  41804. * @param text defines the text to be drawn
  41805. * @param x defines the placement of the text from the left
  41806. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41807. * @param font defines the font to be used with font-style, font-size, font-name
  41808. * @param color defines the color used for the text
  41809. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41810. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41811. * @param update defines whether texture is immediately update (default is true)
  41812. */
  41813. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41814. /**
  41815. * Clones the texture
  41816. * @returns the clone of the texture.
  41817. */
  41818. clone(): DynamicTexture;
  41819. /**
  41820. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41821. * @returns a serialized dynamic texture object
  41822. */
  41823. serialize(): any;
  41824. /** @hidden */
  41825. _rebuild(): void;
  41826. }
  41827. }
  41828. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41829. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41831. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41832. /** @hidden */
  41833. export var imageProcessingPixelShader: {
  41834. name: string;
  41835. shader: string;
  41836. };
  41837. }
  41838. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41839. import { Nullable } from "babylonjs/types";
  41840. import { Color4 } from "babylonjs/Maths/math.color";
  41841. import { Camera } from "babylonjs/Cameras/camera";
  41842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41843. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41844. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41845. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41846. import { Engine } from "babylonjs/Engines/engine";
  41847. import "babylonjs/Shaders/imageProcessing.fragment";
  41848. import "babylonjs/Shaders/postprocess.vertex";
  41849. /**
  41850. * ImageProcessingPostProcess
  41851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41852. */
  41853. export class ImageProcessingPostProcess extends PostProcess {
  41854. /**
  41855. * Default configuration related to image processing available in the PBR Material.
  41856. */
  41857. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41858. /**
  41859. * Gets the image processing configuration used either in this material.
  41860. */
  41861. /**
  41862. * Sets the Default image processing configuration used either in the this material.
  41863. *
  41864. * If sets to null, the scene one is in use.
  41865. */
  41866. imageProcessingConfiguration: ImageProcessingConfiguration;
  41867. /**
  41868. * Keep track of the image processing observer to allow dispose and replace.
  41869. */
  41870. private _imageProcessingObserver;
  41871. /**
  41872. * Attaches a new image processing configuration to the PBR Material.
  41873. * @param configuration
  41874. */
  41875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41876. /**
  41877. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41878. */
  41879. /**
  41880. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41881. */
  41882. colorCurves: Nullable<ColorCurves>;
  41883. /**
  41884. * Gets wether the color curves effect is enabled.
  41885. */
  41886. /**
  41887. * Sets wether the color curves effect is enabled.
  41888. */
  41889. colorCurvesEnabled: boolean;
  41890. /**
  41891. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41892. */
  41893. /**
  41894. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41895. */
  41896. colorGradingTexture: Nullable<BaseTexture>;
  41897. /**
  41898. * Gets wether the color grading effect is enabled.
  41899. */
  41900. /**
  41901. * Gets wether the color grading effect is enabled.
  41902. */
  41903. colorGradingEnabled: boolean;
  41904. /**
  41905. * Gets exposure used in the effect.
  41906. */
  41907. /**
  41908. * Sets exposure used in the effect.
  41909. */
  41910. exposure: number;
  41911. /**
  41912. * Gets wether tonemapping is enabled or not.
  41913. */
  41914. /**
  41915. * Sets wether tonemapping is enabled or not
  41916. */
  41917. toneMappingEnabled: boolean;
  41918. /**
  41919. * Gets the type of tone mapping effect.
  41920. */
  41921. /**
  41922. * Sets the type of tone mapping effect.
  41923. */
  41924. toneMappingType: number;
  41925. /**
  41926. * Gets contrast used in the effect.
  41927. */
  41928. /**
  41929. * Sets contrast used in the effect.
  41930. */
  41931. contrast: number;
  41932. /**
  41933. * Gets Vignette stretch size.
  41934. */
  41935. /**
  41936. * Sets Vignette stretch size.
  41937. */
  41938. vignetteStretch: number;
  41939. /**
  41940. * Gets Vignette centre X Offset.
  41941. */
  41942. /**
  41943. * Sets Vignette centre X Offset.
  41944. */
  41945. vignetteCentreX: number;
  41946. /**
  41947. * Gets Vignette centre Y Offset.
  41948. */
  41949. /**
  41950. * Sets Vignette centre Y Offset.
  41951. */
  41952. vignetteCentreY: number;
  41953. /**
  41954. * Gets Vignette weight or intensity of the vignette effect.
  41955. */
  41956. /**
  41957. * Sets Vignette weight or intensity of the vignette effect.
  41958. */
  41959. vignetteWeight: number;
  41960. /**
  41961. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41962. * if vignetteEnabled is set to true.
  41963. */
  41964. /**
  41965. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41966. * if vignetteEnabled is set to true.
  41967. */
  41968. vignetteColor: Color4;
  41969. /**
  41970. * Gets Camera field of view used by the Vignette effect.
  41971. */
  41972. /**
  41973. * Sets Camera field of view used by the Vignette effect.
  41974. */
  41975. vignetteCameraFov: number;
  41976. /**
  41977. * Gets the vignette blend mode allowing different kind of effect.
  41978. */
  41979. /**
  41980. * Sets the vignette blend mode allowing different kind of effect.
  41981. */
  41982. vignetteBlendMode: number;
  41983. /**
  41984. * Gets wether the vignette effect is enabled.
  41985. */
  41986. /**
  41987. * Sets wether the vignette effect is enabled.
  41988. */
  41989. vignetteEnabled: boolean;
  41990. private _fromLinearSpace;
  41991. /**
  41992. * Gets wether the input of the processing is in Gamma or Linear Space.
  41993. */
  41994. /**
  41995. * Sets wether the input of the processing is in Gamma or Linear Space.
  41996. */
  41997. fromLinearSpace: boolean;
  41998. /**
  41999. * Defines cache preventing GC.
  42000. */
  42001. private _defines;
  42002. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42003. /**
  42004. * "ImageProcessingPostProcess"
  42005. * @returns "ImageProcessingPostProcess"
  42006. */
  42007. getClassName(): string;
  42008. protected _updateParameters(): void;
  42009. dispose(camera?: Camera): void;
  42010. }
  42011. }
  42012. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42013. import { Scene } from "babylonjs/scene";
  42014. import { Color3 } from "babylonjs/Maths/math.color";
  42015. import { Mesh } from "babylonjs/Meshes/mesh";
  42016. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42017. import { Nullable } from "babylonjs/types";
  42018. /**
  42019. * Class containing static functions to help procedurally build meshes
  42020. */
  42021. export class GroundBuilder {
  42022. /**
  42023. * Creates a ground mesh
  42024. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42025. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42027. * @param name defines the name of the mesh
  42028. * @param options defines the options used to create the mesh
  42029. * @param scene defines the hosting scene
  42030. * @returns the ground mesh
  42031. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42032. */
  42033. static CreateGround(name: string, options: {
  42034. width?: number;
  42035. height?: number;
  42036. subdivisions?: number;
  42037. subdivisionsX?: number;
  42038. subdivisionsY?: number;
  42039. updatable?: boolean;
  42040. }, scene: any): Mesh;
  42041. /**
  42042. * Creates a tiled ground mesh
  42043. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42044. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42045. * * 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
  42046. * * 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
  42047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42048. * @param name defines the name of the mesh
  42049. * @param options defines the options used to create the mesh
  42050. * @param scene defines the hosting scene
  42051. * @returns the tiled ground mesh
  42052. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42053. */
  42054. static CreateTiledGround(name: string, options: {
  42055. xmin: number;
  42056. zmin: number;
  42057. xmax: number;
  42058. zmax: number;
  42059. subdivisions?: {
  42060. w: number;
  42061. h: number;
  42062. };
  42063. precision?: {
  42064. w: number;
  42065. h: number;
  42066. };
  42067. updatable?: boolean;
  42068. }, scene?: Nullable<Scene>): Mesh;
  42069. /**
  42070. * Creates a ground mesh from a height map
  42071. * * The parameter `url` sets the URL of the height map image resource.
  42072. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42073. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42074. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42075. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42076. * * 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.
  42077. * * 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).
  42078. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42080. * @param name defines the name of the mesh
  42081. * @param url defines the url to the height map
  42082. * @param options defines the options used to create the mesh
  42083. * @param scene defines the hosting scene
  42084. * @returns the ground mesh
  42085. * @see https://doc.babylonjs.com/babylon101/height_map
  42086. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42087. */
  42088. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42089. width?: number;
  42090. height?: number;
  42091. subdivisions?: number;
  42092. minHeight?: number;
  42093. maxHeight?: number;
  42094. colorFilter?: Color3;
  42095. alphaFilter?: number;
  42096. updatable?: boolean;
  42097. onReady?: (mesh: GroundMesh) => void;
  42098. }, scene?: Nullable<Scene>): GroundMesh;
  42099. }
  42100. }
  42101. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42102. import { Vector4 } from "babylonjs/Maths/math.vector";
  42103. import { Mesh } from "babylonjs/Meshes/mesh";
  42104. /**
  42105. * Class containing static functions to help procedurally build meshes
  42106. */
  42107. export class TorusBuilder {
  42108. /**
  42109. * Creates a torus mesh
  42110. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42111. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42112. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42116. * @param name defines the name of the mesh
  42117. * @param options defines the options used to create the mesh
  42118. * @param scene defines the hosting scene
  42119. * @returns the torus mesh
  42120. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42121. */
  42122. static CreateTorus(name: string, options: {
  42123. diameter?: number;
  42124. thickness?: number;
  42125. tessellation?: number;
  42126. updatable?: boolean;
  42127. sideOrientation?: number;
  42128. frontUVs?: Vector4;
  42129. backUVs?: Vector4;
  42130. }, scene: any): Mesh;
  42131. }
  42132. }
  42133. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42134. import { Vector4 } from "babylonjs/Maths/math.vector";
  42135. import { Color4 } from "babylonjs/Maths/math.color";
  42136. import { Mesh } from "babylonjs/Meshes/mesh";
  42137. /**
  42138. * Class containing static functions to help procedurally build meshes
  42139. */
  42140. export class CylinderBuilder {
  42141. /**
  42142. * Creates a cylinder or a cone mesh
  42143. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42144. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42145. * * 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.
  42146. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42147. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42148. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42149. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42150. * * 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).
  42151. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42152. * * 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).
  42153. * * 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
  42154. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42155. * * 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
  42156. * * 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.
  42157. * * If `enclose` is false, a ring surface is one element.
  42158. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42159. * * 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
  42160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42163. * @param name defines the name of the mesh
  42164. * @param options defines the options used to create the mesh
  42165. * @param scene defines the hosting scene
  42166. * @returns the cylinder mesh
  42167. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42168. */
  42169. static CreateCylinder(name: string, options: {
  42170. height?: number;
  42171. diameterTop?: number;
  42172. diameterBottom?: number;
  42173. diameter?: number;
  42174. tessellation?: number;
  42175. subdivisions?: number;
  42176. arc?: number;
  42177. faceColors?: Color4[];
  42178. faceUV?: Vector4[];
  42179. updatable?: boolean;
  42180. hasRings?: boolean;
  42181. enclose?: boolean;
  42182. cap?: number;
  42183. sideOrientation?: number;
  42184. frontUVs?: Vector4;
  42185. backUVs?: Vector4;
  42186. }, scene: any): Mesh;
  42187. }
  42188. }
  42189. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42190. import { Observable } from "babylonjs/Misc/observable";
  42191. import { Nullable } from "babylonjs/types";
  42192. import { Camera } from "babylonjs/Cameras/camera";
  42193. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42194. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42195. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42196. import { Scene } from "babylonjs/scene";
  42197. import { Vector3 } from "babylonjs/Maths/math.vector";
  42198. import { Color3 } from "babylonjs/Maths/math.color";
  42199. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42201. import { Mesh } from "babylonjs/Meshes/mesh";
  42202. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42203. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42204. import "babylonjs/Meshes/Builders/groundBuilder";
  42205. import "babylonjs/Meshes/Builders/torusBuilder";
  42206. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42207. import "babylonjs/Gamepads/gamepadSceneComponent";
  42208. import "babylonjs/Animations/animatable";
  42209. /**
  42210. * Options to modify the vr teleportation behavior.
  42211. */
  42212. export interface VRTeleportationOptions {
  42213. /**
  42214. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42215. */
  42216. floorMeshName?: string;
  42217. /**
  42218. * A list of meshes to be used as the teleportation floor. (default: empty)
  42219. */
  42220. floorMeshes?: Mesh[];
  42221. }
  42222. /**
  42223. * Options to modify the vr experience helper's behavior.
  42224. */
  42225. export interface VRExperienceHelperOptions extends WebVROptions {
  42226. /**
  42227. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42228. */
  42229. createDeviceOrientationCamera?: boolean;
  42230. /**
  42231. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42232. */
  42233. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42234. /**
  42235. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42236. */
  42237. laserToggle?: boolean;
  42238. /**
  42239. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42240. */
  42241. floorMeshes?: Mesh[];
  42242. /**
  42243. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42244. */
  42245. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42246. }
  42247. /**
  42248. * Event containing information after VR has been entered
  42249. */
  42250. export class OnAfterEnteringVRObservableEvent {
  42251. /**
  42252. * If entering vr was successful
  42253. */
  42254. success: boolean;
  42255. }
  42256. /**
  42257. * Helps to quickly add VR support to an existing scene.
  42258. * See http://doc.babylonjs.com/how_to/webvr_helper
  42259. */
  42260. export class VRExperienceHelper {
  42261. /** Options to modify the vr experience helper's behavior. */
  42262. webVROptions: VRExperienceHelperOptions;
  42263. private _scene;
  42264. private _position;
  42265. private _btnVR;
  42266. private _btnVRDisplayed;
  42267. private _webVRsupported;
  42268. private _webVRready;
  42269. private _webVRrequesting;
  42270. private _webVRpresenting;
  42271. private _hasEnteredVR;
  42272. private _fullscreenVRpresenting;
  42273. private _canvas;
  42274. private _webVRCamera;
  42275. private _vrDeviceOrientationCamera;
  42276. private _deviceOrientationCamera;
  42277. private _existingCamera;
  42278. private _onKeyDown;
  42279. private _onVrDisplayPresentChange;
  42280. private _onVRDisplayChanged;
  42281. private _onVRRequestPresentStart;
  42282. private _onVRRequestPresentComplete;
  42283. /**
  42284. * 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)
  42285. */
  42286. enableGazeEvenWhenNoPointerLock: boolean;
  42287. /**
  42288. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42289. */
  42290. exitVROnDoubleTap: boolean;
  42291. /**
  42292. * Observable raised right before entering VR.
  42293. */
  42294. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42295. /**
  42296. * Observable raised when entering VR has completed.
  42297. */
  42298. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42299. /**
  42300. * Observable raised when exiting VR.
  42301. */
  42302. onExitingVRObservable: Observable<VRExperienceHelper>;
  42303. /**
  42304. * Observable raised when controller mesh is loaded.
  42305. */
  42306. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42307. /** Return this.onEnteringVRObservable
  42308. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42309. */
  42310. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42311. /** Return this.onExitingVRObservable
  42312. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42313. */
  42314. readonly onExitingVR: Observable<VRExperienceHelper>;
  42315. /** Return this.onControllerMeshLoadedObservable
  42316. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42317. */
  42318. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42319. private _rayLength;
  42320. private _useCustomVRButton;
  42321. private _teleportationRequested;
  42322. private _teleportActive;
  42323. private _floorMeshName;
  42324. private _floorMeshesCollection;
  42325. private _rotationAllowed;
  42326. private _teleportBackwardsVector;
  42327. private _teleportationTarget;
  42328. private _isDefaultTeleportationTarget;
  42329. private _postProcessMove;
  42330. private _teleportationFillColor;
  42331. private _teleportationBorderColor;
  42332. private _rotationAngle;
  42333. private _haloCenter;
  42334. private _cameraGazer;
  42335. private _padSensibilityUp;
  42336. private _padSensibilityDown;
  42337. private _leftController;
  42338. private _rightController;
  42339. /**
  42340. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42341. */
  42342. onNewMeshSelected: Observable<AbstractMesh>;
  42343. /**
  42344. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42345. * This observable will provide the mesh and the controller used to select the mesh
  42346. */
  42347. onMeshSelectedWithController: Observable<{
  42348. mesh: AbstractMesh;
  42349. controller: WebVRController;
  42350. }>;
  42351. /**
  42352. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42353. */
  42354. onNewMeshPicked: Observable<PickingInfo>;
  42355. private _circleEase;
  42356. /**
  42357. * Observable raised before camera teleportation
  42358. */
  42359. onBeforeCameraTeleport: Observable<Vector3>;
  42360. /**
  42361. * Observable raised after camera teleportation
  42362. */
  42363. onAfterCameraTeleport: Observable<Vector3>;
  42364. /**
  42365. * Observable raised when current selected mesh gets unselected
  42366. */
  42367. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42368. private _raySelectionPredicate;
  42369. /**
  42370. * To be optionaly changed by user to define custom ray selection
  42371. */
  42372. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42373. /**
  42374. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42375. */
  42376. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42377. /**
  42378. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42379. */
  42380. teleportationEnabled: boolean;
  42381. private _defaultHeight;
  42382. private _teleportationInitialized;
  42383. private _interactionsEnabled;
  42384. private _interactionsRequested;
  42385. private _displayGaze;
  42386. private _displayLaserPointer;
  42387. /**
  42388. * The mesh used to display where the user is going to teleport.
  42389. */
  42390. /**
  42391. * Sets the mesh to be used to display where the user is going to teleport.
  42392. */
  42393. teleportationTarget: Mesh;
  42394. /**
  42395. * 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
  42396. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42397. * See http://doc.babylonjs.com/resources/baking_transformations
  42398. */
  42399. gazeTrackerMesh: Mesh;
  42400. /**
  42401. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42402. */
  42403. updateGazeTrackerScale: boolean;
  42404. /**
  42405. * If the gaze trackers color should be updated when selecting meshes
  42406. */
  42407. updateGazeTrackerColor: boolean;
  42408. /**
  42409. * The gaze tracking mesh corresponding to the left controller
  42410. */
  42411. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42412. /**
  42413. * The gaze tracking mesh corresponding to the right controller
  42414. */
  42415. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42416. /**
  42417. * If the ray of the gaze should be displayed.
  42418. */
  42419. /**
  42420. * Sets if the ray of the gaze should be displayed.
  42421. */
  42422. displayGaze: boolean;
  42423. /**
  42424. * If the ray of the LaserPointer should be displayed.
  42425. */
  42426. /**
  42427. * Sets if the ray of the LaserPointer should be displayed.
  42428. */
  42429. displayLaserPointer: boolean;
  42430. /**
  42431. * The deviceOrientationCamera used as the camera when not in VR.
  42432. */
  42433. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42434. /**
  42435. * Based on the current WebVR support, returns the current VR camera used.
  42436. */
  42437. readonly currentVRCamera: Nullable<Camera>;
  42438. /**
  42439. * The webVRCamera which is used when in VR.
  42440. */
  42441. readonly webVRCamera: WebVRFreeCamera;
  42442. /**
  42443. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42444. */
  42445. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42446. /**
  42447. * The html button that is used to trigger entering into VR.
  42448. */
  42449. readonly vrButton: Nullable<HTMLButtonElement>;
  42450. private readonly _teleportationRequestInitiated;
  42451. /**
  42452. * Defines wether or not Pointer lock should be requested when switching to
  42453. * full screen.
  42454. */
  42455. requestPointerLockOnFullScreen: boolean;
  42456. /**
  42457. * Instantiates a VRExperienceHelper.
  42458. * Helps to quickly add VR support to an existing scene.
  42459. * @param scene The scene the VRExperienceHelper belongs to.
  42460. * @param webVROptions Options to modify the vr experience helper's behavior.
  42461. */
  42462. constructor(scene: Scene,
  42463. /** Options to modify the vr experience helper's behavior. */
  42464. webVROptions?: VRExperienceHelperOptions);
  42465. private _onDefaultMeshLoaded;
  42466. private _onResize;
  42467. private _onFullscreenChange;
  42468. /**
  42469. * Gets a value indicating if we are currently in VR mode.
  42470. */
  42471. readonly isInVRMode: boolean;
  42472. private onVrDisplayPresentChange;
  42473. private onVRDisplayChanged;
  42474. private moveButtonToBottomRight;
  42475. private displayVRButton;
  42476. private updateButtonVisibility;
  42477. private _cachedAngularSensibility;
  42478. /**
  42479. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42480. * Otherwise, will use the fullscreen API.
  42481. */
  42482. enterVR(): void;
  42483. /**
  42484. * Attempt to exit VR, or fullscreen.
  42485. */
  42486. exitVR(): void;
  42487. /**
  42488. * The position of the vr experience helper.
  42489. */
  42490. /**
  42491. * Sets the position of the vr experience helper.
  42492. */
  42493. position: Vector3;
  42494. /**
  42495. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42496. */
  42497. enableInteractions(): void;
  42498. private readonly _noControllerIsActive;
  42499. private beforeRender;
  42500. private _isTeleportationFloor;
  42501. /**
  42502. * Adds a floor mesh to be used for teleportation.
  42503. * @param floorMesh the mesh to be used for teleportation.
  42504. */
  42505. addFloorMesh(floorMesh: Mesh): void;
  42506. /**
  42507. * Removes a floor mesh from being used for teleportation.
  42508. * @param floorMesh the mesh to be removed.
  42509. */
  42510. removeFloorMesh(floorMesh: Mesh): void;
  42511. /**
  42512. * Enables interactions and teleportation using the VR controllers and gaze.
  42513. * @param vrTeleportationOptions options to modify teleportation behavior.
  42514. */
  42515. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42516. private _onNewGamepadConnected;
  42517. private _tryEnableInteractionOnController;
  42518. private _onNewGamepadDisconnected;
  42519. private _enableInteractionOnController;
  42520. private _checkTeleportWithRay;
  42521. private _checkRotate;
  42522. private _checkTeleportBackwards;
  42523. private _enableTeleportationOnController;
  42524. private _createTeleportationCircles;
  42525. private _displayTeleportationTarget;
  42526. private _hideTeleportationTarget;
  42527. private _rotateCamera;
  42528. private _moveTeleportationSelectorTo;
  42529. private _workingVector;
  42530. private _workingQuaternion;
  42531. private _workingMatrix;
  42532. /**
  42533. * Teleports the users feet to the desired location
  42534. * @param location The location where the user's feet should be placed
  42535. */
  42536. teleportCamera(location: Vector3): void;
  42537. private _convertNormalToDirectionOfRay;
  42538. private _castRayAndSelectObject;
  42539. private _notifySelectedMeshUnselected;
  42540. /**
  42541. * Sets the color of the laser ray from the vr controllers.
  42542. * @param color new color for the ray.
  42543. */
  42544. changeLaserColor(color: Color3): void;
  42545. /**
  42546. * Sets the color of the ray from the vr headsets gaze.
  42547. * @param color new color for the ray.
  42548. */
  42549. changeGazeColor(color: Color3): void;
  42550. /**
  42551. * Exits VR and disposes of the vr experience helper
  42552. */
  42553. dispose(): void;
  42554. /**
  42555. * Gets the name of the VRExperienceHelper class
  42556. * @returns "VRExperienceHelper"
  42557. */
  42558. getClassName(): string;
  42559. }
  42560. }
  42561. declare module "babylonjs/Cameras/VR/index" {
  42562. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42563. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42564. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42565. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42566. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42567. export * from "babylonjs/Cameras/VR/webVRCamera";
  42568. }
  42569. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42570. import { Observable } from "babylonjs/Misc/observable";
  42571. import { Nullable } from "babylonjs/types";
  42572. import { IDisposable, Scene } from "babylonjs/scene";
  42573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42574. /**
  42575. * Manages an XRSession to work with Babylon's engine
  42576. * @see https://doc.babylonjs.com/how_to/webxr
  42577. */
  42578. export class WebXRSessionManager implements IDisposable {
  42579. private scene;
  42580. /**
  42581. * Fires every time a new xrFrame arrives which can be used to update the camera
  42582. */
  42583. onXRFrameObservable: Observable<any>;
  42584. /**
  42585. * Fires when the xr session is ended either by the device or manually done
  42586. */
  42587. onXRSessionEnded: Observable<any>;
  42588. /**
  42589. * Underlying xr session
  42590. */
  42591. session: XRSession;
  42592. /**
  42593. * Type of reference space used when creating the session
  42594. */
  42595. referenceSpace: XRReferenceSpace;
  42596. /** @hidden */
  42597. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42598. /**
  42599. * Current XR frame
  42600. */
  42601. currentFrame: Nullable<XRFrame>;
  42602. private _xrNavigator;
  42603. private baseLayer;
  42604. /**
  42605. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42606. * @param scene The scene which the session should be created for
  42607. */
  42608. constructor(scene: Scene);
  42609. /**
  42610. * Initializes the manager
  42611. * After initialization enterXR can be called to start an XR session
  42612. * @returns Promise which resolves after it is initialized
  42613. */
  42614. initializeAsync(): Promise<void>;
  42615. /**
  42616. * Initializes an xr session
  42617. * @param xrSessionMode mode to initialize
  42618. * @returns a promise which will resolve once the session has been initialized
  42619. */
  42620. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42621. /**
  42622. * Sets the reference space on the xr session
  42623. * @param referenceSpace space to set
  42624. * @returns a promise that will resolve once the reference space has been set
  42625. */
  42626. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42627. /**
  42628. * Updates the render state of the session
  42629. * @param state state to set
  42630. * @returns a promise that resolves once the render state has been updated
  42631. */
  42632. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42633. /**
  42634. * Starts rendering to the xr layer
  42635. * @returns a promise that will resolve once rendering has started
  42636. */
  42637. startRenderingToXRAsync(): Promise<void>;
  42638. /**
  42639. * Stops the xrSession and restores the renderloop
  42640. * @returns Promise which resolves after it exits XR
  42641. */
  42642. exitXRAsync(): Promise<unknown>;
  42643. /**
  42644. * Checks if a session would be supported for the creation options specified
  42645. * @param sessionMode session mode to check if supported eg. immersive-vr
  42646. * @returns true if supported
  42647. */
  42648. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42649. /**
  42650. * @hidden
  42651. * Converts the render layer of xrSession to a render target
  42652. * @param session session to create render target for
  42653. * @param scene scene the new render target should be created for
  42654. */
  42655. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42656. /**
  42657. * Disposes of the session manager
  42658. */
  42659. dispose(): void;
  42660. }
  42661. }
  42662. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42663. import { Scene } from "babylonjs/scene";
  42664. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42665. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42666. /**
  42667. * WebXR Camera which holds the views for the xrSession
  42668. * @see https://doc.babylonjs.com/how_to/webxr
  42669. */
  42670. export class WebXRCamera extends FreeCamera {
  42671. private static _TmpMatrix;
  42672. /**
  42673. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42674. * @param name the name of the camera
  42675. * @param scene the scene to add the camera to
  42676. */
  42677. constructor(name: string, scene: Scene);
  42678. private _updateNumberOfRigCameras;
  42679. /** @hidden */
  42680. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42681. /**
  42682. * Updates the cameras position from the current pose information of the XR session
  42683. * @param xrSessionManager the session containing pose information
  42684. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42685. */
  42686. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42687. }
  42688. }
  42689. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42690. import { Nullable } from "babylonjs/types";
  42691. import { IDisposable } from "babylonjs/scene";
  42692. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42693. /**
  42694. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42695. */
  42696. export class WebXRManagedOutputCanvas implements IDisposable {
  42697. private helper;
  42698. private _canvas;
  42699. /**
  42700. * xrpresent context of the canvas which can be used to display/mirror xr content
  42701. */
  42702. canvasContext: WebGLRenderingContext;
  42703. /**
  42704. * xr layer for the canvas
  42705. */
  42706. xrLayer: Nullable<XRWebGLLayer>;
  42707. /**
  42708. * Initializes the xr layer for the session
  42709. * @param xrSession xr session
  42710. * @returns a promise that will resolve once the XR Layer has been created
  42711. */
  42712. initializeXRLayerAsync(xrSession: any): any;
  42713. /**
  42714. * Initializes the canvas to be added/removed upon entering/exiting xr
  42715. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42716. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42717. */
  42718. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42719. /**
  42720. * Disposes of the object
  42721. */
  42722. dispose(): void;
  42723. private _setManagedOutputCanvas;
  42724. private _addCanvas;
  42725. private _removeCanvas;
  42726. }
  42727. }
  42728. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42729. import { Observable } from "babylonjs/Misc/observable";
  42730. import { IDisposable, Scene } from "babylonjs/scene";
  42731. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42733. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42734. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42735. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42736. /**
  42737. * States of the webXR experience
  42738. */
  42739. export enum WebXRState {
  42740. /**
  42741. * Transitioning to being in XR mode
  42742. */
  42743. ENTERING_XR = 0,
  42744. /**
  42745. * Transitioning to non XR mode
  42746. */
  42747. EXITING_XR = 1,
  42748. /**
  42749. * In XR mode and presenting
  42750. */
  42751. IN_XR = 2,
  42752. /**
  42753. * Not entered XR mode
  42754. */
  42755. NOT_IN_XR = 3
  42756. }
  42757. /**
  42758. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42759. * @see https://doc.babylonjs.com/how_to/webxr
  42760. */
  42761. export class WebXRExperienceHelper implements IDisposable {
  42762. private scene;
  42763. /**
  42764. * 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
  42765. */
  42766. container: AbstractMesh;
  42767. /**
  42768. * Camera used to render xr content
  42769. */
  42770. camera: WebXRCamera;
  42771. /**
  42772. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42773. */
  42774. state: WebXRState;
  42775. private _setState;
  42776. private static _TmpVector;
  42777. /**
  42778. * Fires when the state of the experience helper has changed
  42779. */
  42780. onStateChangedObservable: Observable<WebXRState>;
  42781. /** Session manager used to keep track of xr session */
  42782. sessionManager: WebXRSessionManager;
  42783. private _nonVRCamera;
  42784. private _originalSceneAutoClear;
  42785. private _supported;
  42786. /**
  42787. * Creates the experience helper
  42788. * @param scene the scene to attach the experience helper to
  42789. * @returns a promise for the experience helper
  42790. */
  42791. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42792. /**
  42793. * Creates a WebXRExperienceHelper
  42794. * @param scene The scene the helper should be created in
  42795. */
  42796. private constructor();
  42797. /**
  42798. * Exits XR mode and returns the scene to its original state
  42799. * @returns promise that resolves after xr mode has exited
  42800. */
  42801. exitXRAsync(): Promise<unknown>;
  42802. /**
  42803. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42804. * @param sessionCreationOptions options for the XR session
  42805. * @param referenceSpaceType frame of reference of the XR session
  42806. * @param outputCanvas the output canvas that will be used to enter XR mode
  42807. * @returns promise that resolves after xr mode has entered
  42808. */
  42809. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42810. /**
  42811. * Updates the global position of the camera by moving the camera's container
  42812. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42813. * @param position The desired global position of the camera
  42814. */
  42815. setPositionOfCameraUsingContainer(position: Vector3): void;
  42816. /**
  42817. * Rotates the xr camera by rotating the camera's container around the camera's position
  42818. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42819. * @param rotation the desired quaternion rotation to apply to the camera
  42820. */
  42821. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42822. /**
  42823. * Disposes of the experience helper
  42824. */
  42825. dispose(): void;
  42826. }
  42827. }
  42828. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42829. import { Nullable } from "babylonjs/types";
  42830. import { Observable } from "babylonjs/Misc/observable";
  42831. import { IDisposable, Scene } from "babylonjs/scene";
  42832. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42833. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42834. /**
  42835. * Button which can be used to enter a different mode of XR
  42836. */
  42837. export class WebXREnterExitUIButton {
  42838. /** button element */
  42839. element: HTMLElement;
  42840. /** XR initialization options for the button */
  42841. sessionMode: XRSessionMode;
  42842. /** Reference space type */
  42843. referenceSpaceType: XRReferenceSpaceType;
  42844. /**
  42845. * Creates a WebXREnterExitUIButton
  42846. * @param element button element
  42847. * @param sessionMode XR initialization session mode
  42848. * @param referenceSpaceType the type of reference space to be used
  42849. */
  42850. constructor(
  42851. /** button element */
  42852. element: HTMLElement,
  42853. /** XR initialization options for the button */
  42854. sessionMode: XRSessionMode,
  42855. /** Reference space type */
  42856. referenceSpaceType: XRReferenceSpaceType);
  42857. /**
  42858. * Overwritable function which can be used to update the button's visuals when the state changes
  42859. * @param activeButton the current active button in the UI
  42860. */
  42861. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42862. }
  42863. /**
  42864. * Options to create the webXR UI
  42865. */
  42866. export class WebXREnterExitUIOptions {
  42867. /**
  42868. * Context to enter xr with
  42869. */
  42870. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42871. /**
  42872. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42873. */
  42874. customButtons?: Array<WebXREnterExitUIButton>;
  42875. }
  42876. /**
  42877. * UI to allow the user to enter/exit XR mode
  42878. */
  42879. export class WebXREnterExitUI implements IDisposable {
  42880. private scene;
  42881. private _overlay;
  42882. private _buttons;
  42883. private _activeButton;
  42884. /**
  42885. * Fired every time the active button is changed.
  42886. *
  42887. * When xr is entered via a button that launches xr that button will be the callback parameter
  42888. *
  42889. * When exiting xr the callback parameter will be null)
  42890. */
  42891. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42892. /**
  42893. * Creates UI to allow the user to enter/exit XR mode
  42894. * @param scene the scene to add the ui to
  42895. * @param helper the xr experience helper to enter/exit xr with
  42896. * @param options options to configure the UI
  42897. * @returns the created ui
  42898. */
  42899. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42900. private constructor();
  42901. private _updateButtons;
  42902. /**
  42903. * Disposes of the object
  42904. */
  42905. dispose(): void;
  42906. }
  42907. }
  42908. declare module "babylonjs/Cameras/XR/webXRController" {
  42909. import { Nullable } from "babylonjs/types";
  42910. import { Observable } from "babylonjs/Misc/observable";
  42911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42912. import { Ray } from "babylonjs/Culling/ray";
  42913. import { Scene } from "babylonjs/scene";
  42914. /**
  42915. * Represents an XR input
  42916. */
  42917. export class WebXRController {
  42918. private scene;
  42919. /** The underlying input source for the controller */
  42920. inputSource: XRInputSource;
  42921. private parentContainer;
  42922. /**
  42923. * 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
  42924. */
  42925. grip?: AbstractMesh;
  42926. /**
  42927. * Pointer which can be used to select objects or attach a visible laser to
  42928. */
  42929. pointer: AbstractMesh;
  42930. /**
  42931. * Event that fires when the controller is removed/disposed
  42932. */
  42933. onDisposeObservable: Observable<{}>;
  42934. private _tmpMatrix;
  42935. private _tmpQuaternion;
  42936. private _tmpVector;
  42937. /**
  42938. * Creates the controller
  42939. * @see https://doc.babylonjs.com/how_to/webxr
  42940. * @param scene the scene which the controller should be associated to
  42941. * @param inputSource the underlying input source for the controller
  42942. * @param parentContainer parent that the controller meshes should be children of
  42943. */
  42944. constructor(scene: Scene,
  42945. /** The underlying input source for the controller */
  42946. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42947. /**
  42948. * Updates the controller pose based on the given XRFrame
  42949. * @param xrFrame xr frame to update the pose with
  42950. * @param referenceSpace reference space to use
  42951. */
  42952. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42953. /**
  42954. * Gets a world space ray coming from the controller
  42955. * @param result the resulting ray
  42956. */
  42957. getWorldPointerRayToRef(result: Ray): void;
  42958. /**
  42959. * Disposes of the object
  42960. */
  42961. dispose(): void;
  42962. }
  42963. }
  42964. declare module "babylonjs/Cameras/XR/webXRInput" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { IDisposable } from "babylonjs/scene";
  42967. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42968. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42969. /**
  42970. * XR input used to track XR inputs such as controllers/rays
  42971. */
  42972. export class WebXRInput implements IDisposable {
  42973. /**
  42974. * Base experience the input listens to
  42975. */
  42976. baseExperience: WebXRExperienceHelper;
  42977. /**
  42978. * XR controllers being tracked
  42979. */
  42980. controllers: Array<WebXRController>;
  42981. private _frameObserver;
  42982. private _stateObserver;
  42983. /**
  42984. * Event when a controller has been connected/added
  42985. */
  42986. onControllerAddedObservable: Observable<WebXRController>;
  42987. /**
  42988. * Event when a controller has been removed/disconnected
  42989. */
  42990. onControllerRemovedObservable: Observable<WebXRController>;
  42991. /**
  42992. * Initializes the WebXRInput
  42993. * @param baseExperience experience helper which the input should be created for
  42994. */
  42995. constructor(
  42996. /**
  42997. * Base experience the input listens to
  42998. */
  42999. baseExperience: WebXRExperienceHelper);
  43000. private _onInputSourcesChange;
  43001. private _addAndRemoveControllers;
  43002. /**
  43003. * Disposes of the object
  43004. */
  43005. dispose(): void;
  43006. }
  43007. }
  43008. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43010. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43011. /**
  43012. * Enables teleportation
  43013. */
  43014. export class WebXRControllerTeleportation {
  43015. private _teleportationFillColor;
  43016. private _teleportationBorderColor;
  43017. private _tmpRay;
  43018. private _tmpVector;
  43019. /**
  43020. * Creates a WebXRControllerTeleportation
  43021. * @param input input manager to add teleportation to
  43022. * @param floorMeshes floormeshes which can be teleported to
  43023. */
  43024. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43025. }
  43026. }
  43027. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43028. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43029. /**
  43030. * Handles pointer input automatically for the pointer of XR controllers
  43031. */
  43032. export class WebXRControllerPointerSelection {
  43033. private static _idCounter;
  43034. private _tmpRay;
  43035. /**
  43036. * Creates a WebXRControllerPointerSelection
  43037. * @param input input manager to setup pointer selection
  43038. */
  43039. constructor(input: WebXRInput);
  43040. private _convertNormalToDirectionOfRay;
  43041. private _updatePointerDistance;
  43042. }
  43043. }
  43044. declare module "babylonjs/Loading/sceneLoader" {
  43045. import { Observable } from "babylonjs/Misc/observable";
  43046. import { Nullable } from "babylonjs/types";
  43047. import { Scene } from "babylonjs/scene";
  43048. import { Engine } from "babylonjs/Engines/engine";
  43049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43050. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43051. import { AssetContainer } from "babylonjs/assetContainer";
  43052. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43053. import { Skeleton } from "babylonjs/Bones/skeleton";
  43054. /**
  43055. * Class used to represent data loading progression
  43056. */
  43057. export class SceneLoaderProgressEvent {
  43058. /** defines if data length to load can be evaluated */
  43059. readonly lengthComputable: boolean;
  43060. /** defines the loaded data length */
  43061. readonly loaded: number;
  43062. /** defines the data length to load */
  43063. readonly total: number;
  43064. /**
  43065. * Create a new progress event
  43066. * @param lengthComputable defines if data length to load can be evaluated
  43067. * @param loaded defines the loaded data length
  43068. * @param total defines the data length to load
  43069. */
  43070. constructor(
  43071. /** defines if data length to load can be evaluated */
  43072. lengthComputable: boolean,
  43073. /** defines the loaded data length */
  43074. loaded: number,
  43075. /** defines the data length to load */
  43076. total: number);
  43077. /**
  43078. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43079. * @param event defines the source event
  43080. * @returns a new SceneLoaderProgressEvent
  43081. */
  43082. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43083. }
  43084. /**
  43085. * Interface used by SceneLoader plugins to define supported file extensions
  43086. */
  43087. export interface ISceneLoaderPluginExtensions {
  43088. /**
  43089. * Defines the list of supported extensions
  43090. */
  43091. [extension: string]: {
  43092. isBinary: boolean;
  43093. };
  43094. }
  43095. /**
  43096. * Interface used by SceneLoader plugin factory
  43097. */
  43098. export interface ISceneLoaderPluginFactory {
  43099. /**
  43100. * Defines the name of the factory
  43101. */
  43102. name: string;
  43103. /**
  43104. * Function called to create a new plugin
  43105. * @return the new plugin
  43106. */
  43107. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43108. /**
  43109. * Boolean indicating if the plugin can direct load specific data
  43110. */
  43111. canDirectLoad?: (data: string) => boolean;
  43112. }
  43113. /**
  43114. * Interface used to define a SceneLoader plugin
  43115. */
  43116. export interface ISceneLoaderPlugin {
  43117. /**
  43118. * The friendly name of this plugin.
  43119. */
  43120. name: string;
  43121. /**
  43122. * The file extensions supported by this plugin.
  43123. */
  43124. extensions: string | ISceneLoaderPluginExtensions;
  43125. /**
  43126. * Import meshes into a scene.
  43127. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43128. * @param scene The scene to import into
  43129. * @param data The data to import
  43130. * @param rootUrl The root url for scene and resources
  43131. * @param meshes The meshes array to import into
  43132. * @param particleSystems The particle systems array to import into
  43133. * @param skeletons The skeletons array to import into
  43134. * @param onError The callback when import fails
  43135. * @returns True if successful or false otherwise
  43136. */
  43137. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43138. /**
  43139. * Load into a scene.
  43140. * @param scene The scene to load into
  43141. * @param data The data to import
  43142. * @param rootUrl The root url for scene and resources
  43143. * @param onError The callback when import fails
  43144. * @returns true if successful or false otherwise
  43145. */
  43146. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43147. /**
  43148. * The callback that returns true if the data can be directly loaded.
  43149. */
  43150. canDirectLoad?: (data: string) => boolean;
  43151. /**
  43152. * The callback that allows custom handling of the root url based on the response url.
  43153. */
  43154. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43155. /**
  43156. * Load into an asset container.
  43157. * @param scene The scene to load into
  43158. * @param data The data to import
  43159. * @param rootUrl The root url for scene and resources
  43160. * @param onError The callback when import fails
  43161. * @returns The loaded asset container
  43162. */
  43163. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43164. }
  43165. /**
  43166. * Interface used to define an async SceneLoader plugin
  43167. */
  43168. export interface ISceneLoaderPluginAsync {
  43169. /**
  43170. * The friendly name of this plugin.
  43171. */
  43172. name: string;
  43173. /**
  43174. * The file extensions supported by this plugin.
  43175. */
  43176. extensions: string | ISceneLoaderPluginExtensions;
  43177. /**
  43178. * Import meshes into a scene.
  43179. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43180. * @param scene The scene to import into
  43181. * @param data The data to import
  43182. * @param rootUrl The root url for scene and resources
  43183. * @param onProgress The callback when the load progresses
  43184. * @param fileName Defines the name of the file to load
  43185. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43186. */
  43187. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43188. meshes: AbstractMesh[];
  43189. particleSystems: IParticleSystem[];
  43190. skeletons: Skeleton[];
  43191. animationGroups: AnimationGroup[];
  43192. }>;
  43193. /**
  43194. * Load into a scene.
  43195. * @param scene The scene to load into
  43196. * @param data The data to import
  43197. * @param rootUrl The root url for scene and resources
  43198. * @param onProgress The callback when the load progresses
  43199. * @param fileName Defines the name of the file to load
  43200. * @returns Nothing
  43201. */
  43202. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43203. /**
  43204. * The callback that returns true if the data can be directly loaded.
  43205. */
  43206. canDirectLoad?: (data: string) => boolean;
  43207. /**
  43208. * The callback that allows custom handling of the root url based on the response url.
  43209. */
  43210. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43211. /**
  43212. * Load into an asset container.
  43213. * @param scene The scene to load into
  43214. * @param data The data to import
  43215. * @param rootUrl The root url for scene and resources
  43216. * @param onProgress The callback when the load progresses
  43217. * @param fileName Defines the name of the file to load
  43218. * @returns The loaded asset container
  43219. */
  43220. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43221. }
  43222. /**
  43223. * Class used to load scene from various file formats using registered plugins
  43224. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43225. */
  43226. export class SceneLoader {
  43227. /**
  43228. * No logging while loading
  43229. */
  43230. static readonly NO_LOGGING: number;
  43231. /**
  43232. * Minimal logging while loading
  43233. */
  43234. static readonly MINIMAL_LOGGING: number;
  43235. /**
  43236. * Summary logging while loading
  43237. */
  43238. static readonly SUMMARY_LOGGING: number;
  43239. /**
  43240. * Detailled logging while loading
  43241. */
  43242. static readonly DETAILED_LOGGING: number;
  43243. /**
  43244. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43245. */
  43246. static ForceFullSceneLoadingForIncremental: boolean;
  43247. /**
  43248. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43249. */
  43250. static ShowLoadingScreen: boolean;
  43251. /**
  43252. * Defines the current logging level (while loading the scene)
  43253. * @ignorenaming
  43254. */
  43255. static loggingLevel: number;
  43256. /**
  43257. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43258. */
  43259. static CleanBoneMatrixWeights: boolean;
  43260. /**
  43261. * Event raised when a plugin is used to load a scene
  43262. */
  43263. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43264. private static _registeredPlugins;
  43265. private static _getDefaultPlugin;
  43266. private static _getPluginForExtension;
  43267. private static _getPluginForDirectLoad;
  43268. private static _getPluginForFilename;
  43269. private static _getDirectLoad;
  43270. private static _loadData;
  43271. private static _getFileInfo;
  43272. /**
  43273. * Gets a plugin that can load the given extension
  43274. * @param extension defines the extension to load
  43275. * @returns a plugin or null if none works
  43276. */
  43277. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43278. /**
  43279. * Gets a boolean indicating that the given extension can be loaded
  43280. * @param extension defines the extension to load
  43281. * @returns true if the extension is supported
  43282. */
  43283. static IsPluginForExtensionAvailable(extension: string): boolean;
  43284. /**
  43285. * Adds a new plugin to the list of registered plugins
  43286. * @param plugin defines the plugin to add
  43287. */
  43288. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43289. /**
  43290. * Import meshes into a scene
  43291. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43292. * @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)
  43293. * @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)
  43294. * @param scene the instance of BABYLON.Scene to append to
  43295. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43296. * @param onProgress a callback with a progress event for each file being loaded
  43297. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43298. * @param pluginExtension the extension used to determine the plugin
  43299. * @returns The loaded plugin
  43300. */
  43301. 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>;
  43302. /**
  43303. * Import meshes into a scene
  43304. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43305. * @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)
  43306. * @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)
  43307. * @param scene the instance of BABYLON.Scene to append to
  43308. * @param onProgress a callback with a progress event for each file being loaded
  43309. * @param pluginExtension the extension used to determine the plugin
  43310. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43311. */
  43312. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43313. meshes: AbstractMesh[];
  43314. particleSystems: IParticleSystem[];
  43315. skeletons: Skeleton[];
  43316. animationGroups: AnimationGroup[];
  43317. }>;
  43318. /**
  43319. * Load a scene
  43320. * @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)
  43321. * @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)
  43322. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43323. * @param onSuccess a callback with the scene when import succeeds
  43324. * @param onProgress a callback with a progress event for each file being loaded
  43325. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43326. * @param pluginExtension the extension used to determine the plugin
  43327. * @returns The loaded plugin
  43328. */
  43329. 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>;
  43330. /**
  43331. * Load a scene
  43332. * @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)
  43333. * @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)
  43334. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43335. * @param onProgress a callback with a progress event for each file being loaded
  43336. * @param pluginExtension the extension used to determine the plugin
  43337. * @returns The loaded scene
  43338. */
  43339. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43340. /**
  43341. * Append a scene
  43342. * @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)
  43343. * @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)
  43344. * @param scene is the instance of BABYLON.Scene to append to
  43345. * @param onSuccess a callback with the scene when import succeeds
  43346. * @param onProgress a callback with a progress event for each file being loaded
  43347. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43348. * @param pluginExtension the extension used to determine the plugin
  43349. * @returns The loaded plugin
  43350. */
  43351. 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>;
  43352. /**
  43353. * Append a scene
  43354. * @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)
  43355. * @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)
  43356. * @param scene is the instance of BABYLON.Scene to append to
  43357. * @param onProgress a callback with a progress event for each file being loaded
  43358. * @param pluginExtension the extension used to determine the plugin
  43359. * @returns The given scene
  43360. */
  43361. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43362. /**
  43363. * Load a scene into an asset container
  43364. * @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)
  43365. * @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)
  43366. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43367. * @param onSuccess a callback with the scene when import succeeds
  43368. * @param onProgress a callback with a progress event for each file being loaded
  43369. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43370. * @param pluginExtension the extension used to determine the plugin
  43371. * @returns The loaded plugin
  43372. */
  43373. 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>;
  43374. /**
  43375. * Load a scene into an asset container
  43376. * @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)
  43377. * @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)
  43378. * @param scene is the instance of Scene to append to
  43379. * @param onProgress a callback with a progress event for each file being loaded
  43380. * @param pluginExtension the extension used to determine the plugin
  43381. * @returns The loaded asset container
  43382. */
  43383. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43384. }
  43385. }
  43386. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43387. import { Scene } from "babylonjs/scene";
  43388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43389. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43390. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43391. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43392. /**
  43393. * Generic Controller
  43394. */
  43395. export class GenericController extends WebVRController {
  43396. /**
  43397. * Base Url for the controller model.
  43398. */
  43399. static readonly MODEL_BASE_URL: string;
  43400. /**
  43401. * File name for the controller model.
  43402. */
  43403. static readonly MODEL_FILENAME: string;
  43404. /**
  43405. * Creates a new GenericController from a gamepad
  43406. * @param vrGamepad the gamepad that the controller should be created from
  43407. */
  43408. constructor(vrGamepad: any);
  43409. /**
  43410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43411. * @param scene scene in which to add meshes
  43412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43413. */
  43414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43415. /**
  43416. * Called once for each button that changed state since the last frame
  43417. * @param buttonIdx Which button index changed
  43418. * @param state New state of the button
  43419. * @param changes Which properties on the state changed since last frame
  43420. */
  43421. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43422. }
  43423. }
  43424. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43425. import { Observable } from "babylonjs/Misc/observable";
  43426. import { Scene } from "babylonjs/scene";
  43427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43428. import { Ray } from "babylonjs/Culling/ray";
  43429. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43430. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43431. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43432. /**
  43433. * Defines the WindowsMotionController object that the state of the windows motion controller
  43434. */
  43435. export class WindowsMotionController extends WebVRController {
  43436. /**
  43437. * The base url used to load the left and right controller models
  43438. */
  43439. static MODEL_BASE_URL: string;
  43440. /**
  43441. * The name of the left controller model file
  43442. */
  43443. static MODEL_LEFT_FILENAME: string;
  43444. /**
  43445. * The name of the right controller model file
  43446. */
  43447. static MODEL_RIGHT_FILENAME: string;
  43448. /**
  43449. * The controller name prefix for this controller type
  43450. */
  43451. static readonly GAMEPAD_ID_PREFIX: string;
  43452. /**
  43453. * The controller id pattern for this controller type
  43454. */
  43455. private static readonly GAMEPAD_ID_PATTERN;
  43456. private _loadedMeshInfo;
  43457. private readonly _mapping;
  43458. /**
  43459. * Fired when the trackpad on this controller is clicked
  43460. */
  43461. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43462. /**
  43463. * Fired when the trackpad on this controller is modified
  43464. */
  43465. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43466. /**
  43467. * The current x and y values of this controller's trackpad
  43468. */
  43469. trackpad: StickValues;
  43470. /**
  43471. * Creates a new WindowsMotionController from a gamepad
  43472. * @param vrGamepad the gamepad that the controller should be created from
  43473. */
  43474. constructor(vrGamepad: any);
  43475. /**
  43476. * Fired when the trigger on this controller is modified
  43477. */
  43478. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43479. /**
  43480. * Fired when the menu button on this controller is modified
  43481. */
  43482. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43483. /**
  43484. * Fired when the grip button on this controller is modified
  43485. */
  43486. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43487. /**
  43488. * Fired when the thumbstick button on this controller is modified
  43489. */
  43490. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43491. /**
  43492. * Fired when the touchpad button on this controller is modified
  43493. */
  43494. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43495. /**
  43496. * Fired when the touchpad values on this controller are modified
  43497. */
  43498. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43499. private _updateTrackpad;
  43500. /**
  43501. * Called once per frame by the engine.
  43502. */
  43503. update(): void;
  43504. /**
  43505. * Called once for each button that changed state since the last frame
  43506. * @param buttonIdx Which button index changed
  43507. * @param state New state of the button
  43508. * @param changes Which properties on the state changed since last frame
  43509. */
  43510. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43511. /**
  43512. * Moves the buttons on the controller mesh based on their current state
  43513. * @param buttonName the name of the button to move
  43514. * @param buttonValue the value of the button which determines the buttons new position
  43515. */
  43516. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43517. /**
  43518. * Moves the axis on the controller mesh based on its current state
  43519. * @param axis the index of the axis
  43520. * @param axisValue the value of the axis which determines the meshes new position
  43521. * @hidden
  43522. */
  43523. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43524. /**
  43525. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43526. * @param scene scene in which to add meshes
  43527. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43528. */
  43529. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43530. /**
  43531. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43532. * can be transformed by button presses and axes values, based on this._mapping.
  43533. *
  43534. * @param scene scene in which the meshes exist
  43535. * @param meshes list of meshes that make up the controller model to process
  43536. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43537. */
  43538. private processModel;
  43539. private createMeshInfo;
  43540. /**
  43541. * Gets the ray of the controller in the direction the controller is pointing
  43542. * @param length the length the resulting ray should be
  43543. * @returns a ray in the direction the controller is pointing
  43544. */
  43545. getForwardRay(length?: number): Ray;
  43546. /**
  43547. * Disposes of the controller
  43548. */
  43549. dispose(): void;
  43550. }
  43551. }
  43552. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43553. import { Observable } from "babylonjs/Misc/observable";
  43554. import { Scene } from "babylonjs/scene";
  43555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43556. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43557. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43558. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43559. /**
  43560. * Oculus Touch Controller
  43561. */
  43562. export class OculusTouchController extends WebVRController {
  43563. /**
  43564. * Base Url for the controller model.
  43565. */
  43566. static MODEL_BASE_URL: string;
  43567. /**
  43568. * File name for the left controller model.
  43569. */
  43570. static MODEL_LEFT_FILENAME: string;
  43571. /**
  43572. * File name for the right controller model.
  43573. */
  43574. static MODEL_RIGHT_FILENAME: string;
  43575. /**
  43576. * Base Url for the Quest controller model.
  43577. */
  43578. static QUEST_MODEL_BASE_URL: string;
  43579. /**
  43580. * @hidden
  43581. * If the controllers are running on a device that needs the updated Quest controller models
  43582. */
  43583. static _IsQuest: boolean;
  43584. /**
  43585. * Fired when the secondary trigger on this controller is modified
  43586. */
  43587. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43588. /**
  43589. * Fired when the thumb rest on this controller is modified
  43590. */
  43591. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43592. /**
  43593. * Creates a new OculusTouchController from a gamepad
  43594. * @param vrGamepad the gamepad that the controller should be created from
  43595. */
  43596. constructor(vrGamepad: any);
  43597. /**
  43598. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43599. * @param scene scene in which to add meshes
  43600. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43601. */
  43602. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43603. /**
  43604. * Fired when the A button on this controller is modified
  43605. */
  43606. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43607. /**
  43608. * Fired when the B button on this controller is modified
  43609. */
  43610. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43611. /**
  43612. * Fired when the X button on this controller is modified
  43613. */
  43614. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43615. /**
  43616. * Fired when the Y button on this controller is modified
  43617. */
  43618. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43619. /**
  43620. * Called once for each button that changed state since the last frame
  43621. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43622. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43623. * 2) secondary trigger (same)
  43624. * 3) A (right) X (left), touch, pressed = value
  43625. * 4) B / Y
  43626. * 5) thumb rest
  43627. * @param buttonIdx Which button index changed
  43628. * @param state New state of the button
  43629. * @param changes Which properties on the state changed since last frame
  43630. */
  43631. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43632. }
  43633. }
  43634. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43635. import { Scene } from "babylonjs/scene";
  43636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43637. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43638. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43639. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43640. import { Observable } from "babylonjs/Misc/observable";
  43641. /**
  43642. * Vive Controller
  43643. */
  43644. export class ViveController extends WebVRController {
  43645. /**
  43646. * Base Url for the controller model.
  43647. */
  43648. static MODEL_BASE_URL: string;
  43649. /**
  43650. * File name for the controller model.
  43651. */
  43652. static MODEL_FILENAME: string;
  43653. /**
  43654. * Creates a new ViveController from a gamepad
  43655. * @param vrGamepad the gamepad that the controller should be created from
  43656. */
  43657. constructor(vrGamepad: any);
  43658. /**
  43659. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43660. * @param scene scene in which to add meshes
  43661. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43662. */
  43663. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43664. /**
  43665. * Fired when the left button on this controller is modified
  43666. */
  43667. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43668. /**
  43669. * Fired when the right button on this controller is modified
  43670. */
  43671. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43672. /**
  43673. * Fired when the menu button on this controller is modified
  43674. */
  43675. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43676. /**
  43677. * Called once for each button that changed state since the last frame
  43678. * Vive mapping:
  43679. * 0: touchpad
  43680. * 1: trigger
  43681. * 2: left AND right buttons
  43682. * 3: menu button
  43683. * @param buttonIdx Which button index changed
  43684. * @param state New state of the button
  43685. * @param changes Which properties on the state changed since last frame
  43686. */
  43687. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43688. }
  43689. }
  43690. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43691. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43692. /**
  43693. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43694. */
  43695. export class WebXRControllerModelLoader {
  43696. /**
  43697. * Creates the WebXRControllerModelLoader
  43698. * @param input xr input that creates the controllers
  43699. */
  43700. constructor(input: WebXRInput);
  43701. }
  43702. }
  43703. declare module "babylonjs/Cameras/XR/index" {
  43704. export * from "babylonjs/Cameras/XR/webXRCamera";
  43705. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43706. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43707. export * from "babylonjs/Cameras/XR/webXRInput";
  43708. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43709. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43710. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43711. export * from "babylonjs/Cameras/XR/webXRController";
  43712. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43713. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43714. }
  43715. declare module "babylonjs/Cameras/RigModes/index" {
  43716. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43717. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43718. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43719. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43720. }
  43721. declare module "babylonjs/Cameras/index" {
  43722. export * from "babylonjs/Cameras/Inputs/index";
  43723. export * from "babylonjs/Cameras/cameraInputsManager";
  43724. export * from "babylonjs/Cameras/camera";
  43725. export * from "babylonjs/Cameras/targetCamera";
  43726. export * from "babylonjs/Cameras/freeCamera";
  43727. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43728. export * from "babylonjs/Cameras/touchCamera";
  43729. export * from "babylonjs/Cameras/arcRotateCamera";
  43730. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43731. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43732. export * from "babylonjs/Cameras/flyCamera";
  43733. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43734. export * from "babylonjs/Cameras/followCamera";
  43735. export * from "babylonjs/Cameras/gamepadCamera";
  43736. export * from "babylonjs/Cameras/Stereoscopic/index";
  43737. export * from "babylonjs/Cameras/universalCamera";
  43738. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43739. export * from "babylonjs/Cameras/VR/index";
  43740. export * from "babylonjs/Cameras/XR/index";
  43741. export * from "babylonjs/Cameras/RigModes/index";
  43742. }
  43743. declare module "babylonjs/Collisions/index" {
  43744. export * from "babylonjs/Collisions/collider";
  43745. export * from "babylonjs/Collisions/collisionCoordinator";
  43746. export * from "babylonjs/Collisions/pickingInfo";
  43747. export * from "babylonjs/Collisions/intersectionInfo";
  43748. export * from "babylonjs/Collisions/meshCollisionData";
  43749. }
  43750. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43751. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43752. import { Vector3 } from "babylonjs/Maths/math.vector";
  43753. import { Ray } from "babylonjs/Culling/ray";
  43754. import { Plane } from "babylonjs/Maths/math.plane";
  43755. /**
  43756. * Contains an array of blocks representing the octree
  43757. */
  43758. export interface IOctreeContainer<T> {
  43759. /**
  43760. * Blocks within the octree
  43761. */
  43762. blocks: Array<OctreeBlock<T>>;
  43763. }
  43764. /**
  43765. * Class used to store a cell in an octree
  43766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43767. */
  43768. export class OctreeBlock<T> {
  43769. /**
  43770. * Gets the content of the current block
  43771. */
  43772. entries: T[];
  43773. /**
  43774. * Gets the list of block children
  43775. */
  43776. blocks: Array<OctreeBlock<T>>;
  43777. private _depth;
  43778. private _maxDepth;
  43779. private _capacity;
  43780. private _minPoint;
  43781. private _maxPoint;
  43782. private _boundingVectors;
  43783. private _creationFunc;
  43784. /**
  43785. * Creates a new block
  43786. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43787. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43788. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43789. * @param depth defines the current depth of this block in the octree
  43790. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43791. * @param creationFunc defines a callback to call when an element is added to the block
  43792. */
  43793. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43794. /**
  43795. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43796. */
  43797. readonly capacity: number;
  43798. /**
  43799. * Gets the minimum vector (in world space) of the block's bounding box
  43800. */
  43801. readonly minPoint: Vector3;
  43802. /**
  43803. * Gets the maximum vector (in world space) of the block's bounding box
  43804. */
  43805. readonly maxPoint: Vector3;
  43806. /**
  43807. * Add a new element to this block
  43808. * @param entry defines the element to add
  43809. */
  43810. addEntry(entry: T): void;
  43811. /**
  43812. * Remove an element from this block
  43813. * @param entry defines the element to remove
  43814. */
  43815. removeEntry(entry: T): void;
  43816. /**
  43817. * Add an array of elements to this block
  43818. * @param entries defines the array of elements to add
  43819. */
  43820. addEntries(entries: T[]): void;
  43821. /**
  43822. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43823. * @param frustumPlanes defines the frustum planes to test
  43824. * @param selection defines the array to store current content if selection is positive
  43825. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43826. */
  43827. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43828. /**
  43829. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43830. * @param sphereCenter defines the bounding sphere center
  43831. * @param sphereRadius defines the bounding sphere radius
  43832. * @param selection defines the array to store current content if selection is positive
  43833. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43834. */
  43835. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43836. /**
  43837. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43838. * @param ray defines the ray to test with
  43839. * @param selection defines the array to store current content if selection is positive
  43840. */
  43841. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43842. /**
  43843. * Subdivide the content into child blocks (this block will then be empty)
  43844. */
  43845. createInnerBlocks(): void;
  43846. /**
  43847. * @hidden
  43848. */
  43849. 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;
  43850. }
  43851. }
  43852. declare module "babylonjs/Culling/Octrees/octree" {
  43853. import { SmartArray } from "babylonjs/Misc/smartArray";
  43854. import { Vector3 } from "babylonjs/Maths/math.vector";
  43855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43857. import { Ray } from "babylonjs/Culling/ray";
  43858. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43859. import { Plane } from "babylonjs/Maths/math.plane";
  43860. /**
  43861. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43862. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43863. */
  43864. export class Octree<T> {
  43865. /** 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.) */
  43866. maxDepth: number;
  43867. /**
  43868. * Blocks within the octree containing objects
  43869. */
  43870. blocks: Array<OctreeBlock<T>>;
  43871. /**
  43872. * Content stored in the octree
  43873. */
  43874. dynamicContent: T[];
  43875. private _maxBlockCapacity;
  43876. private _selectionContent;
  43877. private _creationFunc;
  43878. /**
  43879. * Creates a octree
  43880. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43881. * @param creationFunc function to be used to instatiate the octree
  43882. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43883. * @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.)
  43884. */
  43885. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43886. /** 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.) */
  43887. maxDepth?: number);
  43888. /**
  43889. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43890. * @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);
  43891. * @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);
  43892. * @param entries meshes to be added to the octree blocks
  43893. */
  43894. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43895. /**
  43896. * Adds a mesh to the octree
  43897. * @param entry Mesh to add to the octree
  43898. */
  43899. addMesh(entry: T): void;
  43900. /**
  43901. * Remove an element from the octree
  43902. * @param entry defines the element to remove
  43903. */
  43904. removeMesh(entry: T): void;
  43905. /**
  43906. * Selects an array of meshes within the frustum
  43907. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43908. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43909. * @returns array of meshes within the frustum
  43910. */
  43911. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43912. /**
  43913. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43914. * @param sphereCenter defines the bounding sphere center
  43915. * @param sphereRadius defines the bounding sphere radius
  43916. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43917. * @returns an array of objects that intersect the sphere
  43918. */
  43919. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43920. /**
  43921. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43922. * @param ray defines the ray to test with
  43923. * @returns array of intersected objects
  43924. */
  43925. intersectsRay(ray: Ray): SmartArray<T>;
  43926. /**
  43927. * Adds a mesh into the octree block if it intersects the block
  43928. */
  43929. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43930. /**
  43931. * Adds a submesh into the octree block if it intersects the block
  43932. */
  43933. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43934. }
  43935. }
  43936. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43937. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43938. import { Scene } from "babylonjs/scene";
  43939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43941. import { Ray } from "babylonjs/Culling/ray";
  43942. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43943. import { Collider } from "babylonjs/Collisions/collider";
  43944. module "babylonjs/scene" {
  43945. interface Scene {
  43946. /**
  43947. * @hidden
  43948. * Backing Filed
  43949. */
  43950. _selectionOctree: Octree<AbstractMesh>;
  43951. /**
  43952. * Gets the octree used to boost mesh selection (picking)
  43953. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43954. */
  43955. selectionOctree: Octree<AbstractMesh>;
  43956. /**
  43957. * Creates or updates the octree used to boost selection (picking)
  43958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43959. * @param maxCapacity defines the maximum capacity per leaf
  43960. * @param maxDepth defines the maximum depth of the octree
  43961. * @returns an octree of AbstractMesh
  43962. */
  43963. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43964. }
  43965. }
  43966. module "babylonjs/Meshes/abstractMesh" {
  43967. interface AbstractMesh {
  43968. /**
  43969. * @hidden
  43970. * Backing Field
  43971. */
  43972. _submeshesOctree: Octree<SubMesh>;
  43973. /**
  43974. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43976. * @param maxCapacity defines the maximum size of each block (64 by default)
  43977. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43978. * @returns the new octree
  43979. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43981. */
  43982. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43983. }
  43984. }
  43985. /**
  43986. * Defines the octree scene component responsible to manage any octrees
  43987. * in a given scene.
  43988. */
  43989. export class OctreeSceneComponent {
  43990. /**
  43991. * The component name help to identify the component in the list of scene components.
  43992. */
  43993. readonly name: string;
  43994. /**
  43995. * The scene the component belongs to.
  43996. */
  43997. scene: Scene;
  43998. /**
  43999. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44000. */
  44001. readonly checksIsEnabled: boolean;
  44002. /**
  44003. * Creates a new instance of the component for the given scene
  44004. * @param scene Defines the scene to register the component in
  44005. */
  44006. constructor(scene: Scene);
  44007. /**
  44008. * Registers the component in a given scene
  44009. */
  44010. register(): void;
  44011. /**
  44012. * Return the list of active meshes
  44013. * @returns the list of active meshes
  44014. */
  44015. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44016. /**
  44017. * Return the list of active sub meshes
  44018. * @param mesh The mesh to get the candidates sub meshes from
  44019. * @returns the list of active sub meshes
  44020. */
  44021. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44022. private _tempRay;
  44023. /**
  44024. * Return the list of sub meshes intersecting with a given local ray
  44025. * @param mesh defines the mesh to find the submesh for
  44026. * @param localRay defines the ray in local space
  44027. * @returns the list of intersecting sub meshes
  44028. */
  44029. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44030. /**
  44031. * Return the list of sub meshes colliding with a collider
  44032. * @param mesh defines the mesh to find the submesh for
  44033. * @param collider defines the collider to evaluate the collision against
  44034. * @returns the list of colliding sub meshes
  44035. */
  44036. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44037. /**
  44038. * Rebuilds the elements related to this component in case of
  44039. * context lost for instance.
  44040. */
  44041. rebuild(): void;
  44042. /**
  44043. * Disposes the component and the associated ressources.
  44044. */
  44045. dispose(): void;
  44046. }
  44047. }
  44048. declare module "babylonjs/Culling/Octrees/index" {
  44049. export * from "babylonjs/Culling/Octrees/octree";
  44050. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44051. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44052. }
  44053. declare module "babylonjs/Culling/index" {
  44054. export * from "babylonjs/Culling/boundingBox";
  44055. export * from "babylonjs/Culling/boundingInfo";
  44056. export * from "babylonjs/Culling/boundingSphere";
  44057. export * from "babylonjs/Culling/Octrees/index";
  44058. export * from "babylonjs/Culling/ray";
  44059. }
  44060. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44061. import { IDisposable, Scene } from "babylonjs/scene";
  44062. import { Nullable } from "babylonjs/types";
  44063. import { Observable } from "babylonjs/Misc/observable";
  44064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44065. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44066. import { Camera } from "babylonjs/Cameras/camera";
  44067. /**
  44068. * Renders a layer on top of an existing scene
  44069. */
  44070. export class UtilityLayerRenderer implements IDisposable {
  44071. /** the original scene that will be rendered on top of */
  44072. originalScene: Scene;
  44073. private _pointerCaptures;
  44074. private _lastPointerEvents;
  44075. private static _DefaultUtilityLayer;
  44076. private static _DefaultKeepDepthUtilityLayer;
  44077. private _sharedGizmoLight;
  44078. private _renderCamera;
  44079. /**
  44080. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44081. * @returns the camera that is used when rendering the utility layer
  44082. */
  44083. getRenderCamera(): Nullable<Camera>;
  44084. /**
  44085. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44086. * @param cam the camera that should be used when rendering the utility layer
  44087. */
  44088. setRenderCamera(cam: Nullable<Camera>): void;
  44089. /**
  44090. * @hidden
  44091. * Light which used by gizmos to get light shading
  44092. */
  44093. _getSharedGizmoLight(): HemisphericLight;
  44094. /**
  44095. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44096. */
  44097. pickUtilitySceneFirst: boolean;
  44098. /**
  44099. * 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)
  44100. */
  44101. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44102. /**
  44103. * 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)
  44104. */
  44105. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44106. /**
  44107. * The scene that is rendered on top of the original scene
  44108. */
  44109. utilityLayerScene: Scene;
  44110. /**
  44111. * If the utility layer should automatically be rendered on top of existing scene
  44112. */
  44113. shouldRender: boolean;
  44114. /**
  44115. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44116. */
  44117. onlyCheckPointerDownEvents: boolean;
  44118. /**
  44119. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44120. */
  44121. processAllEvents: boolean;
  44122. /**
  44123. * Observable raised when the pointer move from the utility layer scene to the main scene
  44124. */
  44125. onPointerOutObservable: Observable<number>;
  44126. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44127. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44128. private _afterRenderObserver;
  44129. private _sceneDisposeObserver;
  44130. private _originalPointerObserver;
  44131. /**
  44132. * Instantiates a UtilityLayerRenderer
  44133. * @param originalScene the original scene that will be rendered on top of
  44134. * @param handleEvents boolean indicating if the utility layer should handle events
  44135. */
  44136. constructor(
  44137. /** the original scene that will be rendered on top of */
  44138. originalScene: Scene, handleEvents?: boolean);
  44139. private _notifyObservers;
  44140. /**
  44141. * Renders the utility layers scene on top of the original scene
  44142. */
  44143. render(): void;
  44144. /**
  44145. * Disposes of the renderer
  44146. */
  44147. dispose(): void;
  44148. private _updateCamera;
  44149. }
  44150. }
  44151. declare module "babylonjs/Gizmos/gizmo" {
  44152. import { Nullable } from "babylonjs/types";
  44153. import { IDisposable } from "babylonjs/scene";
  44154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44155. import { Mesh } from "babylonjs/Meshes/mesh";
  44156. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44157. /**
  44158. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44159. */
  44160. export class Gizmo implements IDisposable {
  44161. /** The utility layer the gizmo will be added to */
  44162. gizmoLayer: UtilityLayerRenderer;
  44163. /**
  44164. * The root mesh of the gizmo
  44165. */
  44166. _rootMesh: Mesh;
  44167. private _attachedMesh;
  44168. /**
  44169. * Ratio for the scale of the gizmo (Default: 1)
  44170. */
  44171. scaleRatio: number;
  44172. /**
  44173. * If a custom mesh has been set (Default: false)
  44174. */
  44175. protected _customMeshSet: boolean;
  44176. /**
  44177. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44178. * * When set, interactions will be enabled
  44179. */
  44180. attachedMesh: Nullable<AbstractMesh>;
  44181. /**
  44182. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44183. * @param mesh The mesh to replace the default mesh of the gizmo
  44184. */
  44185. setCustomMesh(mesh: Mesh): void;
  44186. /**
  44187. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44188. */
  44189. updateGizmoRotationToMatchAttachedMesh: boolean;
  44190. /**
  44191. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44192. */
  44193. updateGizmoPositionToMatchAttachedMesh: boolean;
  44194. /**
  44195. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44196. */
  44197. updateScale: boolean;
  44198. protected _interactionsEnabled: boolean;
  44199. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44200. private _beforeRenderObserver;
  44201. private _tempVector;
  44202. /**
  44203. * Creates a gizmo
  44204. * @param gizmoLayer The utility layer the gizmo will be added to
  44205. */
  44206. constructor(
  44207. /** The utility layer the gizmo will be added to */
  44208. gizmoLayer?: UtilityLayerRenderer);
  44209. /**
  44210. * Updates the gizmo to match the attached mesh's position/rotation
  44211. */
  44212. protected _update(): void;
  44213. /**
  44214. * Disposes of the gizmo
  44215. */
  44216. dispose(): void;
  44217. }
  44218. }
  44219. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44220. import { Observable } from "babylonjs/Misc/observable";
  44221. import { Nullable } from "babylonjs/types";
  44222. import { Vector3 } from "babylonjs/Maths/math.vector";
  44223. import { Color3 } from "babylonjs/Maths/math.color";
  44224. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44226. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44227. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44228. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44229. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44230. import { Scene } from "babylonjs/scene";
  44231. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44232. /**
  44233. * Single plane drag gizmo
  44234. */
  44235. export class PlaneDragGizmo extends Gizmo {
  44236. /**
  44237. * Drag behavior responsible for the gizmos dragging interactions
  44238. */
  44239. dragBehavior: PointerDragBehavior;
  44240. private _pointerObserver;
  44241. /**
  44242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44243. */
  44244. snapDistance: number;
  44245. /**
  44246. * Event that fires each time the gizmo snaps to a new location.
  44247. * * snapDistance is the the change in distance
  44248. */
  44249. onSnapObservable: Observable<{
  44250. snapDistance: number;
  44251. }>;
  44252. private _plane;
  44253. private _coloredMaterial;
  44254. private _hoverMaterial;
  44255. private _isEnabled;
  44256. private _parent;
  44257. /** @hidden */
  44258. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44259. /** @hidden */
  44260. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44261. /**
  44262. * Creates a PlaneDragGizmo
  44263. * @param gizmoLayer The utility layer the gizmo will be added to
  44264. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44265. * @param color The color of the gizmo
  44266. */
  44267. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44268. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44269. /**
  44270. * If the gizmo is enabled
  44271. */
  44272. isEnabled: boolean;
  44273. /**
  44274. * Disposes of the gizmo
  44275. */
  44276. dispose(): void;
  44277. }
  44278. }
  44279. declare module "babylonjs/Gizmos/positionGizmo" {
  44280. import { Observable } from "babylonjs/Misc/observable";
  44281. import { Nullable } from "babylonjs/types";
  44282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44283. import { Mesh } from "babylonjs/Meshes/mesh";
  44284. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44285. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44286. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44287. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44288. /**
  44289. * Gizmo that enables dragging a mesh along 3 axis
  44290. */
  44291. export class PositionGizmo extends Gizmo {
  44292. /**
  44293. * Internal gizmo used for interactions on the x axis
  44294. */
  44295. xGizmo: AxisDragGizmo;
  44296. /**
  44297. * Internal gizmo used for interactions on the y axis
  44298. */
  44299. yGizmo: AxisDragGizmo;
  44300. /**
  44301. * Internal gizmo used for interactions on the z axis
  44302. */
  44303. zGizmo: AxisDragGizmo;
  44304. /**
  44305. * Internal gizmo used for interactions on the yz plane
  44306. */
  44307. xPlaneGizmo: PlaneDragGizmo;
  44308. /**
  44309. * Internal gizmo used for interactions on the xz plane
  44310. */
  44311. yPlaneGizmo: PlaneDragGizmo;
  44312. /**
  44313. * Internal gizmo used for interactions on the xy plane
  44314. */
  44315. zPlaneGizmo: PlaneDragGizmo;
  44316. /**
  44317. * private variables
  44318. */
  44319. private _meshAttached;
  44320. private _updateGizmoRotationToMatchAttachedMesh;
  44321. private _snapDistance;
  44322. private _scaleRatio;
  44323. /** Fires an event when any of it's sub gizmos are dragged */
  44324. onDragStartObservable: Observable<unknown>;
  44325. /** Fires an event when any of it's sub gizmos are released from dragging */
  44326. onDragEndObservable: Observable<unknown>;
  44327. /**
  44328. * If set to true, planar drag is enabled
  44329. */
  44330. private _planarGizmoEnabled;
  44331. attachedMesh: Nullable<AbstractMesh>;
  44332. /**
  44333. * Creates a PositionGizmo
  44334. * @param gizmoLayer The utility layer the gizmo will be added to
  44335. */
  44336. constructor(gizmoLayer?: UtilityLayerRenderer);
  44337. /**
  44338. * If the planar drag gizmo is enabled
  44339. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44340. */
  44341. planarGizmoEnabled: boolean;
  44342. updateGizmoRotationToMatchAttachedMesh: boolean;
  44343. /**
  44344. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44345. */
  44346. snapDistance: number;
  44347. /**
  44348. * Ratio for the scale of the gizmo (Default: 1)
  44349. */
  44350. scaleRatio: number;
  44351. /**
  44352. * Disposes of the gizmo
  44353. */
  44354. dispose(): void;
  44355. /**
  44356. * CustomMeshes are not supported by this gizmo
  44357. * @param mesh The mesh to replace the default mesh of the gizmo
  44358. */
  44359. setCustomMesh(mesh: Mesh): void;
  44360. }
  44361. }
  44362. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44363. import { Observable } from "babylonjs/Misc/observable";
  44364. import { Nullable } from "babylonjs/types";
  44365. import { Vector3 } from "babylonjs/Maths/math.vector";
  44366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44368. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44369. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44370. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44371. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44372. import { Scene } from "babylonjs/scene";
  44373. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44374. import { Color3 } from "babylonjs/Maths/math.color";
  44375. /**
  44376. * Single axis drag gizmo
  44377. */
  44378. export class AxisDragGizmo extends Gizmo {
  44379. /**
  44380. * Drag behavior responsible for the gizmos dragging interactions
  44381. */
  44382. dragBehavior: PointerDragBehavior;
  44383. private _pointerObserver;
  44384. /**
  44385. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44386. */
  44387. snapDistance: number;
  44388. /**
  44389. * Event that fires each time the gizmo snaps to a new location.
  44390. * * snapDistance is the the change in distance
  44391. */
  44392. onSnapObservable: Observable<{
  44393. snapDistance: number;
  44394. }>;
  44395. private _isEnabled;
  44396. private _parent;
  44397. private _arrow;
  44398. private _coloredMaterial;
  44399. private _hoverMaterial;
  44400. /** @hidden */
  44401. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44402. /** @hidden */
  44403. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44404. /**
  44405. * Creates an AxisDragGizmo
  44406. * @param gizmoLayer The utility layer the gizmo will be added to
  44407. * @param dragAxis The axis which the gizmo will be able to drag on
  44408. * @param color The color of the gizmo
  44409. */
  44410. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44411. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44412. /**
  44413. * If the gizmo is enabled
  44414. */
  44415. isEnabled: boolean;
  44416. /**
  44417. * Disposes of the gizmo
  44418. */
  44419. dispose(): void;
  44420. }
  44421. }
  44422. declare module "babylonjs/Debug/axesViewer" {
  44423. import { Vector3 } from "babylonjs/Maths/math.vector";
  44424. import { Nullable } from "babylonjs/types";
  44425. import { Scene } from "babylonjs/scene";
  44426. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44427. /**
  44428. * The Axes viewer will show 3 axes in a specific point in space
  44429. */
  44430. export class AxesViewer {
  44431. private _xAxis;
  44432. private _yAxis;
  44433. private _zAxis;
  44434. private _scaleLinesFactor;
  44435. private _instanced;
  44436. /**
  44437. * Gets the hosting scene
  44438. */
  44439. scene: Scene;
  44440. /**
  44441. * Gets or sets a number used to scale line length
  44442. */
  44443. scaleLines: number;
  44444. /** Gets the node hierarchy used to render x-axis */
  44445. readonly xAxis: TransformNode;
  44446. /** Gets the node hierarchy used to render y-axis */
  44447. readonly yAxis: TransformNode;
  44448. /** Gets the node hierarchy used to render z-axis */
  44449. readonly zAxis: TransformNode;
  44450. /**
  44451. * Creates a new AxesViewer
  44452. * @param scene defines the hosting scene
  44453. * @param scaleLines defines a number used to scale line length (1 by default)
  44454. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44455. * @param xAxis defines the node hierarchy used to render the x-axis
  44456. * @param yAxis defines the node hierarchy used to render the y-axis
  44457. * @param zAxis defines the node hierarchy used to render the z-axis
  44458. */
  44459. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44460. /**
  44461. * Force the viewer to update
  44462. * @param position defines the position of the viewer
  44463. * @param xaxis defines the x axis of the viewer
  44464. * @param yaxis defines the y axis of the viewer
  44465. * @param zaxis defines the z axis of the viewer
  44466. */
  44467. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44468. /**
  44469. * Creates an instance of this axes viewer.
  44470. * @returns a new axes viewer with instanced meshes
  44471. */
  44472. createInstance(): AxesViewer;
  44473. /** Releases resources */
  44474. dispose(): void;
  44475. private static _SetRenderingGroupId;
  44476. }
  44477. }
  44478. declare module "babylonjs/Debug/boneAxesViewer" {
  44479. import { Nullable } from "babylonjs/types";
  44480. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44481. import { Vector3 } from "babylonjs/Maths/math.vector";
  44482. import { Mesh } from "babylonjs/Meshes/mesh";
  44483. import { Bone } from "babylonjs/Bones/bone";
  44484. import { Scene } from "babylonjs/scene";
  44485. /**
  44486. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44487. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44488. */
  44489. export class BoneAxesViewer extends AxesViewer {
  44490. /**
  44491. * Gets or sets the target mesh where to display the axes viewer
  44492. */
  44493. mesh: Nullable<Mesh>;
  44494. /**
  44495. * Gets or sets the target bone where to display the axes viewer
  44496. */
  44497. bone: Nullable<Bone>;
  44498. /** Gets current position */
  44499. pos: Vector3;
  44500. /** Gets direction of X axis */
  44501. xaxis: Vector3;
  44502. /** Gets direction of Y axis */
  44503. yaxis: Vector3;
  44504. /** Gets direction of Z axis */
  44505. zaxis: Vector3;
  44506. /**
  44507. * Creates a new BoneAxesViewer
  44508. * @param scene defines the hosting scene
  44509. * @param bone defines the target bone
  44510. * @param mesh defines the target mesh
  44511. * @param scaleLines defines a scaling factor for line length (1 by default)
  44512. */
  44513. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44514. /**
  44515. * Force the viewer to update
  44516. */
  44517. update(): void;
  44518. /** Releases resources */
  44519. dispose(): void;
  44520. }
  44521. }
  44522. declare module "babylonjs/Debug/debugLayer" {
  44523. import { Scene } from "babylonjs/scene";
  44524. /**
  44525. * Interface used to define scene explorer extensibility option
  44526. */
  44527. export interface IExplorerExtensibilityOption {
  44528. /**
  44529. * Define the option label
  44530. */
  44531. label: string;
  44532. /**
  44533. * Defines the action to execute on click
  44534. */
  44535. action: (entity: any) => void;
  44536. }
  44537. /**
  44538. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44539. */
  44540. export interface IExplorerExtensibilityGroup {
  44541. /**
  44542. * Defines a predicate to test if a given type mut be extended
  44543. */
  44544. predicate: (entity: any) => boolean;
  44545. /**
  44546. * Gets the list of options added to a type
  44547. */
  44548. entries: IExplorerExtensibilityOption[];
  44549. }
  44550. /**
  44551. * Interface used to define the options to use to create the Inspector
  44552. */
  44553. export interface IInspectorOptions {
  44554. /**
  44555. * Display in overlay mode (default: false)
  44556. */
  44557. overlay?: boolean;
  44558. /**
  44559. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44560. */
  44561. globalRoot?: HTMLElement;
  44562. /**
  44563. * Display the Scene explorer
  44564. */
  44565. showExplorer?: boolean;
  44566. /**
  44567. * Display the property inspector
  44568. */
  44569. showInspector?: boolean;
  44570. /**
  44571. * Display in embed mode (both panes on the right)
  44572. */
  44573. embedMode?: boolean;
  44574. /**
  44575. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44576. */
  44577. handleResize?: boolean;
  44578. /**
  44579. * Allow the panes to popup (default: true)
  44580. */
  44581. enablePopup?: boolean;
  44582. /**
  44583. * Allow the panes to be closed by users (default: true)
  44584. */
  44585. enableClose?: boolean;
  44586. /**
  44587. * Optional list of extensibility entries
  44588. */
  44589. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44590. /**
  44591. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44592. */
  44593. inspectorURL?: string;
  44594. }
  44595. module "babylonjs/scene" {
  44596. interface Scene {
  44597. /**
  44598. * @hidden
  44599. * Backing field
  44600. */
  44601. _debugLayer: DebugLayer;
  44602. /**
  44603. * Gets the debug layer (aka Inspector) associated with the scene
  44604. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44605. */
  44606. debugLayer: DebugLayer;
  44607. }
  44608. }
  44609. /**
  44610. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44611. * what is happening in your scene
  44612. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44613. */
  44614. export class DebugLayer {
  44615. /**
  44616. * Define the url to get the inspector script from.
  44617. * By default it uses the babylonjs CDN.
  44618. * @ignoreNaming
  44619. */
  44620. static InspectorURL: string;
  44621. private _scene;
  44622. private BJSINSPECTOR;
  44623. private _onPropertyChangedObservable?;
  44624. /**
  44625. * Observable triggered when a property is changed through the inspector.
  44626. */
  44627. readonly onPropertyChangedObservable: any;
  44628. /**
  44629. * Instantiates a new debug layer.
  44630. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44631. * what is happening in your scene
  44632. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44633. * @param scene Defines the scene to inspect
  44634. */
  44635. constructor(scene: Scene);
  44636. /** Creates the inspector window. */
  44637. private _createInspector;
  44638. /**
  44639. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44640. * @param entity defines the entity to select
  44641. * @param lineContainerTitle defines the specific block to highlight
  44642. */
  44643. select(entity: any, lineContainerTitle?: string): void;
  44644. /** Get the inspector from bundle or global */
  44645. private _getGlobalInspector;
  44646. /**
  44647. * Get if the inspector is visible or not.
  44648. * @returns true if visible otherwise, false
  44649. */
  44650. isVisible(): boolean;
  44651. /**
  44652. * Hide the inspector and close its window.
  44653. */
  44654. hide(): void;
  44655. /**
  44656. * Launch the debugLayer.
  44657. * @param config Define the configuration of the inspector
  44658. * @return a promise fulfilled when the debug layer is visible
  44659. */
  44660. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44661. }
  44662. }
  44663. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44664. import { Nullable } from "babylonjs/types";
  44665. import { Scene } from "babylonjs/scene";
  44666. import { Vector4 } from "babylonjs/Maths/math.vector";
  44667. import { Color4 } from "babylonjs/Maths/math.color";
  44668. import { Mesh } from "babylonjs/Meshes/mesh";
  44669. /**
  44670. * Class containing static functions to help procedurally build meshes
  44671. */
  44672. export class BoxBuilder {
  44673. /**
  44674. * Creates a box mesh
  44675. * * The parameter `size` sets the size (float) of each box side (default 1)
  44676. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44677. * * 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)
  44678. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44682. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44683. * @param name defines the name of the mesh
  44684. * @param options defines the options used to create the mesh
  44685. * @param scene defines the hosting scene
  44686. * @returns the box mesh
  44687. */
  44688. static CreateBox(name: string, options: {
  44689. size?: number;
  44690. width?: number;
  44691. height?: number;
  44692. depth?: number;
  44693. faceUV?: Vector4[];
  44694. faceColors?: Color4[];
  44695. sideOrientation?: number;
  44696. frontUVs?: Vector4;
  44697. backUVs?: Vector4;
  44698. wrap?: boolean;
  44699. topBaseAt?: number;
  44700. bottomBaseAt?: number;
  44701. updatable?: boolean;
  44702. }, scene?: Nullable<Scene>): Mesh;
  44703. }
  44704. }
  44705. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44706. import { Vector4 } from "babylonjs/Maths/math.vector";
  44707. import { Mesh } from "babylonjs/Meshes/mesh";
  44708. import { Scene } from "babylonjs/scene";
  44709. import { Nullable } from "babylonjs/types";
  44710. /**
  44711. * Class containing static functions to help procedurally build meshes
  44712. */
  44713. export class SphereBuilder {
  44714. /**
  44715. * Creates a sphere mesh
  44716. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44717. * * 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`)
  44718. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44719. * * 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
  44720. * * 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)
  44721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44724. * @param name defines the name of the mesh
  44725. * @param options defines the options used to create the mesh
  44726. * @param scene defines the hosting scene
  44727. * @returns the sphere mesh
  44728. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44729. */
  44730. static CreateSphere(name: string, options: {
  44731. segments?: number;
  44732. diameter?: number;
  44733. diameterX?: number;
  44734. diameterY?: number;
  44735. diameterZ?: number;
  44736. arc?: number;
  44737. slice?: number;
  44738. sideOrientation?: number;
  44739. frontUVs?: Vector4;
  44740. backUVs?: Vector4;
  44741. updatable?: boolean;
  44742. }, scene?: Nullable<Scene>): Mesh;
  44743. }
  44744. }
  44745. declare module "babylonjs/Debug/physicsViewer" {
  44746. import { Nullable } from "babylonjs/types";
  44747. import { Scene } from "babylonjs/scene";
  44748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44749. import { Mesh } from "babylonjs/Meshes/mesh";
  44750. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44751. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44752. /**
  44753. * Used to show the physics impostor around the specific mesh
  44754. */
  44755. export class PhysicsViewer {
  44756. /** @hidden */
  44757. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44758. /** @hidden */
  44759. protected _meshes: Array<Nullable<AbstractMesh>>;
  44760. /** @hidden */
  44761. protected _scene: Nullable<Scene>;
  44762. /** @hidden */
  44763. protected _numMeshes: number;
  44764. /** @hidden */
  44765. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44766. private _renderFunction;
  44767. private _utilityLayer;
  44768. private _debugBoxMesh;
  44769. private _debugSphereMesh;
  44770. private _debugCylinderMesh;
  44771. private _debugMaterial;
  44772. private _debugMeshMeshes;
  44773. /**
  44774. * Creates a new PhysicsViewer
  44775. * @param scene defines the hosting scene
  44776. */
  44777. constructor(scene: Scene);
  44778. /** @hidden */
  44779. protected _updateDebugMeshes(): void;
  44780. /**
  44781. * Renders a specified physic impostor
  44782. * @param impostor defines the impostor to render
  44783. * @param targetMesh defines the mesh represented by the impostor
  44784. * @returns the new debug mesh used to render the impostor
  44785. */
  44786. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44787. /**
  44788. * Hides a specified physic impostor
  44789. * @param impostor defines the impostor to hide
  44790. */
  44791. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44792. private _getDebugMaterial;
  44793. private _getDebugBoxMesh;
  44794. private _getDebugSphereMesh;
  44795. private _getDebugCylinderMesh;
  44796. private _getDebugMeshMesh;
  44797. private _getDebugMesh;
  44798. /** Releases all resources */
  44799. dispose(): void;
  44800. }
  44801. }
  44802. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44803. import { Vector3 } from "babylonjs/Maths/math.vector";
  44804. import { Color4 } from "babylonjs/Maths/math.color";
  44805. import { Nullable } from "babylonjs/types";
  44806. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44807. import { Scene } from "babylonjs/scene";
  44808. /**
  44809. * Class containing static functions to help procedurally build meshes
  44810. */
  44811. export class LinesBuilder {
  44812. /**
  44813. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44814. * * 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
  44815. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44816. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44817. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44818. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44819. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44820. * * 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
  44821. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44824. * @param name defines the name of the new line system
  44825. * @param options defines the options used to create the line system
  44826. * @param scene defines the hosting scene
  44827. * @returns a new line system mesh
  44828. */
  44829. static CreateLineSystem(name: string, options: {
  44830. lines: Vector3[][];
  44831. updatable?: boolean;
  44832. instance?: Nullable<LinesMesh>;
  44833. colors?: Nullable<Color4[][]>;
  44834. useVertexAlpha?: boolean;
  44835. }, scene: Nullable<Scene>): LinesMesh;
  44836. /**
  44837. * Creates a line mesh
  44838. * 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
  44839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44840. * * The parameter `points` is an array successive Vector3
  44841. * * 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
  44842. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44843. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44844. * * When updating an instance, remember that only point positions can change, not the number of points
  44845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44847. * @param name defines the name of the new line system
  44848. * @param options defines the options used to create the line system
  44849. * @param scene defines the hosting scene
  44850. * @returns a new line mesh
  44851. */
  44852. static CreateLines(name: string, options: {
  44853. points: Vector3[];
  44854. updatable?: boolean;
  44855. instance?: Nullable<LinesMesh>;
  44856. colors?: Color4[];
  44857. useVertexAlpha?: boolean;
  44858. }, scene?: Nullable<Scene>): LinesMesh;
  44859. /**
  44860. * Creates a dashed line mesh
  44861. * * 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
  44862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44863. * * The parameter `points` is an array successive Vector3
  44864. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44865. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44866. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44867. * * 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
  44868. * * When updating an instance, remember that only point positions can change, not the number of points
  44869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44870. * @param name defines the name of the mesh
  44871. * @param options defines the options used to create the mesh
  44872. * @param scene defines the hosting scene
  44873. * @returns the dashed line mesh
  44874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44875. */
  44876. static CreateDashedLines(name: string, options: {
  44877. points: Vector3[];
  44878. dashSize?: number;
  44879. gapSize?: number;
  44880. dashNb?: number;
  44881. updatable?: boolean;
  44882. instance?: LinesMesh;
  44883. }, scene?: Nullable<Scene>): LinesMesh;
  44884. }
  44885. }
  44886. declare module "babylonjs/Debug/rayHelper" {
  44887. import { Nullable } from "babylonjs/types";
  44888. import { Ray } from "babylonjs/Culling/ray";
  44889. import { Vector3 } from "babylonjs/Maths/math.vector";
  44890. import { Color3 } from "babylonjs/Maths/math.color";
  44891. import { Scene } from "babylonjs/scene";
  44892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44893. import "babylonjs/Meshes/Builders/linesBuilder";
  44894. /**
  44895. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44896. * in order to better appreciate the issue one might have.
  44897. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44898. */
  44899. export class RayHelper {
  44900. /**
  44901. * Defines the ray we are currently tryin to visualize.
  44902. */
  44903. ray: Nullable<Ray>;
  44904. private _renderPoints;
  44905. private _renderLine;
  44906. private _renderFunction;
  44907. private _scene;
  44908. private _updateToMeshFunction;
  44909. private _attachedToMesh;
  44910. private _meshSpaceDirection;
  44911. private _meshSpaceOrigin;
  44912. /**
  44913. * Helper function to create a colored helper in a scene in one line.
  44914. * @param ray Defines the ray we are currently tryin to visualize
  44915. * @param scene Defines the scene the ray is used in
  44916. * @param color Defines the color we want to see the ray in
  44917. * @returns The newly created ray helper.
  44918. */
  44919. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44920. /**
  44921. * Instantiate a new ray helper.
  44922. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44923. * in order to better appreciate the issue one might have.
  44924. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44925. * @param ray Defines the ray we are currently tryin to visualize
  44926. */
  44927. constructor(ray: Ray);
  44928. /**
  44929. * Shows the ray we are willing to debug.
  44930. * @param scene Defines the scene the ray needs to be rendered in
  44931. * @param color Defines the color the ray needs to be rendered in
  44932. */
  44933. show(scene: Scene, color?: Color3): void;
  44934. /**
  44935. * Hides the ray we are debugging.
  44936. */
  44937. hide(): void;
  44938. private _render;
  44939. /**
  44940. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44941. * @param mesh Defines the mesh we want the helper attached to
  44942. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44943. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44944. * @param length Defines the length of the ray
  44945. */
  44946. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44947. /**
  44948. * Detach the ray helper from the mesh it has previously been attached to.
  44949. */
  44950. detachFromMesh(): void;
  44951. private _updateToMesh;
  44952. /**
  44953. * Dispose the helper and release its associated resources.
  44954. */
  44955. dispose(): void;
  44956. }
  44957. }
  44958. declare module "babylonjs/Debug/skeletonViewer" {
  44959. import { Color3 } from "babylonjs/Maths/math.color";
  44960. import { Scene } from "babylonjs/scene";
  44961. import { Nullable } from "babylonjs/types";
  44962. import { Skeleton } from "babylonjs/Bones/skeleton";
  44963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44964. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44965. /**
  44966. * Class used to render a debug view of a given skeleton
  44967. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44968. */
  44969. export class SkeletonViewer {
  44970. /** defines the skeleton to render */
  44971. skeleton: Skeleton;
  44972. /** defines the mesh attached to the skeleton */
  44973. mesh: AbstractMesh;
  44974. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44975. autoUpdateBonesMatrices: boolean;
  44976. /** defines the rendering group id to use with the viewer */
  44977. renderingGroupId: number;
  44978. /** Gets or sets the color used to render the skeleton */
  44979. color: Color3;
  44980. private _scene;
  44981. private _debugLines;
  44982. private _debugMesh;
  44983. private _isEnabled;
  44984. private _renderFunction;
  44985. private _utilityLayer;
  44986. /**
  44987. * Returns the mesh used to render the bones
  44988. */
  44989. readonly debugMesh: Nullable<LinesMesh>;
  44990. /**
  44991. * Creates a new SkeletonViewer
  44992. * @param skeleton defines the skeleton to render
  44993. * @param mesh defines the mesh attached to the skeleton
  44994. * @param scene defines the hosting scene
  44995. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44996. * @param renderingGroupId defines the rendering group id to use with the viewer
  44997. */
  44998. constructor(
  44999. /** defines the skeleton to render */
  45000. skeleton: Skeleton,
  45001. /** defines the mesh attached to the skeleton */
  45002. mesh: AbstractMesh, scene: Scene,
  45003. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45004. autoUpdateBonesMatrices?: boolean,
  45005. /** defines the rendering group id to use with the viewer */
  45006. renderingGroupId?: number);
  45007. /** Gets or sets a boolean indicating if the viewer is enabled */
  45008. isEnabled: boolean;
  45009. private _getBonePosition;
  45010. private _getLinesForBonesWithLength;
  45011. private _getLinesForBonesNoLength;
  45012. /** Update the viewer to sync with current skeleton state */
  45013. update(): void;
  45014. /** Release associated resources */
  45015. dispose(): void;
  45016. }
  45017. }
  45018. declare module "babylonjs/Debug/index" {
  45019. export * from "babylonjs/Debug/axesViewer";
  45020. export * from "babylonjs/Debug/boneAxesViewer";
  45021. export * from "babylonjs/Debug/debugLayer";
  45022. export * from "babylonjs/Debug/physicsViewer";
  45023. export * from "babylonjs/Debug/rayHelper";
  45024. export * from "babylonjs/Debug/skeletonViewer";
  45025. }
  45026. declare module "babylonjs/Engines/nullEngine" {
  45027. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45028. import { Scene } from "babylonjs/scene";
  45029. import { Engine } from "babylonjs/Engines/engine";
  45030. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45031. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45033. import { Effect } from "babylonjs/Materials/effect";
  45034. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45035. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45036. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45037. /**
  45038. * Options to create the null engine
  45039. */
  45040. export class NullEngineOptions {
  45041. /**
  45042. * Render width (Default: 512)
  45043. */
  45044. renderWidth: number;
  45045. /**
  45046. * Render height (Default: 256)
  45047. */
  45048. renderHeight: number;
  45049. /**
  45050. * Texture size (Default: 512)
  45051. */
  45052. textureSize: number;
  45053. /**
  45054. * If delta time between frames should be constant
  45055. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45056. */
  45057. deterministicLockstep: boolean;
  45058. /**
  45059. * Maximum about of steps between frames (Default: 4)
  45060. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45061. */
  45062. lockstepMaxSteps: number;
  45063. }
  45064. /**
  45065. * The null engine class provides support for headless version of babylon.js.
  45066. * This can be used in server side scenario or for testing purposes
  45067. */
  45068. export class NullEngine extends Engine {
  45069. private _options;
  45070. /**
  45071. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45072. */
  45073. isDeterministicLockStep(): boolean;
  45074. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45075. getLockstepMaxSteps(): number;
  45076. /**
  45077. * Sets hardware scaling, used to save performance if needed
  45078. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45079. */
  45080. getHardwareScalingLevel(): number;
  45081. constructor(options?: NullEngineOptions);
  45082. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45083. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45084. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45085. getRenderWidth(useScreen?: boolean): number;
  45086. getRenderHeight(useScreen?: boolean): number;
  45087. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45088. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45089. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45090. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45091. bindSamplers(effect: Effect): void;
  45092. enableEffect(effect: Effect): void;
  45093. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45094. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45095. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45096. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45097. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45098. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45099. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45100. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45101. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45102. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45103. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45104. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45105. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45106. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45107. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45108. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45109. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45110. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45111. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45112. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45113. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45114. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45115. bindBuffers(vertexBuffers: {
  45116. [key: string]: VertexBuffer;
  45117. }, indexBuffer: DataBuffer, effect: Effect): void;
  45118. wipeCaches(bruteForce?: boolean): void;
  45119. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45120. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45121. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45122. /** @hidden */
  45123. _createTexture(): WebGLTexture;
  45124. /** @hidden */
  45125. _releaseTexture(texture: InternalTexture): void;
  45126. 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;
  45127. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45128. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45129. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45130. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45131. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45132. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45133. areAllEffectsReady(): boolean;
  45134. /**
  45135. * @hidden
  45136. * Get the current error code of the webGL context
  45137. * @returns the error code
  45138. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45139. */
  45140. getError(): number;
  45141. /** @hidden */
  45142. _getUnpackAlignement(): number;
  45143. /** @hidden */
  45144. _unpackFlipY(value: boolean): void;
  45145. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45146. /**
  45147. * Updates a dynamic vertex buffer.
  45148. * @param vertexBuffer the vertex buffer to update
  45149. * @param data the data used to update the vertex buffer
  45150. * @param byteOffset the byte offset of the data (optional)
  45151. * @param byteLength the byte length of the data (optional)
  45152. */
  45153. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45154. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45155. /** @hidden */
  45156. _bindTexture(channel: number, texture: InternalTexture): void;
  45157. /** @hidden */
  45158. _releaseBuffer(buffer: DataBuffer): boolean;
  45159. releaseEffects(): void;
  45160. displayLoadingUI(): void;
  45161. hideLoadingUI(): void;
  45162. /** @hidden */
  45163. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45164. /** @hidden */
  45165. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45166. /** @hidden */
  45167. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45168. /** @hidden */
  45169. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45170. }
  45171. }
  45172. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45173. import { Nullable, int } from "babylonjs/types";
  45174. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45175. /** @hidden */
  45176. export class _OcclusionDataStorage {
  45177. /** @hidden */
  45178. occlusionInternalRetryCounter: number;
  45179. /** @hidden */
  45180. isOcclusionQueryInProgress: boolean;
  45181. /** @hidden */
  45182. isOccluded: boolean;
  45183. /** @hidden */
  45184. occlusionRetryCount: number;
  45185. /** @hidden */
  45186. occlusionType: number;
  45187. /** @hidden */
  45188. occlusionQueryAlgorithmType: number;
  45189. }
  45190. module "babylonjs/Engines/engine" {
  45191. interface Engine {
  45192. /**
  45193. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45194. * @return the new query
  45195. */
  45196. createQuery(): WebGLQuery;
  45197. /**
  45198. * Delete and release a webGL query
  45199. * @param query defines the query to delete
  45200. * @return the current engine
  45201. */
  45202. deleteQuery(query: WebGLQuery): Engine;
  45203. /**
  45204. * Check if a given query has resolved and got its value
  45205. * @param query defines the query to check
  45206. * @returns true if the query got its value
  45207. */
  45208. isQueryResultAvailable(query: WebGLQuery): boolean;
  45209. /**
  45210. * Gets the value of a given query
  45211. * @param query defines the query to check
  45212. * @returns the value of the query
  45213. */
  45214. getQueryResult(query: WebGLQuery): number;
  45215. /**
  45216. * Initiates an occlusion query
  45217. * @param algorithmType defines the algorithm to use
  45218. * @param query defines the query to use
  45219. * @returns the current engine
  45220. * @see http://doc.babylonjs.com/features/occlusionquery
  45221. */
  45222. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45223. /**
  45224. * Ends an occlusion query
  45225. * @see http://doc.babylonjs.com/features/occlusionquery
  45226. * @param algorithmType defines the algorithm to use
  45227. * @returns the current engine
  45228. */
  45229. endOcclusionQuery(algorithmType: number): Engine;
  45230. /**
  45231. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45232. * Please note that only one query can be issued at a time
  45233. * @returns a time token used to track the time span
  45234. */
  45235. startTimeQuery(): Nullable<_TimeToken>;
  45236. /**
  45237. * Ends a time query
  45238. * @param token defines the token used to measure the time span
  45239. * @returns the time spent (in ns)
  45240. */
  45241. endTimeQuery(token: _TimeToken): int;
  45242. /** @hidden */
  45243. _currentNonTimestampToken: Nullable<_TimeToken>;
  45244. /** @hidden */
  45245. _createTimeQuery(): WebGLQuery;
  45246. /** @hidden */
  45247. _deleteTimeQuery(query: WebGLQuery): void;
  45248. /** @hidden */
  45249. _getGlAlgorithmType(algorithmType: number): number;
  45250. /** @hidden */
  45251. _getTimeQueryResult(query: WebGLQuery): any;
  45252. /** @hidden */
  45253. _getTimeQueryAvailability(query: WebGLQuery): any;
  45254. }
  45255. }
  45256. module "babylonjs/Meshes/abstractMesh" {
  45257. interface AbstractMesh {
  45258. /**
  45259. * Backing filed
  45260. * @hidden
  45261. */
  45262. __occlusionDataStorage: _OcclusionDataStorage;
  45263. /**
  45264. * Access property
  45265. * @hidden
  45266. */
  45267. _occlusionDataStorage: _OcclusionDataStorage;
  45268. /**
  45269. * 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.
  45270. * The default value is -1 which means don't break the query and wait till the result
  45271. * @see http://doc.babylonjs.com/features/occlusionquery
  45272. */
  45273. occlusionRetryCount: number;
  45274. /**
  45275. * 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:
  45276. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45277. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45278. * * 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.
  45279. * @see http://doc.babylonjs.com/features/occlusionquery
  45280. */
  45281. occlusionType: number;
  45282. /**
  45283. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45284. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45285. * * 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.
  45286. * @see http://doc.babylonjs.com/features/occlusionquery
  45287. */
  45288. occlusionQueryAlgorithmType: number;
  45289. /**
  45290. * 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
  45291. * @see http://doc.babylonjs.com/features/occlusionquery
  45292. */
  45293. isOccluded: boolean;
  45294. /**
  45295. * Flag to check the progress status of the query
  45296. * @see http://doc.babylonjs.com/features/occlusionquery
  45297. */
  45298. isOcclusionQueryInProgress: boolean;
  45299. }
  45300. }
  45301. }
  45302. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45303. import { Nullable } from "babylonjs/types";
  45304. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45305. /** @hidden */
  45306. export var _forceTransformFeedbackToBundle: boolean;
  45307. module "babylonjs/Engines/engine" {
  45308. interface Engine {
  45309. /**
  45310. * Creates a webGL transform feedback object
  45311. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45312. * @returns the webGL transform feedback object
  45313. */
  45314. createTransformFeedback(): WebGLTransformFeedback;
  45315. /**
  45316. * Delete a webGL transform feedback object
  45317. * @param value defines the webGL transform feedback object to delete
  45318. */
  45319. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45320. /**
  45321. * Bind a webGL transform feedback object to the webgl context
  45322. * @param value defines the webGL transform feedback object to bind
  45323. */
  45324. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45325. /**
  45326. * Begins a transform feedback operation
  45327. * @param usePoints defines if points or triangles must be used
  45328. */
  45329. beginTransformFeedback(usePoints: boolean): void;
  45330. /**
  45331. * Ends a transform feedback operation
  45332. */
  45333. endTransformFeedback(): void;
  45334. /**
  45335. * Specify the varyings to use with transform feedback
  45336. * @param program defines the associated webGL program
  45337. * @param value defines the list of strings representing the varying names
  45338. */
  45339. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45340. /**
  45341. * Bind a webGL buffer for a transform feedback operation
  45342. * @param value defines the webGL buffer to bind
  45343. */
  45344. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45345. }
  45346. }
  45347. }
  45348. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45349. import { Scene } from "babylonjs/scene";
  45350. import { Engine } from "babylonjs/Engines/engine";
  45351. import { Texture } from "babylonjs/Materials/Textures/texture";
  45352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45353. import "babylonjs/Engines/Extensions/engine.multiRender";
  45354. /**
  45355. * Creation options of the multi render target texture.
  45356. */
  45357. export interface IMultiRenderTargetOptions {
  45358. /**
  45359. * Define if the texture needs to create mip maps after render.
  45360. */
  45361. generateMipMaps?: boolean;
  45362. /**
  45363. * Define the types of all the draw buffers we want to create
  45364. */
  45365. types?: number[];
  45366. /**
  45367. * Define the sampling modes of all the draw buffers we want to create
  45368. */
  45369. samplingModes?: number[];
  45370. /**
  45371. * Define if a depth buffer is required
  45372. */
  45373. generateDepthBuffer?: boolean;
  45374. /**
  45375. * Define if a stencil buffer is required
  45376. */
  45377. generateStencilBuffer?: boolean;
  45378. /**
  45379. * Define if a depth texture is required instead of a depth buffer
  45380. */
  45381. generateDepthTexture?: boolean;
  45382. /**
  45383. * Define the number of desired draw buffers
  45384. */
  45385. textureCount?: number;
  45386. /**
  45387. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45388. */
  45389. doNotChangeAspectRatio?: boolean;
  45390. /**
  45391. * Define the default type of the buffers we are creating
  45392. */
  45393. defaultType?: number;
  45394. }
  45395. /**
  45396. * A multi render target, like a render target provides the ability to render to a texture.
  45397. * Unlike the render target, it can render to several draw buffers in one draw.
  45398. * This is specially interesting in deferred rendering or for any effects requiring more than
  45399. * just one color from a single pass.
  45400. */
  45401. export class MultiRenderTarget extends RenderTargetTexture {
  45402. private _internalTextures;
  45403. private _textures;
  45404. private _multiRenderTargetOptions;
  45405. /**
  45406. * Get if draw buffers are currently supported by the used hardware and browser.
  45407. */
  45408. readonly isSupported: boolean;
  45409. /**
  45410. * Get the list of textures generated by the multi render target.
  45411. */
  45412. readonly textures: Texture[];
  45413. /**
  45414. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45415. */
  45416. readonly depthTexture: Texture;
  45417. /**
  45418. * Set the wrapping mode on U of all the textures we are rendering to.
  45419. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45420. */
  45421. wrapU: number;
  45422. /**
  45423. * Set the wrapping mode on V of all the textures we are rendering to.
  45424. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45425. */
  45426. wrapV: number;
  45427. /**
  45428. * Instantiate a new multi render target texture.
  45429. * A multi render target, like a render target provides the ability to render to a texture.
  45430. * Unlike the render target, it can render to several draw buffers in one draw.
  45431. * This is specially interesting in deferred rendering or for any effects requiring more than
  45432. * just one color from a single pass.
  45433. * @param name Define the name of the texture
  45434. * @param size Define the size of the buffers to render to
  45435. * @param count Define the number of target we are rendering into
  45436. * @param scene Define the scene the texture belongs to
  45437. * @param options Define the options used to create the multi render target
  45438. */
  45439. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45440. /** @hidden */
  45441. _rebuild(): void;
  45442. private _createInternalTextures;
  45443. private _createTextures;
  45444. /**
  45445. * Define the number of samples used if MSAA is enabled.
  45446. */
  45447. samples: number;
  45448. /**
  45449. * Resize all the textures in the multi render target.
  45450. * Be carrefull as it will recreate all the data in the new texture.
  45451. * @param size Define the new size
  45452. */
  45453. resize(size: any): void;
  45454. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45455. /**
  45456. * Dispose the render targets and their associated resources
  45457. */
  45458. dispose(): void;
  45459. /**
  45460. * Release all the underlying texture used as draw buffers.
  45461. */
  45462. releaseInternalTextures(): void;
  45463. }
  45464. }
  45465. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45466. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45467. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45468. import { Nullable } from "babylonjs/types";
  45469. module "babylonjs/Engines/engine" {
  45470. interface Engine {
  45471. /**
  45472. * Unbind a list of render target textures from the webGL context
  45473. * This is used only when drawBuffer extension or webGL2 are active
  45474. * @param textures defines the render target textures to unbind
  45475. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45476. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45477. */
  45478. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45479. /**
  45480. * Create a multi render target texture
  45481. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45482. * @param size defines the size of the texture
  45483. * @param options defines the creation options
  45484. * @returns the cube texture as an InternalTexture
  45485. */
  45486. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45487. /**
  45488. * Update the sample count for a given multiple render target texture
  45489. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45490. * @param textures defines the textures to update
  45491. * @param samples defines the sample count to set
  45492. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45493. */
  45494. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45495. }
  45496. }
  45497. }
  45498. declare module "babylonjs/Engines/Extensions/index" {
  45499. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45500. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45501. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45502. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45503. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45504. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45505. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45506. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45507. }
  45508. declare module "babylonjs/Engines/index" {
  45509. export * from "babylonjs/Engines/constants";
  45510. export * from "babylonjs/Engines/engine";
  45511. export * from "babylonjs/Engines/engineStore";
  45512. export * from "babylonjs/Engines/nullEngine";
  45513. export * from "babylonjs/Engines/Extensions/index";
  45514. export * from "babylonjs/Engines/IPipelineContext";
  45515. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45516. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45517. }
  45518. declare module "babylonjs/Events/clipboardEvents" {
  45519. /**
  45520. * Gather the list of clipboard event types as constants.
  45521. */
  45522. export class ClipboardEventTypes {
  45523. /**
  45524. * The clipboard event is fired when a copy command is active (pressed).
  45525. */
  45526. static readonly COPY: number;
  45527. /**
  45528. * The clipboard event is fired when a cut command is active (pressed).
  45529. */
  45530. static readonly CUT: number;
  45531. /**
  45532. * The clipboard event is fired when a paste command is active (pressed).
  45533. */
  45534. static readonly PASTE: number;
  45535. }
  45536. /**
  45537. * This class is used to store clipboard related info for the onClipboardObservable event.
  45538. */
  45539. export class ClipboardInfo {
  45540. /**
  45541. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45542. */
  45543. type: number;
  45544. /**
  45545. * Defines the related dom event
  45546. */
  45547. event: ClipboardEvent;
  45548. /**
  45549. *Creates an instance of ClipboardInfo.
  45550. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45551. * @param event Defines the related dom event
  45552. */
  45553. constructor(
  45554. /**
  45555. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45556. */
  45557. type: number,
  45558. /**
  45559. * Defines the related dom event
  45560. */
  45561. event: ClipboardEvent);
  45562. /**
  45563. * Get the clipboard event's type from the keycode.
  45564. * @param keyCode Defines the keyCode for the current keyboard event.
  45565. * @return {number}
  45566. */
  45567. static GetTypeFromCharacter(keyCode: number): number;
  45568. }
  45569. }
  45570. declare module "babylonjs/Events/index" {
  45571. export * from "babylonjs/Events/keyboardEvents";
  45572. export * from "babylonjs/Events/pointerEvents";
  45573. export * from "babylonjs/Events/clipboardEvents";
  45574. }
  45575. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45576. import { Scene } from "babylonjs/scene";
  45577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45578. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45579. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45580. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45581. /**
  45582. * Google Daydream controller
  45583. */
  45584. export class DaydreamController extends WebVRController {
  45585. /**
  45586. * Base Url for the controller model.
  45587. */
  45588. static MODEL_BASE_URL: string;
  45589. /**
  45590. * File name for the controller model.
  45591. */
  45592. static MODEL_FILENAME: string;
  45593. /**
  45594. * Gamepad Id prefix used to identify Daydream Controller.
  45595. */
  45596. static readonly GAMEPAD_ID_PREFIX: string;
  45597. /**
  45598. * Creates a new DaydreamController from a gamepad
  45599. * @param vrGamepad the gamepad that the controller should be created from
  45600. */
  45601. constructor(vrGamepad: any);
  45602. /**
  45603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45604. * @param scene scene in which to add meshes
  45605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45606. */
  45607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45608. /**
  45609. * Called once for each button that changed state since the last frame
  45610. * @param buttonIdx Which button index changed
  45611. * @param state New state of the button
  45612. * @param changes Which properties on the state changed since last frame
  45613. */
  45614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45615. }
  45616. }
  45617. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45618. import { Scene } from "babylonjs/scene";
  45619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45620. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45621. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45622. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45623. /**
  45624. * Gear VR Controller
  45625. */
  45626. export class GearVRController extends WebVRController {
  45627. /**
  45628. * Base Url for the controller model.
  45629. */
  45630. static MODEL_BASE_URL: string;
  45631. /**
  45632. * File name for the controller model.
  45633. */
  45634. static MODEL_FILENAME: string;
  45635. /**
  45636. * Gamepad Id prefix used to identify this controller.
  45637. */
  45638. static readonly GAMEPAD_ID_PREFIX: string;
  45639. private readonly _buttonIndexToObservableNameMap;
  45640. /**
  45641. * Creates a new GearVRController from a gamepad
  45642. * @param vrGamepad the gamepad that the controller should be created from
  45643. */
  45644. constructor(vrGamepad: any);
  45645. /**
  45646. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45647. * @param scene scene in which to add meshes
  45648. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45649. */
  45650. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45651. /**
  45652. * Called once for each button that changed state since the last frame
  45653. * @param buttonIdx Which button index changed
  45654. * @param state New state of the button
  45655. * @param changes Which properties on the state changed since last frame
  45656. */
  45657. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45658. }
  45659. }
  45660. declare module "babylonjs/Gamepads/Controllers/index" {
  45661. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45662. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45663. export * from "babylonjs/Gamepads/Controllers/genericController";
  45664. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45665. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45666. export * from "babylonjs/Gamepads/Controllers/viveController";
  45667. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45668. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45669. }
  45670. declare module "babylonjs/Gamepads/index" {
  45671. export * from "babylonjs/Gamepads/Controllers/index";
  45672. export * from "babylonjs/Gamepads/gamepad";
  45673. export * from "babylonjs/Gamepads/gamepadManager";
  45674. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45675. export * from "babylonjs/Gamepads/xboxGamepad";
  45676. export * from "babylonjs/Gamepads/dualShockGamepad";
  45677. }
  45678. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45679. import { Scene } from "babylonjs/scene";
  45680. import { Vector4 } from "babylonjs/Maths/math.vector";
  45681. import { Color4 } from "babylonjs/Maths/math.color";
  45682. import { Mesh } from "babylonjs/Meshes/mesh";
  45683. import { Nullable } from "babylonjs/types";
  45684. /**
  45685. * Class containing static functions to help procedurally build meshes
  45686. */
  45687. export class PolyhedronBuilder {
  45688. /**
  45689. * Creates a polyhedron mesh
  45690. * * 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
  45691. * * The parameter `size` (positive float, default 1) sets the polygon size
  45692. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45693. * * 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`
  45694. * * 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
  45695. * * 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)`)
  45696. * * 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
  45697. * * 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
  45698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45701. * @param name defines the name of the mesh
  45702. * @param options defines the options used to create the mesh
  45703. * @param scene defines the hosting scene
  45704. * @returns the polyhedron mesh
  45705. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45706. */
  45707. static CreatePolyhedron(name: string, options: {
  45708. type?: number;
  45709. size?: number;
  45710. sizeX?: number;
  45711. sizeY?: number;
  45712. sizeZ?: number;
  45713. custom?: any;
  45714. faceUV?: Vector4[];
  45715. faceColors?: Color4[];
  45716. flat?: boolean;
  45717. updatable?: boolean;
  45718. sideOrientation?: number;
  45719. frontUVs?: Vector4;
  45720. backUVs?: Vector4;
  45721. }, scene?: Nullable<Scene>): Mesh;
  45722. }
  45723. }
  45724. declare module "babylonjs/Gizmos/scaleGizmo" {
  45725. import { Observable } from "babylonjs/Misc/observable";
  45726. import { Nullable } from "babylonjs/types";
  45727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45728. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45729. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45730. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45731. /**
  45732. * Gizmo that enables scaling a mesh along 3 axis
  45733. */
  45734. export class ScaleGizmo extends Gizmo {
  45735. /**
  45736. * Internal gizmo used for interactions on the x axis
  45737. */
  45738. xGizmo: AxisScaleGizmo;
  45739. /**
  45740. * Internal gizmo used for interactions on the y axis
  45741. */
  45742. yGizmo: AxisScaleGizmo;
  45743. /**
  45744. * Internal gizmo used for interactions on the z axis
  45745. */
  45746. zGizmo: AxisScaleGizmo;
  45747. /**
  45748. * Internal gizmo used to scale all axis equally
  45749. */
  45750. uniformScaleGizmo: AxisScaleGizmo;
  45751. private _meshAttached;
  45752. private _updateGizmoRotationToMatchAttachedMesh;
  45753. private _snapDistance;
  45754. private _scaleRatio;
  45755. private _uniformScalingMesh;
  45756. private _octahedron;
  45757. /** Fires an event when any of it's sub gizmos are dragged */
  45758. onDragStartObservable: Observable<unknown>;
  45759. /** Fires an event when any of it's sub gizmos are released from dragging */
  45760. onDragEndObservable: Observable<unknown>;
  45761. attachedMesh: Nullable<AbstractMesh>;
  45762. /**
  45763. * Creates a ScaleGizmo
  45764. * @param gizmoLayer The utility layer the gizmo will be added to
  45765. */
  45766. constructor(gizmoLayer?: UtilityLayerRenderer);
  45767. updateGizmoRotationToMatchAttachedMesh: boolean;
  45768. /**
  45769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45770. */
  45771. snapDistance: number;
  45772. /**
  45773. * Ratio for the scale of the gizmo (Default: 1)
  45774. */
  45775. scaleRatio: number;
  45776. /**
  45777. * Disposes of the gizmo
  45778. */
  45779. dispose(): void;
  45780. }
  45781. }
  45782. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45783. import { Observable } from "babylonjs/Misc/observable";
  45784. import { Nullable } from "babylonjs/types";
  45785. import { Vector3 } from "babylonjs/Maths/math.vector";
  45786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45787. import { Mesh } from "babylonjs/Meshes/mesh";
  45788. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45789. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45790. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45791. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45792. import { Color3 } from "babylonjs/Maths/math.color";
  45793. /**
  45794. * Single axis scale gizmo
  45795. */
  45796. export class AxisScaleGizmo extends Gizmo {
  45797. /**
  45798. * Drag behavior responsible for the gizmos dragging interactions
  45799. */
  45800. dragBehavior: PointerDragBehavior;
  45801. private _pointerObserver;
  45802. /**
  45803. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45804. */
  45805. snapDistance: number;
  45806. /**
  45807. * Event that fires each time the gizmo snaps to a new location.
  45808. * * snapDistance is the the change in distance
  45809. */
  45810. onSnapObservable: Observable<{
  45811. snapDistance: number;
  45812. }>;
  45813. /**
  45814. * If the scaling operation should be done on all axis (default: false)
  45815. */
  45816. uniformScaling: boolean;
  45817. private _isEnabled;
  45818. private _parent;
  45819. private _arrow;
  45820. private _coloredMaterial;
  45821. private _hoverMaterial;
  45822. /**
  45823. * Creates an AxisScaleGizmo
  45824. * @param gizmoLayer The utility layer the gizmo will be added to
  45825. * @param dragAxis The axis which the gizmo will be able to scale on
  45826. * @param color The color of the gizmo
  45827. */
  45828. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45829. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45830. /**
  45831. * If the gizmo is enabled
  45832. */
  45833. isEnabled: boolean;
  45834. /**
  45835. * Disposes of the gizmo
  45836. */
  45837. dispose(): void;
  45838. /**
  45839. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45840. * @param mesh The mesh to replace the default mesh of the gizmo
  45841. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45842. */
  45843. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45844. }
  45845. }
  45846. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45847. import { Observable } from "babylonjs/Misc/observable";
  45848. import { Nullable } from "babylonjs/types";
  45849. import { Vector3 } from "babylonjs/Maths/math.vector";
  45850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45851. import { Mesh } from "babylonjs/Meshes/mesh";
  45852. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45853. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45854. import { Color3 } from "babylonjs/Maths/math.color";
  45855. import "babylonjs/Meshes/Builders/boxBuilder";
  45856. /**
  45857. * Bounding box gizmo
  45858. */
  45859. export class BoundingBoxGizmo extends Gizmo {
  45860. private _lineBoundingBox;
  45861. private _rotateSpheresParent;
  45862. private _scaleBoxesParent;
  45863. private _boundingDimensions;
  45864. private _renderObserver;
  45865. private _pointerObserver;
  45866. private _scaleDragSpeed;
  45867. private _tmpQuaternion;
  45868. private _tmpVector;
  45869. private _tmpRotationMatrix;
  45870. /**
  45871. * 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)
  45872. */
  45873. ignoreChildren: boolean;
  45874. /**
  45875. * 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)
  45876. */
  45877. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45878. /**
  45879. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45880. */
  45881. rotationSphereSize: number;
  45882. /**
  45883. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45884. */
  45885. scaleBoxSize: number;
  45886. /**
  45887. * 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)
  45888. */
  45889. fixedDragMeshScreenSize: boolean;
  45890. /**
  45891. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45892. */
  45893. fixedDragMeshScreenSizeDistanceFactor: number;
  45894. /**
  45895. * Fired when a rotation sphere or scale box is dragged
  45896. */
  45897. onDragStartObservable: Observable<{}>;
  45898. /**
  45899. * Fired when a scale box is dragged
  45900. */
  45901. onScaleBoxDragObservable: Observable<{}>;
  45902. /**
  45903. * Fired when a scale box drag is ended
  45904. */
  45905. onScaleBoxDragEndObservable: Observable<{}>;
  45906. /**
  45907. * Fired when a rotation sphere is dragged
  45908. */
  45909. onRotationSphereDragObservable: Observable<{}>;
  45910. /**
  45911. * Fired when a rotation sphere drag is ended
  45912. */
  45913. onRotationSphereDragEndObservable: Observable<{}>;
  45914. /**
  45915. * 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)
  45916. */
  45917. scalePivot: Nullable<Vector3>;
  45918. /**
  45919. * Mesh used as a pivot to rotate the attached mesh
  45920. */
  45921. private _anchorMesh;
  45922. private _existingMeshScale;
  45923. private _dragMesh;
  45924. private pointerDragBehavior;
  45925. private coloredMaterial;
  45926. private hoverColoredMaterial;
  45927. /**
  45928. * Sets the color of the bounding box gizmo
  45929. * @param color the color to set
  45930. */
  45931. setColor(color: Color3): void;
  45932. /**
  45933. * Creates an BoundingBoxGizmo
  45934. * @param gizmoLayer The utility layer the gizmo will be added to
  45935. * @param color The color of the gizmo
  45936. */
  45937. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45938. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45939. private _selectNode;
  45940. /**
  45941. * Updates the bounding box information for the Gizmo
  45942. */
  45943. updateBoundingBox(): void;
  45944. private _updateRotationSpheres;
  45945. private _updateScaleBoxes;
  45946. /**
  45947. * Enables rotation on the specified axis and disables rotation on the others
  45948. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45949. */
  45950. setEnabledRotationAxis(axis: string): void;
  45951. /**
  45952. * Enables/disables scaling
  45953. * @param enable if scaling should be enabled
  45954. */
  45955. setEnabledScaling(enable: boolean): void;
  45956. private _updateDummy;
  45957. /**
  45958. * Enables a pointer drag behavior on the bounding box of the gizmo
  45959. */
  45960. enableDragBehavior(): void;
  45961. /**
  45962. * Disposes of the gizmo
  45963. */
  45964. dispose(): void;
  45965. /**
  45966. * 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)
  45967. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45968. * @returns the bounding box mesh with the passed in mesh as a child
  45969. */
  45970. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45971. /**
  45972. * CustomMeshes are not supported by this gizmo
  45973. * @param mesh The mesh to replace the default mesh of the gizmo
  45974. */
  45975. setCustomMesh(mesh: Mesh): void;
  45976. }
  45977. }
  45978. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45979. import { Observable } from "babylonjs/Misc/observable";
  45980. import { Nullable } from "babylonjs/types";
  45981. import { Vector3 } from "babylonjs/Maths/math.vector";
  45982. import { Color3 } from "babylonjs/Maths/math.color";
  45983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45984. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45985. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45986. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45987. import "babylonjs/Meshes/Builders/linesBuilder";
  45988. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45989. /**
  45990. * Single plane rotation gizmo
  45991. */
  45992. export class PlaneRotationGizmo extends Gizmo {
  45993. /**
  45994. * Drag behavior responsible for the gizmos dragging interactions
  45995. */
  45996. dragBehavior: PointerDragBehavior;
  45997. private _pointerObserver;
  45998. /**
  45999. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46000. */
  46001. snapDistance: number;
  46002. /**
  46003. * Event that fires each time the gizmo snaps to a new location.
  46004. * * snapDistance is the the change in distance
  46005. */
  46006. onSnapObservable: Observable<{
  46007. snapDistance: number;
  46008. }>;
  46009. private _isEnabled;
  46010. private _parent;
  46011. /**
  46012. * Creates a PlaneRotationGizmo
  46013. * @param gizmoLayer The utility layer the gizmo will be added to
  46014. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46015. * @param color The color of the gizmo
  46016. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46017. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46018. */
  46019. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46020. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46021. /**
  46022. * If the gizmo is enabled
  46023. */
  46024. isEnabled: boolean;
  46025. /**
  46026. * Disposes of the gizmo
  46027. */
  46028. dispose(): void;
  46029. }
  46030. }
  46031. declare module "babylonjs/Gizmos/rotationGizmo" {
  46032. import { Observable } from "babylonjs/Misc/observable";
  46033. import { Nullable } from "babylonjs/types";
  46034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46035. import { Mesh } from "babylonjs/Meshes/mesh";
  46036. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46037. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46038. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46039. /**
  46040. * Gizmo that enables rotating a mesh along 3 axis
  46041. */
  46042. export class RotationGizmo extends Gizmo {
  46043. /**
  46044. * Internal gizmo used for interactions on the x axis
  46045. */
  46046. xGizmo: PlaneRotationGizmo;
  46047. /**
  46048. * Internal gizmo used for interactions on the y axis
  46049. */
  46050. yGizmo: PlaneRotationGizmo;
  46051. /**
  46052. * Internal gizmo used for interactions on the z axis
  46053. */
  46054. zGizmo: PlaneRotationGizmo;
  46055. /** Fires an event when any of it's sub gizmos are dragged */
  46056. onDragStartObservable: Observable<unknown>;
  46057. /** Fires an event when any of it's sub gizmos are released from dragging */
  46058. onDragEndObservable: Observable<unknown>;
  46059. private _meshAttached;
  46060. attachedMesh: Nullable<AbstractMesh>;
  46061. /**
  46062. * Creates a RotationGizmo
  46063. * @param gizmoLayer The utility layer the gizmo will be added to
  46064. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46065. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46066. */
  46067. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46068. updateGizmoRotationToMatchAttachedMesh: boolean;
  46069. /**
  46070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46071. */
  46072. snapDistance: number;
  46073. /**
  46074. * Ratio for the scale of the gizmo (Default: 1)
  46075. */
  46076. scaleRatio: number;
  46077. /**
  46078. * Disposes of the gizmo
  46079. */
  46080. dispose(): void;
  46081. /**
  46082. * CustomMeshes are not supported by this gizmo
  46083. * @param mesh The mesh to replace the default mesh of the gizmo
  46084. */
  46085. setCustomMesh(mesh: Mesh): void;
  46086. }
  46087. }
  46088. declare module "babylonjs/Gizmos/gizmoManager" {
  46089. import { Observable } from "babylonjs/Misc/observable";
  46090. import { Nullable } from "babylonjs/types";
  46091. import { Scene, IDisposable } from "babylonjs/scene";
  46092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46093. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46094. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46095. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46096. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46097. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46098. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46099. /**
  46100. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46101. */
  46102. export class GizmoManager implements IDisposable {
  46103. private scene;
  46104. /**
  46105. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46106. */
  46107. gizmos: {
  46108. positionGizmo: Nullable<PositionGizmo>;
  46109. rotationGizmo: Nullable<RotationGizmo>;
  46110. scaleGizmo: Nullable<ScaleGizmo>;
  46111. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46112. };
  46113. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46114. clearGizmoOnEmptyPointerEvent: boolean;
  46115. /** Fires an event when the manager is attached to a mesh */
  46116. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46117. private _gizmosEnabled;
  46118. private _pointerObserver;
  46119. private _attachedMesh;
  46120. private _boundingBoxColor;
  46121. private _defaultUtilityLayer;
  46122. private _defaultKeepDepthUtilityLayer;
  46123. /**
  46124. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46125. */
  46126. boundingBoxDragBehavior: SixDofDragBehavior;
  46127. /**
  46128. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46129. */
  46130. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46131. /**
  46132. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46133. */
  46134. usePointerToAttachGizmos: boolean;
  46135. /**
  46136. * Utility layer that the bounding box gizmo belongs to
  46137. */
  46138. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46139. /**
  46140. * Utility layer that all gizmos besides bounding box belong to
  46141. */
  46142. readonly utilityLayer: UtilityLayerRenderer;
  46143. /**
  46144. * Instatiates a gizmo manager
  46145. * @param scene the scene to overlay the gizmos on top of
  46146. */
  46147. constructor(scene: Scene);
  46148. /**
  46149. * Attaches a set of gizmos to the specified mesh
  46150. * @param mesh The mesh the gizmo's should be attached to
  46151. */
  46152. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46153. /**
  46154. * If the position gizmo is enabled
  46155. */
  46156. positionGizmoEnabled: boolean;
  46157. /**
  46158. * If the rotation gizmo is enabled
  46159. */
  46160. rotationGizmoEnabled: boolean;
  46161. /**
  46162. * If the scale gizmo is enabled
  46163. */
  46164. scaleGizmoEnabled: boolean;
  46165. /**
  46166. * If the boundingBox gizmo is enabled
  46167. */
  46168. boundingBoxGizmoEnabled: boolean;
  46169. /**
  46170. * Disposes of the gizmo manager
  46171. */
  46172. dispose(): void;
  46173. }
  46174. }
  46175. declare module "babylonjs/Lights/directionalLight" {
  46176. import { Camera } from "babylonjs/Cameras/camera";
  46177. import { Scene } from "babylonjs/scene";
  46178. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46180. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46181. import { Effect } from "babylonjs/Materials/effect";
  46182. /**
  46183. * A directional light is defined by a direction (what a surprise!).
  46184. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46185. * 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.
  46186. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46187. */
  46188. export class DirectionalLight extends ShadowLight {
  46189. private _shadowFrustumSize;
  46190. /**
  46191. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46192. */
  46193. /**
  46194. * Specifies a fix frustum size for the shadow generation.
  46195. */
  46196. shadowFrustumSize: number;
  46197. private _shadowOrthoScale;
  46198. /**
  46199. * Gets the shadow projection scale against the optimal computed one.
  46200. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46201. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46202. */
  46203. /**
  46204. * Sets the shadow projection scale against the optimal computed one.
  46205. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46206. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46207. */
  46208. shadowOrthoScale: number;
  46209. /**
  46210. * Automatically compute the projection matrix to best fit (including all the casters)
  46211. * on each frame.
  46212. */
  46213. autoUpdateExtends: boolean;
  46214. private _orthoLeft;
  46215. private _orthoRight;
  46216. private _orthoTop;
  46217. private _orthoBottom;
  46218. /**
  46219. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46220. * The directional light is emitted from everywhere in the given direction.
  46221. * It can cast shadows.
  46222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46223. * @param name The friendly name of the light
  46224. * @param direction The direction of the light
  46225. * @param scene The scene the light belongs to
  46226. */
  46227. constructor(name: string, direction: Vector3, scene: Scene);
  46228. /**
  46229. * Returns the string "DirectionalLight".
  46230. * @return The class name
  46231. */
  46232. getClassName(): string;
  46233. /**
  46234. * Returns the integer 1.
  46235. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46236. */
  46237. getTypeID(): number;
  46238. /**
  46239. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46240. * Returns the DirectionalLight Shadow projection matrix.
  46241. */
  46242. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46243. /**
  46244. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46245. * Returns the DirectionalLight Shadow projection matrix.
  46246. */
  46247. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46248. /**
  46249. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46250. * Returns the DirectionalLight Shadow projection matrix.
  46251. */
  46252. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46253. protected _buildUniformLayout(): void;
  46254. /**
  46255. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46256. * @param effect The effect to update
  46257. * @param lightIndex The index of the light in the effect to update
  46258. * @returns The directional light
  46259. */
  46260. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46261. /**
  46262. * Gets the minZ used for shadow according to both the scene and the light.
  46263. *
  46264. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46265. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46266. * @param activeCamera The camera we are returning the min for
  46267. * @returns the depth min z
  46268. */
  46269. getDepthMinZ(activeCamera: Camera): number;
  46270. /**
  46271. * Gets the maxZ used for shadow according to both the scene and the light.
  46272. *
  46273. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46274. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46275. * @param activeCamera The camera we are returning the max for
  46276. * @returns the depth max z
  46277. */
  46278. getDepthMaxZ(activeCamera: Camera): number;
  46279. /**
  46280. * Prepares the list of defines specific to the light type.
  46281. * @param defines the list of defines
  46282. * @param lightIndex defines the index of the light for the effect
  46283. */
  46284. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46285. }
  46286. }
  46287. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46288. import { Mesh } from "babylonjs/Meshes/mesh";
  46289. /**
  46290. * Class containing static functions to help procedurally build meshes
  46291. */
  46292. export class HemisphereBuilder {
  46293. /**
  46294. * Creates a hemisphere mesh
  46295. * @param name defines the name of the mesh
  46296. * @param options defines the options used to create the mesh
  46297. * @param scene defines the hosting scene
  46298. * @returns the hemisphere mesh
  46299. */
  46300. static CreateHemisphere(name: string, options: {
  46301. segments?: number;
  46302. diameter?: number;
  46303. sideOrientation?: number;
  46304. }, scene: any): Mesh;
  46305. }
  46306. }
  46307. declare module "babylonjs/Lights/spotLight" {
  46308. import { Nullable } from "babylonjs/types";
  46309. import { Scene } from "babylonjs/scene";
  46310. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46312. import { Effect } from "babylonjs/Materials/effect";
  46313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46314. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46315. /**
  46316. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46317. * These values define a cone of light starting from the position, emitting toward the direction.
  46318. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46319. * and the exponent defines the speed of the decay of the light with distance (reach).
  46320. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46321. */
  46322. export class SpotLight extends ShadowLight {
  46323. private _angle;
  46324. private _innerAngle;
  46325. private _cosHalfAngle;
  46326. private _lightAngleScale;
  46327. private _lightAngleOffset;
  46328. /**
  46329. * Gets the cone angle of the spot light in Radians.
  46330. */
  46331. /**
  46332. * Sets the cone angle of the spot light in Radians.
  46333. */
  46334. angle: number;
  46335. /**
  46336. * Only used in gltf falloff mode, this defines the angle where
  46337. * the directional falloff will start before cutting at angle which could be seen
  46338. * as outer angle.
  46339. */
  46340. /**
  46341. * Only used in gltf falloff mode, this defines the angle where
  46342. * the directional falloff will start before cutting at angle which could be seen
  46343. * as outer angle.
  46344. */
  46345. innerAngle: number;
  46346. private _shadowAngleScale;
  46347. /**
  46348. * Allows scaling the angle of the light for shadow generation only.
  46349. */
  46350. /**
  46351. * Allows scaling the angle of the light for shadow generation only.
  46352. */
  46353. shadowAngleScale: number;
  46354. /**
  46355. * The light decay speed with the distance from the emission spot.
  46356. */
  46357. exponent: number;
  46358. private _projectionTextureMatrix;
  46359. /**
  46360. * Allows reading the projecton texture
  46361. */
  46362. readonly projectionTextureMatrix: Matrix;
  46363. protected _projectionTextureLightNear: number;
  46364. /**
  46365. * Gets the near clip of the Spotlight for texture projection.
  46366. */
  46367. /**
  46368. * Sets the near clip of the Spotlight for texture projection.
  46369. */
  46370. projectionTextureLightNear: number;
  46371. protected _projectionTextureLightFar: number;
  46372. /**
  46373. * Gets the far clip of the Spotlight for texture projection.
  46374. */
  46375. /**
  46376. * Sets the far clip of the Spotlight for texture projection.
  46377. */
  46378. projectionTextureLightFar: number;
  46379. protected _projectionTextureUpDirection: Vector3;
  46380. /**
  46381. * Gets the Up vector of the Spotlight for texture projection.
  46382. */
  46383. /**
  46384. * Sets the Up vector of the Spotlight for texture projection.
  46385. */
  46386. projectionTextureUpDirection: Vector3;
  46387. private _projectionTexture;
  46388. /**
  46389. * Gets the projection texture of the light.
  46390. */
  46391. /**
  46392. * Sets the projection texture of the light.
  46393. */
  46394. projectionTexture: Nullable<BaseTexture>;
  46395. private _projectionTextureViewLightDirty;
  46396. private _projectionTextureProjectionLightDirty;
  46397. private _projectionTextureDirty;
  46398. private _projectionTextureViewTargetVector;
  46399. private _projectionTextureViewLightMatrix;
  46400. private _projectionTextureProjectionLightMatrix;
  46401. private _projectionTextureScalingMatrix;
  46402. /**
  46403. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46404. * It can cast shadows.
  46405. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46406. * @param name The light friendly name
  46407. * @param position The position of the spot light in the scene
  46408. * @param direction The direction of the light in the scene
  46409. * @param angle The cone angle of the light in Radians
  46410. * @param exponent The light decay speed with the distance from the emission spot
  46411. * @param scene The scene the lights belongs to
  46412. */
  46413. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46414. /**
  46415. * Returns the string "SpotLight".
  46416. * @returns the class name
  46417. */
  46418. getClassName(): string;
  46419. /**
  46420. * Returns the integer 2.
  46421. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46422. */
  46423. getTypeID(): number;
  46424. /**
  46425. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46426. */
  46427. protected _setDirection(value: Vector3): void;
  46428. /**
  46429. * Overrides the position setter to recompute the projection texture view light Matrix.
  46430. */
  46431. protected _setPosition(value: Vector3): void;
  46432. /**
  46433. * 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.
  46434. * Returns the SpotLight.
  46435. */
  46436. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46437. protected _computeProjectionTextureViewLightMatrix(): void;
  46438. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46439. /**
  46440. * Main function for light texture projection matrix computing.
  46441. */
  46442. protected _computeProjectionTextureMatrix(): void;
  46443. protected _buildUniformLayout(): void;
  46444. private _computeAngleValues;
  46445. /**
  46446. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46447. * @param effect The effect to update
  46448. * @param lightIndex The index of the light in the effect to update
  46449. * @returns The spot light
  46450. */
  46451. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46452. /**
  46453. * Disposes the light and the associated resources.
  46454. */
  46455. dispose(): void;
  46456. /**
  46457. * Prepares the list of defines specific to the light type.
  46458. * @param defines the list of defines
  46459. * @param lightIndex defines the index of the light for the effect
  46460. */
  46461. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46462. }
  46463. }
  46464. declare module "babylonjs/Gizmos/lightGizmo" {
  46465. import { Nullable } from "babylonjs/types";
  46466. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46467. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46468. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46469. import { Light } from "babylonjs/Lights/light";
  46470. /**
  46471. * Gizmo that enables viewing a light
  46472. */
  46473. export class LightGizmo extends Gizmo {
  46474. private _lightMesh;
  46475. private _material;
  46476. private cachedPosition;
  46477. private cachedForward;
  46478. /**
  46479. * Creates a LightGizmo
  46480. * @param gizmoLayer The utility layer the gizmo will be added to
  46481. */
  46482. constructor(gizmoLayer?: UtilityLayerRenderer);
  46483. private _light;
  46484. /**
  46485. * The light that the gizmo is attached to
  46486. */
  46487. light: Nullable<Light>;
  46488. /**
  46489. * Gets the material used to render the light gizmo
  46490. */
  46491. readonly material: StandardMaterial;
  46492. /**
  46493. * @hidden
  46494. * Updates the gizmo to match the attached mesh's position/rotation
  46495. */
  46496. protected _update(): void;
  46497. private static _Scale;
  46498. /**
  46499. * Creates the lines for a light mesh
  46500. */
  46501. private static _createLightLines;
  46502. /**
  46503. * Disposes of the light gizmo
  46504. */
  46505. dispose(): void;
  46506. private static _CreateHemisphericLightMesh;
  46507. private static _CreatePointLightMesh;
  46508. private static _CreateSpotLightMesh;
  46509. private static _CreateDirectionalLightMesh;
  46510. }
  46511. }
  46512. declare module "babylonjs/Gizmos/index" {
  46513. export * from "babylonjs/Gizmos/axisDragGizmo";
  46514. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46515. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46516. export * from "babylonjs/Gizmos/gizmo";
  46517. export * from "babylonjs/Gizmos/gizmoManager";
  46518. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46519. export * from "babylonjs/Gizmos/positionGizmo";
  46520. export * from "babylonjs/Gizmos/rotationGizmo";
  46521. export * from "babylonjs/Gizmos/scaleGizmo";
  46522. export * from "babylonjs/Gizmos/lightGizmo";
  46523. export * from "babylonjs/Gizmos/planeDragGizmo";
  46524. }
  46525. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46526. /** @hidden */
  46527. export var backgroundFragmentDeclaration: {
  46528. name: string;
  46529. shader: string;
  46530. };
  46531. }
  46532. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46533. /** @hidden */
  46534. export var backgroundUboDeclaration: {
  46535. name: string;
  46536. shader: string;
  46537. };
  46538. }
  46539. declare module "babylonjs/Shaders/background.fragment" {
  46540. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46541. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46542. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46543. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46544. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46545. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46546. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46547. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46548. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46549. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46550. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46551. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46552. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46553. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46554. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46555. /** @hidden */
  46556. export var backgroundPixelShader: {
  46557. name: string;
  46558. shader: string;
  46559. };
  46560. }
  46561. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46562. /** @hidden */
  46563. export var backgroundVertexDeclaration: {
  46564. name: string;
  46565. shader: string;
  46566. };
  46567. }
  46568. declare module "babylonjs/Shaders/background.vertex" {
  46569. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46570. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46572. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46573. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46574. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46575. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46576. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46577. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46578. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46579. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46580. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46581. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46582. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46583. /** @hidden */
  46584. export var backgroundVertexShader: {
  46585. name: string;
  46586. shader: string;
  46587. };
  46588. }
  46589. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46590. import { Nullable, int, float } from "babylonjs/types";
  46591. import { Scene } from "babylonjs/scene";
  46592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46595. import { Mesh } from "babylonjs/Meshes/mesh";
  46596. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46597. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46598. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46600. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46601. import { Color3 } from "babylonjs/Maths/math.color";
  46602. import "babylonjs/Shaders/background.fragment";
  46603. import "babylonjs/Shaders/background.vertex";
  46604. /**
  46605. * Background material used to create an efficient environement around your scene.
  46606. */
  46607. export class BackgroundMaterial extends PushMaterial {
  46608. /**
  46609. * Standard reflectance value at parallel view angle.
  46610. */
  46611. static StandardReflectance0: number;
  46612. /**
  46613. * Standard reflectance value at grazing angle.
  46614. */
  46615. static StandardReflectance90: number;
  46616. protected _primaryColor: Color3;
  46617. /**
  46618. * Key light Color (multiply against the environement texture)
  46619. */
  46620. primaryColor: Color3;
  46621. protected __perceptualColor: Nullable<Color3>;
  46622. /**
  46623. * Experimental Internal Use Only.
  46624. *
  46625. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46626. * This acts as a helper to set the primary color to a more "human friendly" value.
  46627. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46628. * output color as close as possible from the chosen value.
  46629. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46630. * part of lighting setup.)
  46631. */
  46632. _perceptualColor: Nullable<Color3>;
  46633. protected _primaryColorShadowLevel: float;
  46634. /**
  46635. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46636. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46637. */
  46638. primaryColorShadowLevel: float;
  46639. protected _primaryColorHighlightLevel: float;
  46640. /**
  46641. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46642. * The primary color is used at the level chosen to define what the white area would look.
  46643. */
  46644. primaryColorHighlightLevel: float;
  46645. protected _reflectionTexture: Nullable<BaseTexture>;
  46646. /**
  46647. * Reflection Texture used in the material.
  46648. * Should be author in a specific way for the best result (refer to the documentation).
  46649. */
  46650. reflectionTexture: Nullable<BaseTexture>;
  46651. protected _reflectionBlur: float;
  46652. /**
  46653. * Reflection Texture level of blur.
  46654. *
  46655. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46656. * texture twice.
  46657. */
  46658. reflectionBlur: float;
  46659. protected _diffuseTexture: Nullable<BaseTexture>;
  46660. /**
  46661. * Diffuse Texture used in the material.
  46662. * Should be author in a specific way for the best result (refer to the documentation).
  46663. */
  46664. diffuseTexture: Nullable<BaseTexture>;
  46665. protected _shadowLights: Nullable<IShadowLight[]>;
  46666. /**
  46667. * Specify the list of lights casting shadow on the material.
  46668. * All scene shadow lights will be included if null.
  46669. */
  46670. shadowLights: Nullable<IShadowLight[]>;
  46671. protected _shadowLevel: float;
  46672. /**
  46673. * Helps adjusting the shadow to a softer level if required.
  46674. * 0 means black shadows and 1 means no shadows.
  46675. */
  46676. shadowLevel: float;
  46677. protected _sceneCenter: Vector3;
  46678. /**
  46679. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46680. * It is usually zero but might be interesting to modify according to your setup.
  46681. */
  46682. sceneCenter: Vector3;
  46683. protected _opacityFresnel: boolean;
  46684. /**
  46685. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46686. * This helps ensuring a nice transition when the camera goes under the ground.
  46687. */
  46688. opacityFresnel: boolean;
  46689. protected _reflectionFresnel: boolean;
  46690. /**
  46691. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46692. * This helps adding a mirror texture on the ground.
  46693. */
  46694. reflectionFresnel: boolean;
  46695. protected _reflectionFalloffDistance: number;
  46696. /**
  46697. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46698. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46699. */
  46700. reflectionFalloffDistance: number;
  46701. protected _reflectionAmount: number;
  46702. /**
  46703. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46704. */
  46705. reflectionAmount: number;
  46706. protected _reflectionReflectance0: number;
  46707. /**
  46708. * This specifies the weight of the reflection at grazing angle.
  46709. */
  46710. reflectionReflectance0: number;
  46711. protected _reflectionReflectance90: number;
  46712. /**
  46713. * This specifies the weight of the reflection at a perpendicular point of view.
  46714. */
  46715. reflectionReflectance90: number;
  46716. /**
  46717. * Sets the reflection reflectance fresnel values according to the default standard
  46718. * empirically know to work well :-)
  46719. */
  46720. reflectionStandardFresnelWeight: number;
  46721. protected _useRGBColor: boolean;
  46722. /**
  46723. * Helps to directly use the maps channels instead of their level.
  46724. */
  46725. useRGBColor: boolean;
  46726. protected _enableNoise: boolean;
  46727. /**
  46728. * This helps reducing the banding effect that could occur on the background.
  46729. */
  46730. enableNoise: boolean;
  46731. /**
  46732. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46733. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46734. * Recommended to be keep at 1.0 except for special cases.
  46735. */
  46736. fovMultiplier: number;
  46737. private _fovMultiplier;
  46738. /**
  46739. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46740. */
  46741. useEquirectangularFOV: boolean;
  46742. private _maxSimultaneousLights;
  46743. /**
  46744. * Number of Simultaneous lights allowed on the material.
  46745. */
  46746. maxSimultaneousLights: int;
  46747. /**
  46748. * Default configuration related to image processing available in the Background Material.
  46749. */
  46750. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46751. /**
  46752. * Keep track of the image processing observer to allow dispose and replace.
  46753. */
  46754. private _imageProcessingObserver;
  46755. /**
  46756. * Attaches a new image processing configuration to the PBR Material.
  46757. * @param configuration (if null the scene configuration will be use)
  46758. */
  46759. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46760. /**
  46761. * Gets the image processing configuration used either in this material.
  46762. */
  46763. /**
  46764. * Sets the Default image processing configuration used either in the this material.
  46765. *
  46766. * If sets to null, the scene one is in use.
  46767. */
  46768. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46769. /**
  46770. * Gets wether the color curves effect is enabled.
  46771. */
  46772. /**
  46773. * Sets wether the color curves effect is enabled.
  46774. */
  46775. cameraColorCurvesEnabled: boolean;
  46776. /**
  46777. * Gets wether the color grading effect is enabled.
  46778. */
  46779. /**
  46780. * Gets wether the color grading effect is enabled.
  46781. */
  46782. cameraColorGradingEnabled: boolean;
  46783. /**
  46784. * Gets wether tonemapping is enabled or not.
  46785. */
  46786. /**
  46787. * Sets wether tonemapping is enabled or not
  46788. */
  46789. cameraToneMappingEnabled: boolean;
  46790. /**
  46791. * The camera exposure used on this material.
  46792. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46793. * This corresponds to a photographic exposure.
  46794. */
  46795. /**
  46796. * The camera exposure used on this material.
  46797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46798. * This corresponds to a photographic exposure.
  46799. */
  46800. cameraExposure: float;
  46801. /**
  46802. * Gets The camera contrast used on this material.
  46803. */
  46804. /**
  46805. * Sets The camera contrast used on this material.
  46806. */
  46807. cameraContrast: float;
  46808. /**
  46809. * Gets the Color Grading 2D Lookup Texture.
  46810. */
  46811. /**
  46812. * Sets the Color Grading 2D Lookup Texture.
  46813. */
  46814. cameraColorGradingTexture: Nullable<BaseTexture>;
  46815. /**
  46816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46818. * 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;
  46819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46820. */
  46821. /**
  46822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46824. * 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;
  46825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46826. */
  46827. cameraColorCurves: Nullable<ColorCurves>;
  46828. /**
  46829. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46830. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46831. */
  46832. switchToBGR: boolean;
  46833. private _renderTargets;
  46834. private _reflectionControls;
  46835. private _white;
  46836. private _primaryShadowColor;
  46837. private _primaryHighlightColor;
  46838. /**
  46839. * Instantiates a Background Material in the given scene
  46840. * @param name The friendly name of the material
  46841. * @param scene The scene to add the material to
  46842. */
  46843. constructor(name: string, scene: Scene);
  46844. /**
  46845. * Gets a boolean indicating that current material needs to register RTT
  46846. */
  46847. readonly hasRenderTargetTextures: boolean;
  46848. /**
  46849. * The entire material has been created in order to prevent overdraw.
  46850. * @returns false
  46851. */
  46852. needAlphaTesting(): boolean;
  46853. /**
  46854. * The entire material has been created in order to prevent overdraw.
  46855. * @returns true if blending is enable
  46856. */
  46857. needAlphaBlending(): boolean;
  46858. /**
  46859. * Checks wether the material is ready to be rendered for a given mesh.
  46860. * @param mesh The mesh to render
  46861. * @param subMesh The submesh to check against
  46862. * @param useInstances Specify wether or not the material is used with instances
  46863. * @returns true if all the dependencies are ready (Textures, Effects...)
  46864. */
  46865. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46866. /**
  46867. * Compute the primary color according to the chosen perceptual color.
  46868. */
  46869. private _computePrimaryColorFromPerceptualColor;
  46870. /**
  46871. * Compute the highlights and shadow colors according to their chosen levels.
  46872. */
  46873. private _computePrimaryColors;
  46874. /**
  46875. * Build the uniform buffer used in the material.
  46876. */
  46877. buildUniformLayout(): void;
  46878. /**
  46879. * Unbind the material.
  46880. */
  46881. unbind(): void;
  46882. /**
  46883. * Bind only the world matrix to the material.
  46884. * @param world The world matrix to bind.
  46885. */
  46886. bindOnlyWorldMatrix(world: Matrix): void;
  46887. /**
  46888. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46889. * @param world The world matrix to bind.
  46890. * @param subMesh The submesh to bind for.
  46891. */
  46892. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46893. /**
  46894. * Checks to see if a texture is used in the material.
  46895. * @param texture - Base texture to use.
  46896. * @returns - Boolean specifying if a texture is used in the material.
  46897. */
  46898. hasTexture(texture: BaseTexture): boolean;
  46899. /**
  46900. * Dispose the material.
  46901. * @param forceDisposeEffect Force disposal of the associated effect.
  46902. * @param forceDisposeTextures Force disposal of the associated textures.
  46903. */
  46904. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46905. /**
  46906. * Clones the material.
  46907. * @param name The cloned name.
  46908. * @returns The cloned material.
  46909. */
  46910. clone(name: string): BackgroundMaterial;
  46911. /**
  46912. * Serializes the current material to its JSON representation.
  46913. * @returns The JSON representation.
  46914. */
  46915. serialize(): any;
  46916. /**
  46917. * Gets the class name of the material
  46918. * @returns "BackgroundMaterial"
  46919. */
  46920. getClassName(): string;
  46921. /**
  46922. * Parse a JSON input to create back a background material.
  46923. * @param source The JSON data to parse
  46924. * @param scene The scene to create the parsed material in
  46925. * @param rootUrl The root url of the assets the material depends upon
  46926. * @returns the instantiated BackgroundMaterial.
  46927. */
  46928. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46929. }
  46930. }
  46931. declare module "babylonjs/Helpers/environmentHelper" {
  46932. import { Observable } from "babylonjs/Misc/observable";
  46933. import { Nullable } from "babylonjs/types";
  46934. import { Scene } from "babylonjs/scene";
  46935. import { Vector3 } from "babylonjs/Maths/math.vector";
  46936. import { Color3 } from "babylonjs/Maths/math.color";
  46937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46938. import { Mesh } from "babylonjs/Meshes/mesh";
  46939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46940. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46941. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46942. import "babylonjs/Meshes/Builders/planeBuilder";
  46943. import "babylonjs/Meshes/Builders/boxBuilder";
  46944. /**
  46945. * Represents the different options available during the creation of
  46946. * a Environment helper.
  46947. *
  46948. * This can control the default ground, skybox and image processing setup of your scene.
  46949. */
  46950. export interface IEnvironmentHelperOptions {
  46951. /**
  46952. * Specifies wether or not to create a ground.
  46953. * True by default.
  46954. */
  46955. createGround: boolean;
  46956. /**
  46957. * Specifies the ground size.
  46958. * 15 by default.
  46959. */
  46960. groundSize: number;
  46961. /**
  46962. * The texture used on the ground for the main color.
  46963. * Comes from the BabylonJS CDN by default.
  46964. *
  46965. * Remarks: Can be either a texture or a url.
  46966. */
  46967. groundTexture: string | BaseTexture;
  46968. /**
  46969. * The color mixed in the ground texture by default.
  46970. * BabylonJS clearColor by default.
  46971. */
  46972. groundColor: Color3;
  46973. /**
  46974. * Specifies the ground opacity.
  46975. * 1 by default.
  46976. */
  46977. groundOpacity: number;
  46978. /**
  46979. * Enables the ground to receive shadows.
  46980. * True by default.
  46981. */
  46982. enableGroundShadow: boolean;
  46983. /**
  46984. * Helps preventing the shadow to be fully black on the ground.
  46985. * 0.5 by default.
  46986. */
  46987. groundShadowLevel: number;
  46988. /**
  46989. * Creates a mirror texture attach to the ground.
  46990. * false by default.
  46991. */
  46992. enableGroundMirror: boolean;
  46993. /**
  46994. * Specifies the ground mirror size ratio.
  46995. * 0.3 by default as the default kernel is 64.
  46996. */
  46997. groundMirrorSizeRatio: number;
  46998. /**
  46999. * Specifies the ground mirror blur kernel size.
  47000. * 64 by default.
  47001. */
  47002. groundMirrorBlurKernel: number;
  47003. /**
  47004. * Specifies the ground mirror visibility amount.
  47005. * 1 by default
  47006. */
  47007. groundMirrorAmount: number;
  47008. /**
  47009. * Specifies the ground mirror reflectance weight.
  47010. * This uses the standard weight of the background material to setup the fresnel effect
  47011. * of the mirror.
  47012. * 1 by default.
  47013. */
  47014. groundMirrorFresnelWeight: number;
  47015. /**
  47016. * Specifies the ground mirror Falloff distance.
  47017. * This can helps reducing the size of the reflection.
  47018. * 0 by Default.
  47019. */
  47020. groundMirrorFallOffDistance: number;
  47021. /**
  47022. * Specifies the ground mirror texture type.
  47023. * Unsigned Int by Default.
  47024. */
  47025. groundMirrorTextureType: number;
  47026. /**
  47027. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47028. * the shown objects.
  47029. */
  47030. groundYBias: number;
  47031. /**
  47032. * Specifies wether or not to create a skybox.
  47033. * True by default.
  47034. */
  47035. createSkybox: boolean;
  47036. /**
  47037. * Specifies the skybox size.
  47038. * 20 by default.
  47039. */
  47040. skyboxSize: number;
  47041. /**
  47042. * The texture used on the skybox for the main color.
  47043. * Comes from the BabylonJS CDN by default.
  47044. *
  47045. * Remarks: Can be either a texture or a url.
  47046. */
  47047. skyboxTexture: string | BaseTexture;
  47048. /**
  47049. * The color mixed in the skybox texture by default.
  47050. * BabylonJS clearColor by default.
  47051. */
  47052. skyboxColor: Color3;
  47053. /**
  47054. * The background rotation around the Y axis of the scene.
  47055. * This helps aligning the key lights of your scene with the background.
  47056. * 0 by default.
  47057. */
  47058. backgroundYRotation: number;
  47059. /**
  47060. * Compute automatically the size of the elements to best fit with the scene.
  47061. */
  47062. sizeAuto: boolean;
  47063. /**
  47064. * Default position of the rootMesh if autoSize is not true.
  47065. */
  47066. rootPosition: Vector3;
  47067. /**
  47068. * Sets up the image processing in the scene.
  47069. * true by default.
  47070. */
  47071. setupImageProcessing: boolean;
  47072. /**
  47073. * The texture used as your environment texture in the scene.
  47074. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47075. *
  47076. * Remarks: Can be either a texture or a url.
  47077. */
  47078. environmentTexture: string | BaseTexture;
  47079. /**
  47080. * The value of the exposure to apply to the scene.
  47081. * 0.6 by default if setupImageProcessing is true.
  47082. */
  47083. cameraExposure: number;
  47084. /**
  47085. * The value of the contrast to apply to the scene.
  47086. * 1.6 by default if setupImageProcessing is true.
  47087. */
  47088. cameraContrast: number;
  47089. /**
  47090. * Specifies wether or not tonemapping should be enabled in the scene.
  47091. * true by default if setupImageProcessing is true.
  47092. */
  47093. toneMappingEnabled: boolean;
  47094. }
  47095. /**
  47096. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47097. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47098. * It also helps with the default setup of your imageProcessing configuration.
  47099. */
  47100. export class EnvironmentHelper {
  47101. /**
  47102. * Default ground texture URL.
  47103. */
  47104. private static _groundTextureCDNUrl;
  47105. /**
  47106. * Default skybox texture URL.
  47107. */
  47108. private static _skyboxTextureCDNUrl;
  47109. /**
  47110. * Default environment texture URL.
  47111. */
  47112. private static _environmentTextureCDNUrl;
  47113. /**
  47114. * Creates the default options for the helper.
  47115. */
  47116. private static _getDefaultOptions;
  47117. private _rootMesh;
  47118. /**
  47119. * Gets the root mesh created by the helper.
  47120. */
  47121. readonly rootMesh: Mesh;
  47122. private _skybox;
  47123. /**
  47124. * Gets the skybox created by the helper.
  47125. */
  47126. readonly skybox: Nullable<Mesh>;
  47127. private _skyboxTexture;
  47128. /**
  47129. * Gets the skybox texture created by the helper.
  47130. */
  47131. readonly skyboxTexture: Nullable<BaseTexture>;
  47132. private _skyboxMaterial;
  47133. /**
  47134. * Gets the skybox material created by the helper.
  47135. */
  47136. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47137. private _ground;
  47138. /**
  47139. * Gets the ground mesh created by the helper.
  47140. */
  47141. readonly ground: Nullable<Mesh>;
  47142. private _groundTexture;
  47143. /**
  47144. * Gets the ground texture created by the helper.
  47145. */
  47146. readonly groundTexture: Nullable<BaseTexture>;
  47147. private _groundMirror;
  47148. /**
  47149. * Gets the ground mirror created by the helper.
  47150. */
  47151. readonly groundMirror: Nullable<MirrorTexture>;
  47152. /**
  47153. * Gets the ground mirror render list to helps pushing the meshes
  47154. * you wish in the ground reflection.
  47155. */
  47156. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47157. private _groundMaterial;
  47158. /**
  47159. * Gets the ground material created by the helper.
  47160. */
  47161. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47162. /**
  47163. * Stores the creation options.
  47164. */
  47165. private readonly _scene;
  47166. private _options;
  47167. /**
  47168. * This observable will be notified with any error during the creation of the environment,
  47169. * mainly texture creation errors.
  47170. */
  47171. onErrorObservable: Observable<{
  47172. message?: string;
  47173. exception?: any;
  47174. }>;
  47175. /**
  47176. * constructor
  47177. * @param options Defines the options we want to customize the helper
  47178. * @param scene The scene to add the material to
  47179. */
  47180. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47181. /**
  47182. * Updates the background according to the new options
  47183. * @param options
  47184. */
  47185. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47186. /**
  47187. * Sets the primary color of all the available elements.
  47188. * @param color the main color to affect to the ground and the background
  47189. */
  47190. setMainColor(color: Color3): void;
  47191. /**
  47192. * Setup the image processing according to the specified options.
  47193. */
  47194. private _setupImageProcessing;
  47195. /**
  47196. * Setup the environment texture according to the specified options.
  47197. */
  47198. private _setupEnvironmentTexture;
  47199. /**
  47200. * Setup the background according to the specified options.
  47201. */
  47202. private _setupBackground;
  47203. /**
  47204. * Get the scene sizes according to the setup.
  47205. */
  47206. private _getSceneSize;
  47207. /**
  47208. * Setup the ground according to the specified options.
  47209. */
  47210. private _setupGround;
  47211. /**
  47212. * Setup the ground material according to the specified options.
  47213. */
  47214. private _setupGroundMaterial;
  47215. /**
  47216. * Setup the ground diffuse texture according to the specified options.
  47217. */
  47218. private _setupGroundDiffuseTexture;
  47219. /**
  47220. * Setup the ground mirror texture according to the specified options.
  47221. */
  47222. private _setupGroundMirrorTexture;
  47223. /**
  47224. * Setup the ground to receive the mirror texture.
  47225. */
  47226. private _setupMirrorInGroundMaterial;
  47227. /**
  47228. * Setup the skybox according to the specified options.
  47229. */
  47230. private _setupSkybox;
  47231. /**
  47232. * Setup the skybox material according to the specified options.
  47233. */
  47234. private _setupSkyboxMaterial;
  47235. /**
  47236. * Setup the skybox reflection texture according to the specified options.
  47237. */
  47238. private _setupSkyboxReflectionTexture;
  47239. private _errorHandler;
  47240. /**
  47241. * Dispose all the elements created by the Helper.
  47242. */
  47243. dispose(): void;
  47244. }
  47245. }
  47246. declare module "babylonjs/Helpers/photoDome" {
  47247. import { Observable } from "babylonjs/Misc/observable";
  47248. import { Nullable } from "babylonjs/types";
  47249. import { Scene } from "babylonjs/scene";
  47250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47251. import { Mesh } from "babylonjs/Meshes/mesh";
  47252. import { Texture } from "babylonjs/Materials/Textures/texture";
  47253. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47254. import "babylonjs/Meshes/Builders/sphereBuilder";
  47255. /**
  47256. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47257. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47258. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47259. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47260. */
  47261. export class PhotoDome extends TransformNode {
  47262. /**
  47263. * Define the image as a Monoscopic panoramic 360 image.
  47264. */
  47265. static readonly MODE_MONOSCOPIC: number;
  47266. /**
  47267. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47268. */
  47269. static readonly MODE_TOPBOTTOM: number;
  47270. /**
  47271. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47272. */
  47273. static readonly MODE_SIDEBYSIDE: number;
  47274. private _useDirectMapping;
  47275. /**
  47276. * The texture being displayed on the sphere
  47277. */
  47278. protected _photoTexture: Texture;
  47279. /**
  47280. * Gets or sets the texture being displayed on the sphere
  47281. */
  47282. photoTexture: Texture;
  47283. /**
  47284. * Observable raised when an error occured while loading the 360 image
  47285. */
  47286. onLoadErrorObservable: Observable<string>;
  47287. /**
  47288. * The skybox material
  47289. */
  47290. protected _material: BackgroundMaterial;
  47291. /**
  47292. * The surface used for the skybox
  47293. */
  47294. protected _mesh: Mesh;
  47295. /**
  47296. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47297. * Also see the options.resolution property.
  47298. */
  47299. fovMultiplier: number;
  47300. private _imageMode;
  47301. /**
  47302. * Gets or set the current video mode for the video. It can be:
  47303. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47304. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47305. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47306. */
  47307. imageMode: number;
  47308. /**
  47309. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47310. * @param name Element's name, child elements will append suffixes for their own names.
  47311. * @param urlsOfPhoto defines the url of the photo to display
  47312. * @param options defines an object containing optional or exposed sub element properties
  47313. * @param onError defines a callback called when an error occured while loading the texture
  47314. */
  47315. constructor(name: string, urlOfPhoto: string, options: {
  47316. resolution?: number;
  47317. size?: number;
  47318. useDirectMapping?: boolean;
  47319. faceForward?: boolean;
  47320. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47321. private _onBeforeCameraRenderObserver;
  47322. private _changeImageMode;
  47323. /**
  47324. * Releases resources associated with this node.
  47325. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47326. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47327. */
  47328. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47329. }
  47330. }
  47331. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47333. /** @hidden */
  47334. export var rgbdDecodePixelShader: {
  47335. name: string;
  47336. shader: string;
  47337. };
  47338. }
  47339. declare module "babylonjs/Misc/brdfTextureTools" {
  47340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47341. import { Scene } from "babylonjs/scene";
  47342. import "babylonjs/Shaders/rgbdDecode.fragment";
  47343. /**
  47344. * Class used to host texture specific utilities
  47345. */
  47346. export class BRDFTextureTools {
  47347. /**
  47348. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47349. * @param texture the texture to expand.
  47350. */
  47351. private static _ExpandDefaultBRDFTexture;
  47352. /**
  47353. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47354. * @param scene defines the hosting scene
  47355. * @returns the environment BRDF texture
  47356. */
  47357. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47358. private static _environmentBRDFBase64Texture;
  47359. }
  47360. }
  47361. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47362. import { Nullable } from "babylonjs/types";
  47363. import { Color3 } from "babylonjs/Maths/math.color";
  47364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47365. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47366. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47368. import { Engine } from "babylonjs/Engines/engine";
  47369. import { Scene } from "babylonjs/scene";
  47370. /**
  47371. * @hidden
  47372. */
  47373. export interface IMaterialClearCoatDefines {
  47374. CLEARCOAT: boolean;
  47375. CLEARCOAT_DEFAULTIOR: boolean;
  47376. CLEARCOAT_TEXTURE: boolean;
  47377. CLEARCOAT_TEXTUREDIRECTUV: number;
  47378. CLEARCOAT_BUMP: boolean;
  47379. CLEARCOAT_BUMPDIRECTUV: number;
  47380. CLEARCOAT_TINT: boolean;
  47381. CLEARCOAT_TINT_TEXTURE: boolean;
  47382. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47383. /** @hidden */
  47384. _areTexturesDirty: boolean;
  47385. }
  47386. /**
  47387. * Define the code related to the clear coat parameters of the pbr material.
  47388. */
  47389. export class PBRClearCoatConfiguration {
  47390. /**
  47391. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47392. * The default fits with a polyurethane material.
  47393. */
  47394. private static readonly _DefaultIndexOfRefraction;
  47395. private _isEnabled;
  47396. /**
  47397. * Defines if the clear coat is enabled in the material.
  47398. */
  47399. isEnabled: boolean;
  47400. /**
  47401. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47402. */
  47403. intensity: number;
  47404. /**
  47405. * Defines the clear coat layer roughness.
  47406. */
  47407. roughness: number;
  47408. private _indexOfRefraction;
  47409. /**
  47410. * Defines the index of refraction of the clear coat.
  47411. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47412. * The default fits with a polyurethane material.
  47413. * Changing the default value is more performance intensive.
  47414. */
  47415. indexOfRefraction: number;
  47416. private _texture;
  47417. /**
  47418. * Stores the clear coat values in a texture.
  47419. */
  47420. texture: Nullable<BaseTexture>;
  47421. private _bumpTexture;
  47422. /**
  47423. * Define the clear coat specific bump texture.
  47424. */
  47425. bumpTexture: Nullable<BaseTexture>;
  47426. private _isTintEnabled;
  47427. /**
  47428. * Defines if the clear coat tint is enabled in the material.
  47429. */
  47430. isTintEnabled: boolean;
  47431. /**
  47432. * Defines the clear coat tint of the material.
  47433. * This is only use if tint is enabled
  47434. */
  47435. tintColor: Color3;
  47436. /**
  47437. * Defines the distance at which the tint color should be found in the
  47438. * clear coat media.
  47439. * This is only use if tint is enabled
  47440. */
  47441. tintColorAtDistance: number;
  47442. /**
  47443. * Defines the clear coat layer thickness.
  47444. * This is only use if tint is enabled
  47445. */
  47446. tintThickness: number;
  47447. private _tintTexture;
  47448. /**
  47449. * Stores the clear tint values in a texture.
  47450. * rgb is tint
  47451. * a is a thickness factor
  47452. */
  47453. tintTexture: Nullable<BaseTexture>;
  47454. /** @hidden */
  47455. private _internalMarkAllSubMeshesAsTexturesDirty;
  47456. /** @hidden */
  47457. _markAllSubMeshesAsTexturesDirty(): void;
  47458. /**
  47459. * Instantiate a new istance of clear coat configuration.
  47460. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47461. */
  47462. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47463. /**
  47464. * Gets wehter the submesh is ready to be used or not.
  47465. * @param defines the list of "defines" to update.
  47466. * @param scene defines the scene the material belongs to.
  47467. * @param engine defines the engine the material belongs to.
  47468. * @param disableBumpMap defines wether the material disables bump or not.
  47469. * @returns - boolean indicating that the submesh is ready or not.
  47470. */
  47471. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47472. /**
  47473. * Checks to see if a texture is used in the material.
  47474. * @param defines the list of "defines" to update.
  47475. * @param scene defines the scene to the material belongs to.
  47476. */
  47477. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47478. /**
  47479. * Binds the material data.
  47480. * @param uniformBuffer defines the Uniform buffer to fill in.
  47481. * @param scene defines the scene the material belongs to.
  47482. * @param engine defines the engine the material belongs to.
  47483. * @param disableBumpMap defines wether the material disables bump or not.
  47484. * @param isFrozen defines wether the material is frozen or not.
  47485. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47486. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47487. */
  47488. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47489. /**
  47490. * Checks to see if a texture is used in the material.
  47491. * @param texture - Base texture to use.
  47492. * @returns - Boolean specifying if a texture is used in the material.
  47493. */
  47494. hasTexture(texture: BaseTexture): boolean;
  47495. /**
  47496. * Returns an array of the actively used textures.
  47497. * @param activeTextures Array of BaseTextures
  47498. */
  47499. getActiveTextures(activeTextures: BaseTexture[]): void;
  47500. /**
  47501. * Returns the animatable textures.
  47502. * @param animatables Array of animatable textures.
  47503. */
  47504. getAnimatables(animatables: IAnimatable[]): void;
  47505. /**
  47506. * Disposes the resources of the material.
  47507. * @param forceDisposeTextures - Forces the disposal of all textures.
  47508. */
  47509. dispose(forceDisposeTextures?: boolean): void;
  47510. /**
  47511. * Get the current class name of the texture useful for serialization or dynamic coding.
  47512. * @returns "PBRClearCoatConfiguration"
  47513. */
  47514. getClassName(): string;
  47515. /**
  47516. * Add fallbacks to the effect fallbacks list.
  47517. * @param defines defines the Base texture to use.
  47518. * @param fallbacks defines the current fallback list.
  47519. * @param currentRank defines the current fallback rank.
  47520. * @returns the new fallback rank.
  47521. */
  47522. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47523. /**
  47524. * Add the required uniforms to the current list.
  47525. * @param uniforms defines the current uniform list.
  47526. */
  47527. static AddUniforms(uniforms: string[]): void;
  47528. /**
  47529. * Add the required samplers to the current list.
  47530. * @param samplers defines the current sampler list.
  47531. */
  47532. static AddSamplers(samplers: string[]): void;
  47533. /**
  47534. * Add the required uniforms to the current buffer.
  47535. * @param uniformBuffer defines the current uniform buffer.
  47536. */
  47537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47538. /**
  47539. * Makes a duplicate of the current configuration into another one.
  47540. * @param clearCoatConfiguration define the config where to copy the info
  47541. */
  47542. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47543. /**
  47544. * Serializes this clear coat configuration.
  47545. * @returns - An object with the serialized config.
  47546. */
  47547. serialize(): any;
  47548. /**
  47549. * Parses a anisotropy Configuration from a serialized object.
  47550. * @param source - Serialized object.
  47551. * @param scene Defines the scene we are parsing for
  47552. * @param rootUrl Defines the rootUrl to load from
  47553. */
  47554. parse(source: any, scene: Scene, rootUrl: string): void;
  47555. }
  47556. }
  47557. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47558. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47559. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47561. import { Vector2 } from "babylonjs/Maths/math.vector";
  47562. import { Scene } from "babylonjs/scene";
  47563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47564. import { Nullable } from "babylonjs/types";
  47565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47566. /**
  47567. * @hidden
  47568. */
  47569. export interface IMaterialAnisotropicDefines {
  47570. ANISOTROPIC: boolean;
  47571. ANISOTROPIC_TEXTURE: boolean;
  47572. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47573. MAINUV1: boolean;
  47574. _areTexturesDirty: boolean;
  47575. _needUVs: boolean;
  47576. }
  47577. /**
  47578. * Define the code related to the anisotropic parameters of the pbr material.
  47579. */
  47580. export class PBRAnisotropicConfiguration {
  47581. private _isEnabled;
  47582. /**
  47583. * Defines if the anisotropy is enabled in the material.
  47584. */
  47585. isEnabled: boolean;
  47586. /**
  47587. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47588. */
  47589. intensity: number;
  47590. /**
  47591. * Defines if the effect is along the tangents, bitangents or in between.
  47592. * By default, the effect is "strectching" the highlights along the tangents.
  47593. */
  47594. direction: Vector2;
  47595. private _texture;
  47596. /**
  47597. * Stores the anisotropy values in a texture.
  47598. * rg is direction (like normal from -1 to 1)
  47599. * b is a intensity
  47600. */
  47601. texture: Nullable<BaseTexture>;
  47602. /** @hidden */
  47603. private _internalMarkAllSubMeshesAsTexturesDirty;
  47604. /** @hidden */
  47605. _markAllSubMeshesAsTexturesDirty(): void;
  47606. /**
  47607. * Instantiate a new istance of anisotropy configuration.
  47608. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47609. */
  47610. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47611. /**
  47612. * Specifies that the submesh is ready to be used.
  47613. * @param defines the list of "defines" to update.
  47614. * @param scene defines the scene the material belongs to.
  47615. * @returns - boolean indicating that the submesh is ready or not.
  47616. */
  47617. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47618. /**
  47619. * Checks to see if a texture is used in the material.
  47620. * @param defines the list of "defines" to update.
  47621. * @param mesh the mesh we are preparing the defines for.
  47622. * @param scene defines the scene the material belongs to.
  47623. */
  47624. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47625. /**
  47626. * Binds the material data.
  47627. * @param uniformBuffer defines the Uniform buffer to fill in.
  47628. * @param scene defines the scene the material belongs to.
  47629. * @param isFrozen defines wether the material is frozen or not.
  47630. */
  47631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47632. /**
  47633. * Checks to see if a texture is used in the material.
  47634. * @param texture - Base texture to use.
  47635. * @returns - Boolean specifying if a texture is used in the material.
  47636. */
  47637. hasTexture(texture: BaseTexture): boolean;
  47638. /**
  47639. * Returns an array of the actively used textures.
  47640. * @param activeTextures Array of BaseTextures
  47641. */
  47642. getActiveTextures(activeTextures: BaseTexture[]): void;
  47643. /**
  47644. * Returns the animatable textures.
  47645. * @param animatables Array of animatable textures.
  47646. */
  47647. getAnimatables(animatables: IAnimatable[]): void;
  47648. /**
  47649. * Disposes the resources of the material.
  47650. * @param forceDisposeTextures - Forces the disposal of all textures.
  47651. */
  47652. dispose(forceDisposeTextures?: boolean): void;
  47653. /**
  47654. * Get the current class name of the texture useful for serialization or dynamic coding.
  47655. * @returns "PBRAnisotropicConfiguration"
  47656. */
  47657. getClassName(): string;
  47658. /**
  47659. * Add fallbacks to the effect fallbacks list.
  47660. * @param defines defines the Base texture to use.
  47661. * @param fallbacks defines the current fallback list.
  47662. * @param currentRank defines the current fallback rank.
  47663. * @returns the new fallback rank.
  47664. */
  47665. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47666. /**
  47667. * Add the required uniforms to the current list.
  47668. * @param uniforms defines the current uniform list.
  47669. */
  47670. static AddUniforms(uniforms: string[]): void;
  47671. /**
  47672. * Add the required uniforms to the current buffer.
  47673. * @param uniformBuffer defines the current uniform buffer.
  47674. */
  47675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47676. /**
  47677. * Add the required samplers to the current list.
  47678. * @param samplers defines the current sampler list.
  47679. */
  47680. static AddSamplers(samplers: string[]): void;
  47681. /**
  47682. * Makes a duplicate of the current configuration into another one.
  47683. * @param anisotropicConfiguration define the config where to copy the info
  47684. */
  47685. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47686. /**
  47687. * Serializes this anisotropy configuration.
  47688. * @returns - An object with the serialized config.
  47689. */
  47690. serialize(): any;
  47691. /**
  47692. * Parses a anisotropy Configuration from a serialized object.
  47693. * @param source - Serialized object.
  47694. * @param scene Defines the scene we are parsing for
  47695. * @param rootUrl Defines the rootUrl to load from
  47696. */
  47697. parse(source: any, scene: Scene, rootUrl: string): void;
  47698. }
  47699. }
  47700. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47701. import { Scene } from "babylonjs/scene";
  47702. /**
  47703. * @hidden
  47704. */
  47705. export interface IMaterialBRDFDefines {
  47706. BRDF_V_HEIGHT_CORRELATED: boolean;
  47707. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47708. SPHERICAL_HARMONICS: boolean;
  47709. /** @hidden */
  47710. _areMiscDirty: boolean;
  47711. }
  47712. /**
  47713. * Define the code related to the BRDF parameters of the pbr material.
  47714. */
  47715. export class PBRBRDFConfiguration {
  47716. /**
  47717. * Default value used for the energy conservation.
  47718. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47719. */
  47720. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47721. /**
  47722. * Default value used for the Smith Visibility Height Correlated mode.
  47723. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47724. */
  47725. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47726. /**
  47727. * Default value used for the IBL diffuse part.
  47728. * This can help switching back to the polynomials mode globally which is a tiny bit
  47729. * less GPU intensive at the drawback of a lower quality.
  47730. */
  47731. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47732. private _useEnergyConservation;
  47733. /**
  47734. * Defines if the material uses energy conservation.
  47735. */
  47736. useEnergyConservation: boolean;
  47737. private _useSmithVisibilityHeightCorrelated;
  47738. /**
  47739. * LEGACY Mode set to false
  47740. * Defines if the material uses height smith correlated visibility term.
  47741. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47742. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47743. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47744. * Not relying on height correlated will also disable energy conservation.
  47745. */
  47746. useSmithVisibilityHeightCorrelated: boolean;
  47747. private _useSphericalHarmonics;
  47748. /**
  47749. * LEGACY Mode set to false
  47750. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47751. * diffuse part of the IBL.
  47752. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47753. * to the ground truth.
  47754. */
  47755. useSphericalHarmonics: boolean;
  47756. /** @hidden */
  47757. private _internalMarkAllSubMeshesAsMiscDirty;
  47758. /** @hidden */
  47759. _markAllSubMeshesAsMiscDirty(): void;
  47760. /**
  47761. * Instantiate a new istance of clear coat configuration.
  47762. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47763. */
  47764. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47765. /**
  47766. * Checks to see if a texture is used in the material.
  47767. * @param defines the list of "defines" to update.
  47768. */
  47769. prepareDefines(defines: IMaterialBRDFDefines): void;
  47770. /**
  47771. * Get the current class name of the texture useful for serialization or dynamic coding.
  47772. * @returns "PBRClearCoatConfiguration"
  47773. */
  47774. getClassName(): string;
  47775. /**
  47776. * Makes a duplicate of the current configuration into another one.
  47777. * @param brdfConfiguration define the config where to copy the info
  47778. */
  47779. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47780. /**
  47781. * Serializes this BRDF configuration.
  47782. * @returns - An object with the serialized config.
  47783. */
  47784. serialize(): any;
  47785. /**
  47786. * Parses a anisotropy Configuration from a serialized object.
  47787. * @param source - Serialized object.
  47788. * @param scene Defines the scene we are parsing for
  47789. * @param rootUrl Defines the rootUrl to load from
  47790. */
  47791. parse(source: any, scene: Scene, rootUrl: string): void;
  47792. }
  47793. }
  47794. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47795. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47796. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47797. import { Color3 } from "babylonjs/Maths/math.color";
  47798. import { Scene } from "babylonjs/scene";
  47799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47800. import { Nullable } from "babylonjs/types";
  47801. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47802. /**
  47803. * @hidden
  47804. */
  47805. export interface IMaterialSheenDefines {
  47806. SHEEN: boolean;
  47807. SHEEN_TEXTURE: boolean;
  47808. SHEEN_TEXTUREDIRECTUV: number;
  47809. SHEEN_LINKWITHALBEDO: boolean;
  47810. /** @hidden */
  47811. _areTexturesDirty: boolean;
  47812. }
  47813. /**
  47814. * Define the code related to the Sheen parameters of the pbr material.
  47815. */
  47816. export class PBRSheenConfiguration {
  47817. private _isEnabled;
  47818. /**
  47819. * Defines if the material uses sheen.
  47820. */
  47821. isEnabled: boolean;
  47822. private _linkSheenWithAlbedo;
  47823. /**
  47824. * Defines if the sheen is linked to the sheen color.
  47825. */
  47826. linkSheenWithAlbedo: boolean;
  47827. /**
  47828. * Defines the sheen intensity.
  47829. */
  47830. intensity: number;
  47831. /**
  47832. * Defines the sheen color.
  47833. */
  47834. color: Color3;
  47835. private _texture;
  47836. /**
  47837. * Stores the sheen tint values in a texture.
  47838. * rgb is tint
  47839. * a is a intensity
  47840. */
  47841. texture: Nullable<BaseTexture>;
  47842. /** @hidden */
  47843. private _internalMarkAllSubMeshesAsTexturesDirty;
  47844. /** @hidden */
  47845. _markAllSubMeshesAsTexturesDirty(): void;
  47846. /**
  47847. * Instantiate a new istance of clear coat configuration.
  47848. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47849. */
  47850. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47851. /**
  47852. * Specifies that the submesh is ready to be used.
  47853. * @param defines the list of "defines" to update.
  47854. * @param scene defines the scene the material belongs to.
  47855. * @returns - boolean indicating that the submesh is ready or not.
  47856. */
  47857. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47858. /**
  47859. * Checks to see if a texture is used in the material.
  47860. * @param defines the list of "defines" to update.
  47861. * @param scene defines the scene the material belongs to.
  47862. */
  47863. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47864. /**
  47865. * Binds the material data.
  47866. * @param uniformBuffer defines the Uniform buffer to fill in.
  47867. * @param scene defines the scene the material belongs to.
  47868. * @param isFrozen defines wether the material is frozen or not.
  47869. */
  47870. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47871. /**
  47872. * Checks to see if a texture is used in the material.
  47873. * @param texture - Base texture to use.
  47874. * @returns - Boolean specifying if a texture is used in the material.
  47875. */
  47876. hasTexture(texture: BaseTexture): boolean;
  47877. /**
  47878. * Returns an array of the actively used textures.
  47879. * @param activeTextures Array of BaseTextures
  47880. */
  47881. getActiveTextures(activeTextures: BaseTexture[]): void;
  47882. /**
  47883. * Returns the animatable textures.
  47884. * @param animatables Array of animatable textures.
  47885. */
  47886. getAnimatables(animatables: IAnimatable[]): void;
  47887. /**
  47888. * Disposes the resources of the material.
  47889. * @param forceDisposeTextures - Forces the disposal of all textures.
  47890. */
  47891. dispose(forceDisposeTextures?: boolean): void;
  47892. /**
  47893. * Get the current class name of the texture useful for serialization or dynamic coding.
  47894. * @returns "PBRSheenConfiguration"
  47895. */
  47896. getClassName(): string;
  47897. /**
  47898. * Add fallbacks to the effect fallbacks list.
  47899. * @param defines defines the Base texture to use.
  47900. * @param fallbacks defines the current fallback list.
  47901. * @param currentRank defines the current fallback rank.
  47902. * @returns the new fallback rank.
  47903. */
  47904. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47905. /**
  47906. * Add the required uniforms to the current list.
  47907. * @param uniforms defines the current uniform list.
  47908. */
  47909. static AddUniforms(uniforms: string[]): void;
  47910. /**
  47911. * Add the required uniforms to the current buffer.
  47912. * @param uniformBuffer defines the current uniform buffer.
  47913. */
  47914. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47915. /**
  47916. * Add the required samplers to the current list.
  47917. * @param samplers defines the current sampler list.
  47918. */
  47919. static AddSamplers(samplers: string[]): void;
  47920. /**
  47921. * Makes a duplicate of the current configuration into another one.
  47922. * @param sheenConfiguration define the config where to copy the info
  47923. */
  47924. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47925. /**
  47926. * Serializes this BRDF configuration.
  47927. * @returns - An object with the serialized config.
  47928. */
  47929. serialize(): any;
  47930. /**
  47931. * Parses a anisotropy Configuration from a serialized object.
  47932. * @param source - Serialized object.
  47933. * @param scene Defines the scene we are parsing for
  47934. * @param rootUrl Defines the rootUrl to load from
  47935. */
  47936. parse(source: any, scene: Scene, rootUrl: string): void;
  47937. }
  47938. }
  47939. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47940. import { Nullable } from "babylonjs/types";
  47941. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47942. import { Color3 } from "babylonjs/Maths/math.color";
  47943. import { SmartArray } from "babylonjs/Misc/smartArray";
  47944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47946. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47947. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47948. import { Engine } from "babylonjs/Engines/engine";
  47949. import { Scene } from "babylonjs/scene";
  47950. /**
  47951. * @hidden
  47952. */
  47953. export interface IMaterialSubSurfaceDefines {
  47954. SUBSURFACE: boolean;
  47955. SS_REFRACTION: boolean;
  47956. SS_TRANSLUCENCY: boolean;
  47957. SS_SCATERRING: boolean;
  47958. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47959. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47960. SS_REFRACTIONMAP_3D: boolean;
  47961. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47962. SS_LODINREFRACTIONALPHA: boolean;
  47963. SS_GAMMAREFRACTION: boolean;
  47964. SS_RGBDREFRACTION: boolean;
  47965. SS_LINEARSPECULARREFRACTION: boolean;
  47966. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47967. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47968. /** @hidden */
  47969. _areTexturesDirty: boolean;
  47970. }
  47971. /**
  47972. * Define the code related to the sub surface parameters of the pbr material.
  47973. */
  47974. export class PBRSubSurfaceConfiguration {
  47975. private _isRefractionEnabled;
  47976. /**
  47977. * Defines if the refraction is enabled in the material.
  47978. */
  47979. isRefractionEnabled: boolean;
  47980. private _isTranslucencyEnabled;
  47981. /**
  47982. * Defines if the translucency is enabled in the material.
  47983. */
  47984. isTranslucencyEnabled: boolean;
  47985. private _isScatteringEnabled;
  47986. /**
  47987. * Defines the refraction intensity of the material.
  47988. * The refraction when enabled replaces the Diffuse part of the material.
  47989. * The intensity helps transitionning between diffuse and refraction.
  47990. */
  47991. refractionIntensity: number;
  47992. /**
  47993. * Defines the translucency intensity of the material.
  47994. * When translucency has been enabled, this defines how much of the "translucency"
  47995. * is addded to the diffuse part of the material.
  47996. */
  47997. translucencyIntensity: number;
  47998. /**
  47999. * Defines the scattering intensity of the material.
  48000. * When scattering has been enabled, this defines how much of the "scattered light"
  48001. * is addded to the diffuse part of the material.
  48002. */
  48003. scatteringIntensity: number;
  48004. private _thicknessTexture;
  48005. /**
  48006. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48007. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48008. * 0 would mean minimumThickness
  48009. * 1 would mean maximumThickness
  48010. * The other channels might be use as a mask to vary the different effects intensity.
  48011. */
  48012. thicknessTexture: Nullable<BaseTexture>;
  48013. private _refractionTexture;
  48014. /**
  48015. * Defines the texture to use for refraction.
  48016. */
  48017. refractionTexture: Nullable<BaseTexture>;
  48018. private _indexOfRefraction;
  48019. /**
  48020. * Defines the index of refraction used in the material.
  48021. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48022. */
  48023. indexOfRefraction: number;
  48024. private _invertRefractionY;
  48025. /**
  48026. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48027. */
  48028. invertRefractionY: boolean;
  48029. private _linkRefractionWithTransparency;
  48030. /**
  48031. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48032. * Materials half opaque for instance using refraction could benefit from this control.
  48033. */
  48034. linkRefractionWithTransparency: boolean;
  48035. /**
  48036. * Defines the minimum thickness stored in the thickness map.
  48037. * If no thickness map is defined, this value will be used to simulate thickness.
  48038. */
  48039. minimumThickness: number;
  48040. /**
  48041. * Defines the maximum thickness stored in the thickness map.
  48042. */
  48043. maximumThickness: number;
  48044. /**
  48045. * Defines the volume tint of the material.
  48046. * This is used for both translucency and scattering.
  48047. */
  48048. tintColor: Color3;
  48049. /**
  48050. * Defines the distance at which the tint color should be found in the media.
  48051. * This is used for refraction only.
  48052. */
  48053. tintColorAtDistance: number;
  48054. /**
  48055. * Defines how far each channel transmit through the media.
  48056. * It is defined as a color to simplify it selection.
  48057. */
  48058. diffusionDistance: Color3;
  48059. private _useMaskFromThicknessTexture;
  48060. /**
  48061. * Stores the intensity of the different subsurface effects in the thickness texture.
  48062. * * the green channel is the translucency intensity.
  48063. * * the blue channel is the scattering intensity.
  48064. * * the alpha channel is the refraction intensity.
  48065. */
  48066. useMaskFromThicknessTexture: boolean;
  48067. /** @hidden */
  48068. private _internalMarkAllSubMeshesAsTexturesDirty;
  48069. /** @hidden */
  48070. _markAllSubMeshesAsTexturesDirty(): void;
  48071. /**
  48072. * Instantiate a new istance of sub surface configuration.
  48073. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48074. */
  48075. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48076. /**
  48077. * Gets wehter the submesh is ready to be used or not.
  48078. * @param defines the list of "defines" to update.
  48079. * @param scene defines the scene the material belongs to.
  48080. * @returns - boolean indicating that the submesh is ready or not.
  48081. */
  48082. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48083. /**
  48084. * Checks to see if a texture is used in the material.
  48085. * @param defines the list of "defines" to update.
  48086. * @param scene defines the scene to the material belongs to.
  48087. */
  48088. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48089. /**
  48090. * Binds the material data.
  48091. * @param uniformBuffer defines the Uniform buffer to fill in.
  48092. * @param scene defines the scene the material belongs to.
  48093. * @param engine defines the engine the material belongs to.
  48094. * @param isFrozen defines wether the material is frozen or not.
  48095. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48096. */
  48097. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48098. /**
  48099. * Unbinds the material from the mesh.
  48100. * @param activeEffect defines the effect that should be unbound from.
  48101. * @returns true if unbound, otherwise false
  48102. */
  48103. unbind(activeEffect: Effect): boolean;
  48104. /**
  48105. * Returns the texture used for refraction or null if none is used.
  48106. * @param scene defines the scene the material belongs to.
  48107. * @returns - Refraction texture if present. If no refraction texture and refraction
  48108. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48109. */
  48110. private _getRefractionTexture;
  48111. /**
  48112. * Returns true if alpha blending should be disabled.
  48113. */
  48114. readonly disableAlphaBlending: boolean;
  48115. /**
  48116. * Fills the list of render target textures.
  48117. * @param renderTargets the list of render targets to update
  48118. */
  48119. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48120. /**
  48121. * Checks to see if a texture is used in the material.
  48122. * @param texture - Base texture to use.
  48123. * @returns - Boolean specifying if a texture is used in the material.
  48124. */
  48125. hasTexture(texture: BaseTexture): boolean;
  48126. /**
  48127. * Gets a boolean indicating that current material needs to register RTT
  48128. * @returns true if this uses a render target otherwise false.
  48129. */
  48130. hasRenderTargetTextures(): boolean;
  48131. /**
  48132. * Returns an array of the actively used textures.
  48133. * @param activeTextures Array of BaseTextures
  48134. */
  48135. getActiveTextures(activeTextures: BaseTexture[]): void;
  48136. /**
  48137. * Returns the animatable textures.
  48138. * @param animatables Array of animatable textures.
  48139. */
  48140. getAnimatables(animatables: IAnimatable[]): void;
  48141. /**
  48142. * Disposes the resources of the material.
  48143. * @param forceDisposeTextures - Forces the disposal of all textures.
  48144. */
  48145. dispose(forceDisposeTextures?: boolean): void;
  48146. /**
  48147. * Get the current class name of the texture useful for serialization or dynamic coding.
  48148. * @returns "PBRSubSurfaceConfiguration"
  48149. */
  48150. getClassName(): string;
  48151. /**
  48152. * Add fallbacks to the effect fallbacks list.
  48153. * @param defines defines the Base texture to use.
  48154. * @param fallbacks defines the current fallback list.
  48155. * @param currentRank defines the current fallback rank.
  48156. * @returns the new fallback rank.
  48157. */
  48158. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48159. /**
  48160. * Add the required uniforms to the current list.
  48161. * @param uniforms defines the current uniform list.
  48162. */
  48163. static AddUniforms(uniforms: string[]): void;
  48164. /**
  48165. * Add the required samplers to the current list.
  48166. * @param samplers defines the current sampler list.
  48167. */
  48168. static AddSamplers(samplers: string[]): void;
  48169. /**
  48170. * Add the required uniforms to the current buffer.
  48171. * @param uniformBuffer defines the current uniform buffer.
  48172. */
  48173. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48174. /**
  48175. * Makes a duplicate of the current configuration into another one.
  48176. * @param configuration define the config where to copy the info
  48177. */
  48178. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48179. /**
  48180. * Serializes this Sub Surface configuration.
  48181. * @returns - An object with the serialized config.
  48182. */
  48183. serialize(): any;
  48184. /**
  48185. * Parses a anisotropy Configuration from a serialized object.
  48186. * @param source - Serialized object.
  48187. * @param scene Defines the scene we are parsing for
  48188. * @param rootUrl Defines the rootUrl to load from
  48189. */
  48190. parse(source: any, scene: Scene, rootUrl: string): void;
  48191. }
  48192. }
  48193. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48194. /** @hidden */
  48195. export var pbrFragmentDeclaration: {
  48196. name: string;
  48197. shader: string;
  48198. };
  48199. }
  48200. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48201. /** @hidden */
  48202. export var pbrUboDeclaration: {
  48203. name: string;
  48204. shader: string;
  48205. };
  48206. }
  48207. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48208. /** @hidden */
  48209. export var pbrFragmentExtraDeclaration: {
  48210. name: string;
  48211. shader: string;
  48212. };
  48213. }
  48214. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48215. /** @hidden */
  48216. export var pbrFragmentSamplersDeclaration: {
  48217. name: string;
  48218. shader: string;
  48219. };
  48220. }
  48221. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48222. /** @hidden */
  48223. export var pbrHelperFunctions: {
  48224. name: string;
  48225. shader: string;
  48226. };
  48227. }
  48228. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48229. /** @hidden */
  48230. export var harmonicsFunctions: {
  48231. name: string;
  48232. shader: string;
  48233. };
  48234. }
  48235. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48236. /** @hidden */
  48237. export var pbrDirectLightingSetupFunctions: {
  48238. name: string;
  48239. shader: string;
  48240. };
  48241. }
  48242. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48243. /** @hidden */
  48244. export var pbrDirectLightingFalloffFunctions: {
  48245. name: string;
  48246. shader: string;
  48247. };
  48248. }
  48249. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48250. /** @hidden */
  48251. export var pbrBRDFFunctions: {
  48252. name: string;
  48253. shader: string;
  48254. };
  48255. }
  48256. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48257. /** @hidden */
  48258. export var pbrDirectLightingFunctions: {
  48259. name: string;
  48260. shader: string;
  48261. };
  48262. }
  48263. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48264. /** @hidden */
  48265. export var pbrIBLFunctions: {
  48266. name: string;
  48267. shader: string;
  48268. };
  48269. }
  48270. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48271. /** @hidden */
  48272. export var pbrDebug: {
  48273. name: string;
  48274. shader: string;
  48275. };
  48276. }
  48277. declare module "babylonjs/Shaders/pbr.fragment" {
  48278. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48279. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48280. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48281. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48282. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48283. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48284. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48285. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48286. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48287. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48288. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48289. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48290. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48291. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48292. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48293. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48294. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48295. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48296. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48297. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48298. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48299. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48300. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48301. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48302. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48303. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48304. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48305. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48306. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48307. /** @hidden */
  48308. export var pbrPixelShader: {
  48309. name: string;
  48310. shader: string;
  48311. };
  48312. }
  48313. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48314. /** @hidden */
  48315. export var pbrVertexDeclaration: {
  48316. name: string;
  48317. shader: string;
  48318. };
  48319. }
  48320. declare module "babylonjs/Shaders/pbr.vertex" {
  48321. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48322. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48324. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48325. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48326. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48327. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48328. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48329. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48330. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48331. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48332. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48333. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48334. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48335. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48336. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48337. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48338. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48339. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48340. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48341. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48342. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48343. /** @hidden */
  48344. export var pbrVertexShader: {
  48345. name: string;
  48346. shader: string;
  48347. };
  48348. }
  48349. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48350. import { Nullable } from "babylonjs/types";
  48351. import { Scene } from "babylonjs/scene";
  48352. import { Matrix } from "babylonjs/Maths/math.vector";
  48353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48355. import { Mesh } from "babylonjs/Meshes/mesh";
  48356. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48357. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48358. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48359. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48360. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48361. import { Color3 } from "babylonjs/Maths/math.color";
  48362. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48363. import { Material } from "babylonjs/Materials/material";
  48364. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48365. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48368. import "babylonjs/Shaders/pbr.fragment";
  48369. import "babylonjs/Shaders/pbr.vertex";
  48370. /**
  48371. * Manages the defines for the PBR Material.
  48372. * @hidden
  48373. */
  48374. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48375. PBR: boolean;
  48376. MAINUV1: boolean;
  48377. MAINUV2: boolean;
  48378. UV1: boolean;
  48379. UV2: boolean;
  48380. ALBEDO: boolean;
  48381. ALBEDODIRECTUV: number;
  48382. VERTEXCOLOR: boolean;
  48383. AMBIENT: boolean;
  48384. AMBIENTDIRECTUV: number;
  48385. AMBIENTINGRAYSCALE: boolean;
  48386. OPACITY: boolean;
  48387. VERTEXALPHA: boolean;
  48388. OPACITYDIRECTUV: number;
  48389. OPACITYRGB: boolean;
  48390. ALPHATEST: boolean;
  48391. DEPTHPREPASS: boolean;
  48392. ALPHABLEND: boolean;
  48393. ALPHAFROMALBEDO: boolean;
  48394. ALPHATESTVALUE: string;
  48395. SPECULAROVERALPHA: boolean;
  48396. RADIANCEOVERALPHA: boolean;
  48397. ALPHAFRESNEL: boolean;
  48398. LINEARALPHAFRESNEL: boolean;
  48399. PREMULTIPLYALPHA: boolean;
  48400. EMISSIVE: boolean;
  48401. EMISSIVEDIRECTUV: number;
  48402. REFLECTIVITY: boolean;
  48403. REFLECTIVITYDIRECTUV: number;
  48404. SPECULARTERM: boolean;
  48405. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48406. MICROSURFACEAUTOMATIC: boolean;
  48407. LODBASEDMICROSFURACE: boolean;
  48408. MICROSURFACEMAP: boolean;
  48409. MICROSURFACEMAPDIRECTUV: number;
  48410. METALLICWORKFLOW: boolean;
  48411. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48412. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48413. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48414. AOSTOREINMETALMAPRED: boolean;
  48415. ENVIRONMENTBRDF: boolean;
  48416. ENVIRONMENTBRDF_RGBD: boolean;
  48417. NORMAL: boolean;
  48418. TANGENT: boolean;
  48419. BUMP: boolean;
  48420. BUMPDIRECTUV: number;
  48421. OBJECTSPACE_NORMALMAP: boolean;
  48422. PARALLAX: boolean;
  48423. PARALLAXOCCLUSION: boolean;
  48424. NORMALXYSCALE: boolean;
  48425. LIGHTMAP: boolean;
  48426. LIGHTMAPDIRECTUV: number;
  48427. USELIGHTMAPASSHADOWMAP: boolean;
  48428. GAMMALIGHTMAP: boolean;
  48429. REFLECTION: boolean;
  48430. REFLECTIONMAP_3D: boolean;
  48431. REFLECTIONMAP_SPHERICAL: boolean;
  48432. REFLECTIONMAP_PLANAR: boolean;
  48433. REFLECTIONMAP_CUBIC: boolean;
  48434. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48435. REFLECTIONMAP_PROJECTION: boolean;
  48436. REFLECTIONMAP_SKYBOX: boolean;
  48437. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48438. REFLECTIONMAP_EXPLICIT: boolean;
  48439. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48440. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48441. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48442. INVERTCUBICMAP: boolean;
  48443. USESPHERICALFROMREFLECTIONMAP: boolean;
  48444. USEIRRADIANCEMAP: boolean;
  48445. SPHERICAL_HARMONICS: boolean;
  48446. USESPHERICALINVERTEX: boolean;
  48447. REFLECTIONMAP_OPPOSITEZ: boolean;
  48448. LODINREFLECTIONALPHA: boolean;
  48449. GAMMAREFLECTION: boolean;
  48450. RGBDREFLECTION: boolean;
  48451. LINEARSPECULARREFLECTION: boolean;
  48452. RADIANCEOCCLUSION: boolean;
  48453. HORIZONOCCLUSION: boolean;
  48454. INSTANCES: boolean;
  48455. NUM_BONE_INFLUENCERS: number;
  48456. BonesPerMesh: number;
  48457. BONETEXTURE: boolean;
  48458. NONUNIFORMSCALING: boolean;
  48459. MORPHTARGETS: boolean;
  48460. MORPHTARGETS_NORMAL: boolean;
  48461. MORPHTARGETS_TANGENT: boolean;
  48462. MORPHTARGETS_UV: boolean;
  48463. NUM_MORPH_INFLUENCERS: number;
  48464. IMAGEPROCESSING: boolean;
  48465. VIGNETTE: boolean;
  48466. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48467. VIGNETTEBLENDMODEOPAQUE: boolean;
  48468. TONEMAPPING: boolean;
  48469. TONEMAPPING_ACES: boolean;
  48470. CONTRAST: boolean;
  48471. COLORCURVES: boolean;
  48472. COLORGRADING: boolean;
  48473. COLORGRADING3D: boolean;
  48474. SAMPLER3DGREENDEPTH: boolean;
  48475. SAMPLER3DBGRMAP: boolean;
  48476. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48477. EXPOSURE: boolean;
  48478. MULTIVIEW: boolean;
  48479. USEPHYSICALLIGHTFALLOFF: boolean;
  48480. USEGLTFLIGHTFALLOFF: boolean;
  48481. TWOSIDEDLIGHTING: boolean;
  48482. SHADOWFLOAT: boolean;
  48483. CLIPPLANE: boolean;
  48484. CLIPPLANE2: boolean;
  48485. CLIPPLANE3: boolean;
  48486. CLIPPLANE4: boolean;
  48487. POINTSIZE: boolean;
  48488. FOG: boolean;
  48489. LOGARITHMICDEPTH: boolean;
  48490. FORCENORMALFORWARD: boolean;
  48491. SPECULARAA: boolean;
  48492. CLEARCOAT: boolean;
  48493. CLEARCOAT_DEFAULTIOR: boolean;
  48494. CLEARCOAT_TEXTURE: boolean;
  48495. CLEARCOAT_TEXTUREDIRECTUV: number;
  48496. CLEARCOAT_BUMP: boolean;
  48497. CLEARCOAT_BUMPDIRECTUV: number;
  48498. CLEARCOAT_TINT: boolean;
  48499. CLEARCOAT_TINT_TEXTURE: boolean;
  48500. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48501. ANISOTROPIC: boolean;
  48502. ANISOTROPIC_TEXTURE: boolean;
  48503. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48504. BRDF_V_HEIGHT_CORRELATED: boolean;
  48505. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48506. SHEEN: boolean;
  48507. SHEEN_TEXTURE: boolean;
  48508. SHEEN_TEXTUREDIRECTUV: number;
  48509. SHEEN_LINKWITHALBEDO: boolean;
  48510. SUBSURFACE: boolean;
  48511. SS_REFRACTION: boolean;
  48512. SS_TRANSLUCENCY: boolean;
  48513. SS_SCATERRING: boolean;
  48514. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48515. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48516. SS_REFRACTIONMAP_3D: boolean;
  48517. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48518. SS_LODINREFRACTIONALPHA: boolean;
  48519. SS_GAMMAREFRACTION: boolean;
  48520. SS_RGBDREFRACTION: boolean;
  48521. SS_LINEARSPECULARREFRACTION: boolean;
  48522. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48523. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48524. UNLIT: boolean;
  48525. DEBUGMODE: number;
  48526. /**
  48527. * Initializes the PBR Material defines.
  48528. */
  48529. constructor();
  48530. /**
  48531. * Resets the PBR Material defines.
  48532. */
  48533. reset(): void;
  48534. }
  48535. /**
  48536. * The Physically based material base class of BJS.
  48537. *
  48538. * This offers the main features of a standard PBR material.
  48539. * For more information, please refer to the documentation :
  48540. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48541. */
  48542. export abstract class PBRBaseMaterial extends PushMaterial {
  48543. /**
  48544. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48545. */
  48546. static readonly PBRMATERIAL_OPAQUE: number;
  48547. /**
  48548. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48549. */
  48550. static readonly PBRMATERIAL_ALPHATEST: number;
  48551. /**
  48552. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48553. */
  48554. static readonly PBRMATERIAL_ALPHABLEND: number;
  48555. /**
  48556. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48557. * They are also discarded below the alpha cutoff threshold to improve performances.
  48558. */
  48559. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48560. /**
  48561. * Defines the default value of how much AO map is occluding the analytical lights
  48562. * (point spot...).
  48563. */
  48564. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48565. /**
  48566. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48567. */
  48568. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48569. /**
  48570. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48571. * to enhance interoperability with other engines.
  48572. */
  48573. static readonly LIGHTFALLOFF_GLTF: number;
  48574. /**
  48575. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48576. * to enhance interoperability with other materials.
  48577. */
  48578. static readonly LIGHTFALLOFF_STANDARD: number;
  48579. /**
  48580. * Intensity of the direct lights e.g. the four lights available in your scene.
  48581. * This impacts both the direct diffuse and specular highlights.
  48582. */
  48583. protected _directIntensity: number;
  48584. /**
  48585. * Intensity of the emissive part of the material.
  48586. * This helps controlling the emissive effect without modifying the emissive color.
  48587. */
  48588. protected _emissiveIntensity: number;
  48589. /**
  48590. * Intensity of the environment e.g. how much the environment will light the object
  48591. * either through harmonics for rough material or through the refelction for shiny ones.
  48592. */
  48593. protected _environmentIntensity: number;
  48594. /**
  48595. * This is a special control allowing the reduction of the specular highlights coming from the
  48596. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48597. */
  48598. protected _specularIntensity: number;
  48599. /**
  48600. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48601. */
  48602. private _lightingInfos;
  48603. /**
  48604. * Debug Control allowing disabling the bump map on this material.
  48605. */
  48606. protected _disableBumpMap: boolean;
  48607. /**
  48608. * AKA Diffuse Texture in standard nomenclature.
  48609. */
  48610. protected _albedoTexture: Nullable<BaseTexture>;
  48611. /**
  48612. * AKA Occlusion Texture in other nomenclature.
  48613. */
  48614. protected _ambientTexture: Nullable<BaseTexture>;
  48615. /**
  48616. * AKA Occlusion Texture Intensity in other nomenclature.
  48617. */
  48618. protected _ambientTextureStrength: number;
  48619. /**
  48620. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48621. * 1 means it completely occludes it
  48622. * 0 mean it has no impact
  48623. */
  48624. protected _ambientTextureImpactOnAnalyticalLights: number;
  48625. /**
  48626. * Stores the alpha values in a texture.
  48627. */
  48628. protected _opacityTexture: Nullable<BaseTexture>;
  48629. /**
  48630. * Stores the reflection values in a texture.
  48631. */
  48632. protected _reflectionTexture: Nullable<BaseTexture>;
  48633. /**
  48634. * Stores the emissive values in a texture.
  48635. */
  48636. protected _emissiveTexture: Nullable<BaseTexture>;
  48637. /**
  48638. * AKA Specular texture in other nomenclature.
  48639. */
  48640. protected _reflectivityTexture: Nullable<BaseTexture>;
  48641. /**
  48642. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48643. */
  48644. protected _metallicTexture: Nullable<BaseTexture>;
  48645. /**
  48646. * Specifies the metallic scalar of the metallic/roughness workflow.
  48647. * Can also be used to scale the metalness values of the metallic texture.
  48648. */
  48649. protected _metallic: Nullable<number>;
  48650. /**
  48651. * Specifies the roughness scalar of the metallic/roughness workflow.
  48652. * Can also be used to scale the roughness values of the metallic texture.
  48653. */
  48654. protected _roughness: Nullable<number>;
  48655. /**
  48656. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48657. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48658. */
  48659. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48660. /**
  48661. * Stores surface normal data used to displace a mesh in a texture.
  48662. */
  48663. protected _bumpTexture: Nullable<BaseTexture>;
  48664. /**
  48665. * Stores the pre-calculated light information of a mesh in a texture.
  48666. */
  48667. protected _lightmapTexture: Nullable<BaseTexture>;
  48668. /**
  48669. * The color of a material in ambient lighting.
  48670. */
  48671. protected _ambientColor: Color3;
  48672. /**
  48673. * AKA Diffuse Color in other nomenclature.
  48674. */
  48675. protected _albedoColor: Color3;
  48676. /**
  48677. * AKA Specular Color in other nomenclature.
  48678. */
  48679. protected _reflectivityColor: Color3;
  48680. /**
  48681. * The color applied when light is reflected from a material.
  48682. */
  48683. protected _reflectionColor: Color3;
  48684. /**
  48685. * The color applied when light is emitted from a material.
  48686. */
  48687. protected _emissiveColor: Color3;
  48688. /**
  48689. * AKA Glossiness in other nomenclature.
  48690. */
  48691. protected _microSurface: number;
  48692. /**
  48693. * Specifies that the material will use the light map as a show map.
  48694. */
  48695. protected _useLightmapAsShadowmap: boolean;
  48696. /**
  48697. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48698. * makes the reflect vector face the model (under horizon).
  48699. */
  48700. protected _useHorizonOcclusion: boolean;
  48701. /**
  48702. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48703. * too much the area relying on ambient texture to define their ambient occlusion.
  48704. */
  48705. protected _useRadianceOcclusion: boolean;
  48706. /**
  48707. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48708. */
  48709. protected _useAlphaFromAlbedoTexture: boolean;
  48710. /**
  48711. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48712. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48713. */
  48714. protected _useSpecularOverAlpha: boolean;
  48715. /**
  48716. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48717. */
  48718. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48719. /**
  48720. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48721. */
  48722. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48723. /**
  48724. * Specifies if the metallic texture contains the roughness information in its green channel.
  48725. */
  48726. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48727. /**
  48728. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48729. */
  48730. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48731. /**
  48732. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48733. */
  48734. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48735. /**
  48736. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48737. */
  48738. protected _useAmbientInGrayScale: boolean;
  48739. /**
  48740. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48741. * The material will try to infer what glossiness each pixel should be.
  48742. */
  48743. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48744. /**
  48745. * Defines the falloff type used in this material.
  48746. * It by default is Physical.
  48747. */
  48748. protected _lightFalloff: number;
  48749. /**
  48750. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48751. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48752. */
  48753. protected _useRadianceOverAlpha: boolean;
  48754. /**
  48755. * Allows using an object space normal map (instead of tangent space).
  48756. */
  48757. protected _useObjectSpaceNormalMap: boolean;
  48758. /**
  48759. * Allows using the bump map in parallax mode.
  48760. */
  48761. protected _useParallax: boolean;
  48762. /**
  48763. * Allows using the bump map in parallax occlusion mode.
  48764. */
  48765. protected _useParallaxOcclusion: boolean;
  48766. /**
  48767. * Controls the scale bias of the parallax mode.
  48768. */
  48769. protected _parallaxScaleBias: number;
  48770. /**
  48771. * If sets to true, disables all the lights affecting the material.
  48772. */
  48773. protected _disableLighting: boolean;
  48774. /**
  48775. * Number of Simultaneous lights allowed on the material.
  48776. */
  48777. protected _maxSimultaneousLights: number;
  48778. /**
  48779. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48780. */
  48781. protected _invertNormalMapX: boolean;
  48782. /**
  48783. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48784. */
  48785. protected _invertNormalMapY: boolean;
  48786. /**
  48787. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48788. */
  48789. protected _twoSidedLighting: boolean;
  48790. /**
  48791. * Defines the alpha limits in alpha test mode.
  48792. */
  48793. protected _alphaCutOff: number;
  48794. /**
  48795. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48796. */
  48797. protected _forceAlphaTest: boolean;
  48798. /**
  48799. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48800. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48801. */
  48802. protected _useAlphaFresnel: boolean;
  48803. /**
  48804. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48805. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48806. */
  48807. protected _useLinearAlphaFresnel: boolean;
  48808. /**
  48809. * The transparency mode of the material.
  48810. */
  48811. protected _transparencyMode: Nullable<number>;
  48812. /**
  48813. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48814. * from cos thetav and roughness:
  48815. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48816. */
  48817. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48818. /**
  48819. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48820. */
  48821. protected _forceIrradianceInFragment: boolean;
  48822. /**
  48823. * Force normal to face away from face.
  48824. */
  48825. protected _forceNormalForward: boolean;
  48826. /**
  48827. * Enables specular anti aliasing in the PBR shader.
  48828. * It will both interacts on the Geometry for analytical and IBL lighting.
  48829. * It also prefilter the roughness map based on the bump values.
  48830. */
  48831. protected _enableSpecularAntiAliasing: boolean;
  48832. /**
  48833. * Default configuration related to image processing available in the PBR Material.
  48834. */
  48835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48836. /**
  48837. * Keep track of the image processing observer to allow dispose and replace.
  48838. */
  48839. private _imageProcessingObserver;
  48840. /**
  48841. * Attaches a new image processing configuration to the PBR Material.
  48842. * @param configuration
  48843. */
  48844. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48845. /**
  48846. * Stores the available render targets.
  48847. */
  48848. private _renderTargets;
  48849. /**
  48850. * Sets the global ambient color for the material used in lighting calculations.
  48851. */
  48852. private _globalAmbientColor;
  48853. /**
  48854. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48855. */
  48856. private _useLogarithmicDepth;
  48857. /**
  48858. * If set to true, no lighting calculations will be applied.
  48859. */
  48860. private _unlit;
  48861. private _debugMode;
  48862. /**
  48863. * @hidden
  48864. * This is reserved for the inspector.
  48865. * Defines the material debug mode.
  48866. * It helps seeing only some components of the material while troubleshooting.
  48867. */
  48868. debugMode: number;
  48869. /**
  48870. * @hidden
  48871. * This is reserved for the inspector.
  48872. * Specify from where on screen the debug mode should start.
  48873. * The value goes from -1 (full screen) to 1 (not visible)
  48874. * It helps with side by side comparison against the final render
  48875. * This defaults to -1
  48876. */
  48877. private debugLimit;
  48878. /**
  48879. * @hidden
  48880. * This is reserved for the inspector.
  48881. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48882. * You can use the factor to better multiply the final value.
  48883. */
  48884. private debugFactor;
  48885. /**
  48886. * Defines the clear coat layer parameters for the material.
  48887. */
  48888. readonly clearCoat: PBRClearCoatConfiguration;
  48889. /**
  48890. * Defines the anisotropic parameters for the material.
  48891. */
  48892. readonly anisotropy: PBRAnisotropicConfiguration;
  48893. /**
  48894. * Defines the BRDF parameters for the material.
  48895. */
  48896. readonly brdf: PBRBRDFConfiguration;
  48897. /**
  48898. * Defines the Sheen parameters for the material.
  48899. */
  48900. readonly sheen: PBRSheenConfiguration;
  48901. /**
  48902. * Defines the SubSurface parameters for the material.
  48903. */
  48904. readonly subSurface: PBRSubSurfaceConfiguration;
  48905. /**
  48906. * Custom callback helping to override the default shader used in the material.
  48907. */
  48908. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48909. /**
  48910. * Instantiates a new PBRMaterial instance.
  48911. *
  48912. * @param name The material name
  48913. * @param scene The scene the material will be use in.
  48914. */
  48915. constructor(name: string, scene: Scene);
  48916. /**
  48917. * Gets a boolean indicating that current material needs to register RTT
  48918. */
  48919. readonly hasRenderTargetTextures: boolean;
  48920. /**
  48921. * Gets the name of the material class.
  48922. */
  48923. getClassName(): string;
  48924. /**
  48925. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48926. */
  48927. /**
  48928. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48929. */
  48930. useLogarithmicDepth: boolean;
  48931. /**
  48932. * Gets the current transparency mode.
  48933. */
  48934. /**
  48935. * Sets the transparency mode of the material.
  48936. *
  48937. * | Value | Type | Description |
  48938. * | ----- | ----------------------------------- | ----------- |
  48939. * | 0 | OPAQUE | |
  48940. * | 1 | ALPHATEST | |
  48941. * | 2 | ALPHABLEND | |
  48942. * | 3 | ALPHATESTANDBLEND | |
  48943. *
  48944. */
  48945. transparencyMode: Nullable<number>;
  48946. /**
  48947. * Returns true if alpha blending should be disabled.
  48948. */
  48949. private readonly _disableAlphaBlending;
  48950. /**
  48951. * Specifies whether or not this material should be rendered in alpha blend mode.
  48952. */
  48953. needAlphaBlending(): boolean;
  48954. /**
  48955. * Specifies if the mesh will require alpha blending.
  48956. * @param mesh - BJS mesh.
  48957. */
  48958. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48959. /**
  48960. * Specifies whether or not this material should be rendered in alpha test mode.
  48961. */
  48962. needAlphaTesting(): boolean;
  48963. /**
  48964. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48965. */
  48966. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48967. /**
  48968. * Gets the texture used for the alpha test.
  48969. */
  48970. getAlphaTestTexture(): Nullable<BaseTexture>;
  48971. /**
  48972. * Specifies that the submesh is ready to be used.
  48973. * @param mesh - BJS mesh.
  48974. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48975. * @param useInstances - Specifies that instances should be used.
  48976. * @returns - boolean indicating that the submesh is ready or not.
  48977. */
  48978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48979. /**
  48980. * Specifies if the material uses metallic roughness workflow.
  48981. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48982. */
  48983. isMetallicWorkflow(): boolean;
  48984. private _prepareEffect;
  48985. private _prepareDefines;
  48986. /**
  48987. * Force shader compilation
  48988. */
  48989. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48990. clipPlane: boolean;
  48991. }>): void;
  48992. /**
  48993. * Initializes the uniform buffer layout for the shader.
  48994. */
  48995. buildUniformLayout(): void;
  48996. /**
  48997. * Unbinds the material from the mesh
  48998. */
  48999. unbind(): void;
  49000. /**
  49001. * Binds the submesh data.
  49002. * @param world - The world matrix.
  49003. * @param mesh - The BJS mesh.
  49004. * @param subMesh - A submesh of the BJS mesh.
  49005. */
  49006. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49007. /**
  49008. * Returns the animatable textures.
  49009. * @returns - Array of animatable textures.
  49010. */
  49011. getAnimatables(): IAnimatable[];
  49012. /**
  49013. * Returns the texture used for reflections.
  49014. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49015. */
  49016. private _getReflectionTexture;
  49017. /**
  49018. * Returns an array of the actively used textures.
  49019. * @returns - Array of BaseTextures
  49020. */
  49021. getActiveTextures(): BaseTexture[];
  49022. /**
  49023. * Checks to see if a texture is used in the material.
  49024. * @param texture - Base texture to use.
  49025. * @returns - Boolean specifying if a texture is used in the material.
  49026. */
  49027. hasTexture(texture: BaseTexture): boolean;
  49028. /**
  49029. * Disposes the resources of the material.
  49030. * @param forceDisposeEffect - Forces the disposal of effects.
  49031. * @param forceDisposeTextures - Forces the disposal of all textures.
  49032. */
  49033. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49034. }
  49035. }
  49036. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49037. import { Nullable } from "babylonjs/types";
  49038. import { Scene } from "babylonjs/scene";
  49039. import { Color3 } from "babylonjs/Maths/math.color";
  49040. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49041. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49043. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49044. /**
  49045. * The Physically based material of BJS.
  49046. *
  49047. * This offers the main features of a standard PBR material.
  49048. * For more information, please refer to the documentation :
  49049. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49050. */
  49051. export class PBRMaterial extends PBRBaseMaterial {
  49052. /**
  49053. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49054. */
  49055. static readonly PBRMATERIAL_OPAQUE: number;
  49056. /**
  49057. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49058. */
  49059. static readonly PBRMATERIAL_ALPHATEST: number;
  49060. /**
  49061. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49062. */
  49063. static readonly PBRMATERIAL_ALPHABLEND: number;
  49064. /**
  49065. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49066. * They are also discarded below the alpha cutoff threshold to improve performances.
  49067. */
  49068. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49069. /**
  49070. * Defines the default value of how much AO map is occluding the analytical lights
  49071. * (point spot...).
  49072. */
  49073. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49074. /**
  49075. * Intensity of the direct lights e.g. the four lights available in your scene.
  49076. * This impacts both the direct diffuse and specular highlights.
  49077. */
  49078. directIntensity: number;
  49079. /**
  49080. * Intensity of the emissive part of the material.
  49081. * This helps controlling the emissive effect without modifying the emissive color.
  49082. */
  49083. emissiveIntensity: number;
  49084. /**
  49085. * Intensity of the environment e.g. how much the environment will light the object
  49086. * either through harmonics for rough material or through the refelction for shiny ones.
  49087. */
  49088. environmentIntensity: number;
  49089. /**
  49090. * This is a special control allowing the reduction of the specular highlights coming from the
  49091. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49092. */
  49093. specularIntensity: number;
  49094. /**
  49095. * Debug Control allowing disabling the bump map on this material.
  49096. */
  49097. disableBumpMap: boolean;
  49098. /**
  49099. * AKA Diffuse Texture in standard nomenclature.
  49100. */
  49101. albedoTexture: BaseTexture;
  49102. /**
  49103. * AKA Occlusion Texture in other nomenclature.
  49104. */
  49105. ambientTexture: BaseTexture;
  49106. /**
  49107. * AKA Occlusion Texture Intensity in other nomenclature.
  49108. */
  49109. ambientTextureStrength: number;
  49110. /**
  49111. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49112. * 1 means it completely occludes it
  49113. * 0 mean it has no impact
  49114. */
  49115. ambientTextureImpactOnAnalyticalLights: number;
  49116. /**
  49117. * Stores the alpha values in a texture.
  49118. */
  49119. opacityTexture: BaseTexture;
  49120. /**
  49121. * Stores the reflection values in a texture.
  49122. */
  49123. reflectionTexture: Nullable<BaseTexture>;
  49124. /**
  49125. * Stores the emissive values in a texture.
  49126. */
  49127. emissiveTexture: BaseTexture;
  49128. /**
  49129. * AKA Specular texture in other nomenclature.
  49130. */
  49131. reflectivityTexture: BaseTexture;
  49132. /**
  49133. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49134. */
  49135. metallicTexture: BaseTexture;
  49136. /**
  49137. * Specifies the metallic scalar of the metallic/roughness workflow.
  49138. * Can also be used to scale the metalness values of the metallic texture.
  49139. */
  49140. metallic: Nullable<number>;
  49141. /**
  49142. * Specifies the roughness scalar of the metallic/roughness workflow.
  49143. * Can also be used to scale the roughness values of the metallic texture.
  49144. */
  49145. roughness: Nullable<number>;
  49146. /**
  49147. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49148. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49149. */
  49150. microSurfaceTexture: BaseTexture;
  49151. /**
  49152. * Stores surface normal data used to displace a mesh in a texture.
  49153. */
  49154. bumpTexture: BaseTexture;
  49155. /**
  49156. * Stores the pre-calculated light information of a mesh in a texture.
  49157. */
  49158. lightmapTexture: BaseTexture;
  49159. /**
  49160. * Stores the refracted light information in a texture.
  49161. */
  49162. refractionTexture: Nullable<BaseTexture>;
  49163. /**
  49164. * The color of a material in ambient lighting.
  49165. */
  49166. ambientColor: Color3;
  49167. /**
  49168. * AKA Diffuse Color in other nomenclature.
  49169. */
  49170. albedoColor: Color3;
  49171. /**
  49172. * AKA Specular Color in other nomenclature.
  49173. */
  49174. reflectivityColor: Color3;
  49175. /**
  49176. * The color reflected from the material.
  49177. */
  49178. reflectionColor: Color3;
  49179. /**
  49180. * The color emitted from the material.
  49181. */
  49182. emissiveColor: Color3;
  49183. /**
  49184. * AKA Glossiness in other nomenclature.
  49185. */
  49186. microSurface: number;
  49187. /**
  49188. * source material index of refraction (IOR)' / 'destination material IOR.
  49189. */
  49190. indexOfRefraction: number;
  49191. /**
  49192. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49193. */
  49194. invertRefractionY: boolean;
  49195. /**
  49196. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49197. * Materials half opaque for instance using refraction could benefit from this control.
  49198. */
  49199. linkRefractionWithTransparency: boolean;
  49200. /**
  49201. * If true, the light map contains occlusion information instead of lighting info.
  49202. */
  49203. useLightmapAsShadowmap: boolean;
  49204. /**
  49205. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49206. */
  49207. useAlphaFromAlbedoTexture: boolean;
  49208. /**
  49209. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49210. */
  49211. forceAlphaTest: boolean;
  49212. /**
  49213. * Defines the alpha limits in alpha test mode.
  49214. */
  49215. alphaCutOff: number;
  49216. /**
  49217. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49218. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49219. */
  49220. useSpecularOverAlpha: boolean;
  49221. /**
  49222. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49223. */
  49224. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49225. /**
  49226. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49227. */
  49228. useRoughnessFromMetallicTextureAlpha: boolean;
  49229. /**
  49230. * Specifies if the metallic texture contains the roughness information in its green channel.
  49231. */
  49232. useRoughnessFromMetallicTextureGreen: boolean;
  49233. /**
  49234. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49235. */
  49236. useMetallnessFromMetallicTextureBlue: boolean;
  49237. /**
  49238. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49239. */
  49240. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49241. /**
  49242. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49243. */
  49244. useAmbientInGrayScale: boolean;
  49245. /**
  49246. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49247. * The material will try to infer what glossiness each pixel should be.
  49248. */
  49249. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49250. /**
  49251. * BJS is using an harcoded light falloff based on a manually sets up range.
  49252. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49253. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49254. */
  49255. /**
  49256. * BJS is using an harcoded light falloff based on a manually sets up range.
  49257. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49258. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49259. */
  49260. usePhysicalLightFalloff: boolean;
  49261. /**
  49262. * In order to support the falloff compatibility with gltf, a special mode has been added
  49263. * to reproduce the gltf light falloff.
  49264. */
  49265. /**
  49266. * In order to support the falloff compatibility with gltf, a special mode has been added
  49267. * to reproduce the gltf light falloff.
  49268. */
  49269. useGLTFLightFalloff: boolean;
  49270. /**
  49271. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49272. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49273. */
  49274. useRadianceOverAlpha: boolean;
  49275. /**
  49276. * Allows using an object space normal map (instead of tangent space).
  49277. */
  49278. useObjectSpaceNormalMap: boolean;
  49279. /**
  49280. * Allows using the bump map in parallax mode.
  49281. */
  49282. useParallax: boolean;
  49283. /**
  49284. * Allows using the bump map in parallax occlusion mode.
  49285. */
  49286. useParallaxOcclusion: boolean;
  49287. /**
  49288. * Controls the scale bias of the parallax mode.
  49289. */
  49290. parallaxScaleBias: number;
  49291. /**
  49292. * If sets to true, disables all the lights affecting the material.
  49293. */
  49294. disableLighting: boolean;
  49295. /**
  49296. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49297. */
  49298. forceIrradianceInFragment: boolean;
  49299. /**
  49300. * Number of Simultaneous lights allowed on the material.
  49301. */
  49302. maxSimultaneousLights: number;
  49303. /**
  49304. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49305. */
  49306. invertNormalMapX: boolean;
  49307. /**
  49308. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49309. */
  49310. invertNormalMapY: boolean;
  49311. /**
  49312. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49313. */
  49314. twoSidedLighting: boolean;
  49315. /**
  49316. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49317. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49318. */
  49319. useAlphaFresnel: boolean;
  49320. /**
  49321. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49322. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49323. */
  49324. useLinearAlphaFresnel: boolean;
  49325. /**
  49326. * Let user defines the brdf lookup texture used for IBL.
  49327. * A default 8bit version is embedded but you could point at :
  49328. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49329. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49330. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49331. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49332. */
  49333. environmentBRDFTexture: Nullable<BaseTexture>;
  49334. /**
  49335. * Force normal to face away from face.
  49336. */
  49337. forceNormalForward: boolean;
  49338. /**
  49339. * Enables specular anti aliasing in the PBR shader.
  49340. * It will both interacts on the Geometry for analytical and IBL lighting.
  49341. * It also prefilter the roughness map based on the bump values.
  49342. */
  49343. enableSpecularAntiAliasing: boolean;
  49344. /**
  49345. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49346. * makes the reflect vector face the model (under horizon).
  49347. */
  49348. useHorizonOcclusion: boolean;
  49349. /**
  49350. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49351. * too much the area relying on ambient texture to define their ambient occlusion.
  49352. */
  49353. useRadianceOcclusion: boolean;
  49354. /**
  49355. * If set to true, no lighting calculations will be applied.
  49356. */
  49357. unlit: boolean;
  49358. /**
  49359. * Gets the image processing configuration used either in this material.
  49360. */
  49361. /**
  49362. * Sets the Default image processing configuration used either in the this material.
  49363. *
  49364. * If sets to null, the scene one is in use.
  49365. */
  49366. imageProcessingConfiguration: ImageProcessingConfiguration;
  49367. /**
  49368. * Gets wether the color curves effect is enabled.
  49369. */
  49370. /**
  49371. * Sets wether the color curves effect is enabled.
  49372. */
  49373. cameraColorCurvesEnabled: boolean;
  49374. /**
  49375. * Gets wether the color grading effect is enabled.
  49376. */
  49377. /**
  49378. * Gets wether the color grading effect is enabled.
  49379. */
  49380. cameraColorGradingEnabled: boolean;
  49381. /**
  49382. * Gets wether tonemapping is enabled or not.
  49383. */
  49384. /**
  49385. * Sets wether tonemapping is enabled or not
  49386. */
  49387. cameraToneMappingEnabled: boolean;
  49388. /**
  49389. * The camera exposure used on this material.
  49390. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49391. * This corresponds to a photographic exposure.
  49392. */
  49393. /**
  49394. * The camera exposure used on this material.
  49395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49396. * This corresponds to a photographic exposure.
  49397. */
  49398. cameraExposure: number;
  49399. /**
  49400. * Gets The camera contrast used on this material.
  49401. */
  49402. /**
  49403. * Sets The camera contrast used on this material.
  49404. */
  49405. cameraContrast: number;
  49406. /**
  49407. * Gets the Color Grading 2D Lookup Texture.
  49408. */
  49409. /**
  49410. * Sets the Color Grading 2D Lookup Texture.
  49411. */
  49412. cameraColorGradingTexture: Nullable<BaseTexture>;
  49413. /**
  49414. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49415. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49416. * 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;
  49417. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49418. */
  49419. /**
  49420. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49421. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49422. * 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;
  49423. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49424. */
  49425. cameraColorCurves: Nullable<ColorCurves>;
  49426. /**
  49427. * Instantiates a new PBRMaterial instance.
  49428. *
  49429. * @param name The material name
  49430. * @param scene The scene the material will be use in.
  49431. */
  49432. constructor(name: string, scene: Scene);
  49433. /**
  49434. * Returns the name of this material class.
  49435. */
  49436. getClassName(): string;
  49437. /**
  49438. * Makes a duplicate of the current material.
  49439. * @param name - name to use for the new material.
  49440. */
  49441. clone(name: string): PBRMaterial;
  49442. /**
  49443. * Serializes this PBR Material.
  49444. * @returns - An object with the serialized material.
  49445. */
  49446. serialize(): any;
  49447. /**
  49448. * Parses a PBR Material from a serialized object.
  49449. * @param source - Serialized object.
  49450. * @param scene - BJS scene instance.
  49451. * @param rootUrl - url for the scene object
  49452. * @returns - PBRMaterial
  49453. */
  49454. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49455. }
  49456. }
  49457. declare module "babylonjs/Misc/dds" {
  49458. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49459. import { Engine } from "babylonjs/Engines/engine";
  49460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49461. import { Nullable } from "babylonjs/types";
  49462. import { Scene } from "babylonjs/scene";
  49463. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49464. /**
  49465. * Direct draw surface info
  49466. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49467. */
  49468. export interface DDSInfo {
  49469. /**
  49470. * Width of the texture
  49471. */
  49472. width: number;
  49473. /**
  49474. * Width of the texture
  49475. */
  49476. height: number;
  49477. /**
  49478. * Number of Mipmaps for the texture
  49479. * @see https://en.wikipedia.org/wiki/Mipmap
  49480. */
  49481. mipmapCount: number;
  49482. /**
  49483. * If the textures format is a known fourCC format
  49484. * @see https://www.fourcc.org/
  49485. */
  49486. isFourCC: boolean;
  49487. /**
  49488. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49489. */
  49490. isRGB: boolean;
  49491. /**
  49492. * If the texture is a lumincance format
  49493. */
  49494. isLuminance: boolean;
  49495. /**
  49496. * If this is a cube texture
  49497. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49498. */
  49499. isCube: boolean;
  49500. /**
  49501. * If the texture is a compressed format eg. FOURCC_DXT1
  49502. */
  49503. isCompressed: boolean;
  49504. /**
  49505. * The dxgiFormat of the texture
  49506. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49507. */
  49508. dxgiFormat: number;
  49509. /**
  49510. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49511. */
  49512. textureType: number;
  49513. /**
  49514. * Sphericle polynomial created for the dds texture
  49515. */
  49516. sphericalPolynomial?: SphericalPolynomial;
  49517. }
  49518. /**
  49519. * Class used to provide DDS decompression tools
  49520. */
  49521. export class DDSTools {
  49522. /**
  49523. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49524. */
  49525. static StoreLODInAlphaChannel: boolean;
  49526. /**
  49527. * Gets DDS information from an array buffer
  49528. * @param arrayBuffer defines the array buffer to read data from
  49529. * @returns the DDS information
  49530. */
  49531. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49532. private static _FloatView;
  49533. private static _Int32View;
  49534. private static _ToHalfFloat;
  49535. private static _FromHalfFloat;
  49536. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49537. private static _GetHalfFloatRGBAArrayBuffer;
  49538. private static _GetFloatRGBAArrayBuffer;
  49539. private static _GetFloatAsUIntRGBAArrayBuffer;
  49540. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49541. private static _GetRGBAArrayBuffer;
  49542. private static _ExtractLongWordOrder;
  49543. private static _GetRGBArrayBuffer;
  49544. private static _GetLuminanceArrayBuffer;
  49545. /**
  49546. * Uploads DDS Levels to a Babylon Texture
  49547. * @hidden
  49548. */
  49549. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49550. }
  49551. module "babylonjs/Engines/engine" {
  49552. interface Engine {
  49553. /**
  49554. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49555. * @param rootUrl defines the url where the file to load is located
  49556. * @param scene defines the current scene
  49557. * @param lodScale defines scale to apply to the mip map selection
  49558. * @param lodOffset defines offset to apply to the mip map selection
  49559. * @param onLoad defines an optional callback raised when the texture is loaded
  49560. * @param onError defines an optional callback raised if there is an issue to load the texture
  49561. * @param format defines the format of the data
  49562. * @param forcedExtension defines the extension to use to pick the right loader
  49563. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49564. * @returns the cube texture as an InternalTexture
  49565. */
  49566. 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;
  49567. }
  49568. }
  49569. }
  49570. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49571. import { Nullable } from "babylonjs/types";
  49572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49573. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49574. /**
  49575. * Implementation of the DDS Texture Loader.
  49576. * @hidden
  49577. */
  49578. export class _DDSTextureLoader implements IInternalTextureLoader {
  49579. /**
  49580. * Defines wether the loader supports cascade loading the different faces.
  49581. */
  49582. readonly supportCascades: boolean;
  49583. /**
  49584. * This returns if the loader support the current file information.
  49585. * @param extension defines the file extension of the file being loaded
  49586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49587. * @param fallback defines the fallback internal texture if any
  49588. * @param isBase64 defines whether the texture is encoded as a base64
  49589. * @param isBuffer defines whether the texture data are stored as a buffer
  49590. * @returns true if the loader can load the specified file
  49591. */
  49592. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49593. /**
  49594. * Transform the url before loading if required.
  49595. * @param rootUrl the url of the texture
  49596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49597. * @returns the transformed texture
  49598. */
  49599. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49600. /**
  49601. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49602. * @param rootUrl the url of the texture
  49603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49604. * @returns the fallback texture
  49605. */
  49606. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49607. /**
  49608. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49609. * @param data contains the texture data
  49610. * @param texture defines the BabylonJS internal texture
  49611. * @param createPolynomials will be true if polynomials have been requested
  49612. * @param onLoad defines the callback to trigger once the texture is ready
  49613. * @param onError defines the callback to trigger in case of error
  49614. */
  49615. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49616. /**
  49617. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49618. * @param data contains the texture data
  49619. * @param texture defines the BabylonJS internal texture
  49620. * @param callback defines the method to call once ready to upload
  49621. */
  49622. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49623. }
  49624. }
  49625. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49627. /** @hidden */
  49628. export var rgbdEncodePixelShader: {
  49629. name: string;
  49630. shader: string;
  49631. };
  49632. }
  49633. declare module "babylonjs/Misc/environmentTextureTools" {
  49634. import { Nullable } from "babylonjs/types";
  49635. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49636. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49637. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49638. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49639. import "babylonjs/Shaders/rgbdEncode.fragment";
  49640. import "babylonjs/Shaders/rgbdDecode.fragment";
  49641. /**
  49642. * Raw texture data and descriptor sufficient for WebGL texture upload
  49643. */
  49644. export interface EnvironmentTextureInfo {
  49645. /**
  49646. * Version of the environment map
  49647. */
  49648. version: number;
  49649. /**
  49650. * Width of image
  49651. */
  49652. width: number;
  49653. /**
  49654. * Irradiance information stored in the file.
  49655. */
  49656. irradiance: any;
  49657. /**
  49658. * Specular information stored in the file.
  49659. */
  49660. specular: any;
  49661. }
  49662. /**
  49663. * Sets of helpers addressing the serialization and deserialization of environment texture
  49664. * stored in a BabylonJS env file.
  49665. * Those files are usually stored as .env files.
  49666. */
  49667. export class EnvironmentTextureTools {
  49668. /**
  49669. * Magic number identifying the env file.
  49670. */
  49671. private static _MagicBytes;
  49672. /**
  49673. * Gets the environment info from an env file.
  49674. * @param data The array buffer containing the .env bytes.
  49675. * @returns the environment file info (the json header) if successfully parsed.
  49676. */
  49677. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49678. /**
  49679. * Creates an environment texture from a loaded cube texture.
  49680. * @param texture defines the cube texture to convert in env file
  49681. * @return a promise containing the environment data if succesfull.
  49682. */
  49683. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49684. /**
  49685. * Creates a JSON representation of the spherical data.
  49686. * @param texture defines the texture containing the polynomials
  49687. * @return the JSON representation of the spherical info
  49688. */
  49689. private static _CreateEnvTextureIrradiance;
  49690. /**
  49691. * Uploads the texture info contained in the env file to the GPU.
  49692. * @param texture defines the internal texture to upload to
  49693. * @param arrayBuffer defines the buffer cotaining the data to load
  49694. * @param info defines the texture info retrieved through the GetEnvInfo method
  49695. * @returns a promise
  49696. */
  49697. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49698. /**
  49699. * Uploads the levels of image data to the GPU.
  49700. * @param texture defines the internal texture to upload to
  49701. * @param imageData defines the array buffer views of image data [mipmap][face]
  49702. * @returns a promise
  49703. */
  49704. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49705. /**
  49706. * Uploads spherical polynomials information to the texture.
  49707. * @param texture defines the texture we are trying to upload the information to
  49708. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49709. */
  49710. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49711. /** @hidden */
  49712. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49713. }
  49714. }
  49715. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49716. import { Nullable } from "babylonjs/types";
  49717. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49718. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49719. /**
  49720. * Implementation of the ENV Texture Loader.
  49721. * @hidden
  49722. */
  49723. export class _ENVTextureLoader implements IInternalTextureLoader {
  49724. /**
  49725. * Defines wether the loader supports cascade loading the different faces.
  49726. */
  49727. readonly supportCascades: boolean;
  49728. /**
  49729. * This returns if the loader support the current file information.
  49730. * @param extension defines the file extension of the file being loaded
  49731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49732. * @param fallback defines the fallback internal texture if any
  49733. * @param isBase64 defines whether the texture is encoded as a base64
  49734. * @param isBuffer defines whether the texture data are stored as a buffer
  49735. * @returns true if the loader can load the specified file
  49736. */
  49737. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49738. /**
  49739. * Transform the url before loading if required.
  49740. * @param rootUrl the url of the texture
  49741. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49742. * @returns the transformed texture
  49743. */
  49744. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49745. /**
  49746. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49747. * @param rootUrl the url of the texture
  49748. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49749. * @returns the fallback texture
  49750. */
  49751. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49752. /**
  49753. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49754. * @param data contains the texture data
  49755. * @param texture defines the BabylonJS internal texture
  49756. * @param createPolynomials will be true if polynomials have been requested
  49757. * @param onLoad defines the callback to trigger once the texture is ready
  49758. * @param onError defines the callback to trigger in case of error
  49759. */
  49760. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49761. /**
  49762. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49763. * @param data contains the texture data
  49764. * @param texture defines the BabylonJS internal texture
  49765. * @param callback defines the method to call once ready to upload
  49766. */
  49767. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49768. }
  49769. }
  49770. declare module "babylonjs/Misc/khronosTextureContainer" {
  49771. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49772. /**
  49773. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49774. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49775. */
  49776. export class KhronosTextureContainer {
  49777. /** contents of the KTX container file */
  49778. arrayBuffer: any;
  49779. private static HEADER_LEN;
  49780. private static COMPRESSED_2D;
  49781. private static COMPRESSED_3D;
  49782. private static TEX_2D;
  49783. private static TEX_3D;
  49784. /**
  49785. * Gets the openGL type
  49786. */
  49787. glType: number;
  49788. /**
  49789. * Gets the openGL type size
  49790. */
  49791. glTypeSize: number;
  49792. /**
  49793. * Gets the openGL format
  49794. */
  49795. glFormat: number;
  49796. /**
  49797. * Gets the openGL internal format
  49798. */
  49799. glInternalFormat: number;
  49800. /**
  49801. * Gets the base internal format
  49802. */
  49803. glBaseInternalFormat: number;
  49804. /**
  49805. * Gets image width in pixel
  49806. */
  49807. pixelWidth: number;
  49808. /**
  49809. * Gets image height in pixel
  49810. */
  49811. pixelHeight: number;
  49812. /**
  49813. * Gets image depth in pixels
  49814. */
  49815. pixelDepth: number;
  49816. /**
  49817. * Gets the number of array elements
  49818. */
  49819. numberOfArrayElements: number;
  49820. /**
  49821. * Gets the number of faces
  49822. */
  49823. numberOfFaces: number;
  49824. /**
  49825. * Gets the number of mipmap levels
  49826. */
  49827. numberOfMipmapLevels: number;
  49828. /**
  49829. * Gets the bytes of key value data
  49830. */
  49831. bytesOfKeyValueData: number;
  49832. /**
  49833. * Gets the load type
  49834. */
  49835. loadType: number;
  49836. /**
  49837. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49838. */
  49839. isInvalid: boolean;
  49840. /**
  49841. * Creates a new KhronosTextureContainer
  49842. * @param arrayBuffer contents of the KTX container file
  49843. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49844. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49845. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49846. */
  49847. constructor(
  49848. /** contents of the KTX container file */
  49849. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49850. /**
  49851. * Uploads KTX content to a Babylon Texture.
  49852. * It is assumed that the texture has already been created & is currently bound
  49853. * @hidden
  49854. */
  49855. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49856. private _upload2DCompressedLevels;
  49857. }
  49858. }
  49859. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49860. import { Nullable } from "babylonjs/types";
  49861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49862. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49863. /**
  49864. * Implementation of the KTX Texture Loader.
  49865. * @hidden
  49866. */
  49867. export class _KTXTextureLoader implements IInternalTextureLoader {
  49868. /**
  49869. * Defines wether the loader supports cascade loading the different faces.
  49870. */
  49871. readonly supportCascades: boolean;
  49872. /**
  49873. * This returns if the loader support the current file information.
  49874. * @param extension defines the file extension of the file being loaded
  49875. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49876. * @param fallback defines the fallback internal texture if any
  49877. * @param isBase64 defines whether the texture is encoded as a base64
  49878. * @param isBuffer defines whether the texture data are stored as a buffer
  49879. * @returns true if the loader can load the specified file
  49880. */
  49881. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49882. /**
  49883. * Transform the url before loading if required.
  49884. * @param rootUrl the url of the texture
  49885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49886. * @returns the transformed texture
  49887. */
  49888. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49889. /**
  49890. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49891. * @param rootUrl the url of the texture
  49892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49893. * @returns the fallback texture
  49894. */
  49895. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49896. /**
  49897. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49898. * @param data contains the texture data
  49899. * @param texture defines the BabylonJS internal texture
  49900. * @param createPolynomials will be true if polynomials have been requested
  49901. * @param onLoad defines the callback to trigger once the texture is ready
  49902. * @param onError defines the callback to trigger in case of error
  49903. */
  49904. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49905. /**
  49906. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49907. * @param data contains the texture data
  49908. * @param texture defines the BabylonJS internal texture
  49909. * @param callback defines the method to call once ready to upload
  49910. */
  49911. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49912. }
  49913. }
  49914. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49915. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49916. import { Scene } from "babylonjs/scene";
  49917. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49918. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49919. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49920. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49921. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49922. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49924. /**
  49925. * Options for the default xr helper
  49926. */
  49927. export class WebXRDefaultExperienceOptions {
  49928. /**
  49929. * Floor meshes that should be used for teleporting
  49930. */
  49931. floorMeshes: Array<AbstractMesh>;
  49932. }
  49933. /**
  49934. * Default experience which provides a similar setup to the previous webVRExperience
  49935. */
  49936. export class WebXRDefaultExperience {
  49937. /**
  49938. * Base experience
  49939. */
  49940. baseExperience: WebXRExperienceHelper;
  49941. /**
  49942. * Input experience extension
  49943. */
  49944. input: WebXRInput;
  49945. /**
  49946. * Loads the controller models
  49947. */
  49948. controllerModelLoader: WebXRControllerModelLoader;
  49949. /**
  49950. * Enables laser pointer and selection
  49951. */
  49952. pointerSelection: WebXRControllerPointerSelection;
  49953. /**
  49954. * Enables teleportation
  49955. */
  49956. teleportation: WebXRControllerTeleportation;
  49957. /**
  49958. * Enables ui for enetering/exiting xr
  49959. */
  49960. enterExitUI: WebXREnterExitUI;
  49961. /**
  49962. * Default output canvas xr should render to
  49963. */
  49964. outputCanvas: WebXRManagedOutputCanvas;
  49965. /**
  49966. * Creates the default xr experience
  49967. * @param scene scene
  49968. * @param options options for basic configuration
  49969. * @returns resulting WebXRDefaultExperience
  49970. */
  49971. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49972. private constructor();
  49973. /**
  49974. * DIsposes of the experience helper
  49975. */
  49976. dispose(): void;
  49977. }
  49978. }
  49979. declare module "babylonjs/Helpers/sceneHelpers" {
  49980. import { Nullable } from "babylonjs/types";
  49981. import { Mesh } from "babylonjs/Meshes/mesh";
  49982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49983. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49984. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49985. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49986. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49987. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49988. import "babylonjs/Meshes/Builders/boxBuilder";
  49989. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49990. /** @hidden */
  49991. export var _forceSceneHelpersToBundle: boolean;
  49992. module "babylonjs/scene" {
  49993. interface Scene {
  49994. /**
  49995. * Creates a default light for the scene.
  49996. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49997. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49998. */
  49999. createDefaultLight(replace?: boolean): void;
  50000. /**
  50001. * Creates a default camera for the scene.
  50002. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50003. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50004. * @param replace has default false, when true replaces the active camera in the scene
  50005. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50006. */
  50007. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50008. /**
  50009. * Creates a default camera and a default light.
  50010. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50011. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50012. * @param replace has the default false, when true replaces the active camera/light in the scene
  50013. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50014. */
  50015. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50016. /**
  50017. * Creates a new sky box
  50018. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50019. * @param environmentTexture defines the texture to use as environment texture
  50020. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50021. * @param scale defines the overall scale of the skybox
  50022. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50023. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50024. * @returns a new mesh holding the sky box
  50025. */
  50026. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50027. /**
  50028. * Creates a new environment
  50029. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50030. * @param options defines the options you can use to configure the environment
  50031. * @returns the new EnvironmentHelper
  50032. */
  50033. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50034. /**
  50035. * Creates a new VREXperienceHelper
  50036. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50037. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50038. * @returns a new VREXperienceHelper
  50039. */
  50040. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50041. /**
  50042. * Creates a new WebXRDefaultExperience
  50043. * @see http://doc.babylonjs.com/how_to/webxr
  50044. * @param options experience options
  50045. * @returns a promise for a new WebXRDefaultExperience
  50046. */
  50047. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50048. }
  50049. }
  50050. }
  50051. declare module "babylonjs/Maths/math.vertexFormat" {
  50052. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50053. /**
  50054. * Contains position and normal vectors for a vertex
  50055. */
  50056. export class PositionNormalVertex {
  50057. /** the position of the vertex (defaut: 0,0,0) */
  50058. position: Vector3;
  50059. /** the normal of the vertex (defaut: 0,1,0) */
  50060. normal: Vector3;
  50061. /**
  50062. * Creates a PositionNormalVertex
  50063. * @param position the position of the vertex (defaut: 0,0,0)
  50064. * @param normal the normal of the vertex (defaut: 0,1,0)
  50065. */
  50066. constructor(
  50067. /** the position of the vertex (defaut: 0,0,0) */
  50068. position?: Vector3,
  50069. /** the normal of the vertex (defaut: 0,1,0) */
  50070. normal?: Vector3);
  50071. /**
  50072. * Clones the PositionNormalVertex
  50073. * @returns the cloned PositionNormalVertex
  50074. */
  50075. clone(): PositionNormalVertex;
  50076. }
  50077. /**
  50078. * Contains position, normal and uv vectors for a vertex
  50079. */
  50080. export class PositionNormalTextureVertex {
  50081. /** the position of the vertex (defaut: 0,0,0) */
  50082. position: Vector3;
  50083. /** the normal of the vertex (defaut: 0,1,0) */
  50084. normal: Vector3;
  50085. /** the uv of the vertex (default: 0,0) */
  50086. uv: Vector2;
  50087. /**
  50088. * Creates a PositionNormalTextureVertex
  50089. * @param position the position of the vertex (defaut: 0,0,0)
  50090. * @param normal the normal of the vertex (defaut: 0,1,0)
  50091. * @param uv the uv of the vertex (default: 0,0)
  50092. */
  50093. constructor(
  50094. /** the position of the vertex (defaut: 0,0,0) */
  50095. position?: Vector3,
  50096. /** the normal of the vertex (defaut: 0,1,0) */
  50097. normal?: Vector3,
  50098. /** the uv of the vertex (default: 0,0) */
  50099. uv?: Vector2);
  50100. /**
  50101. * Clones the PositionNormalTextureVertex
  50102. * @returns the cloned PositionNormalTextureVertex
  50103. */
  50104. clone(): PositionNormalTextureVertex;
  50105. }
  50106. }
  50107. declare module "babylonjs/Maths/math" {
  50108. export * from "babylonjs/Maths/math.axis";
  50109. export * from "babylonjs/Maths/math.color";
  50110. export * from "babylonjs/Maths/math.constants";
  50111. export * from "babylonjs/Maths/math.frustum";
  50112. export * from "babylonjs/Maths/math.path";
  50113. export * from "babylonjs/Maths/math.plane";
  50114. export * from "babylonjs/Maths/math.size";
  50115. export * from "babylonjs/Maths/math.vector";
  50116. export * from "babylonjs/Maths/math.vertexFormat";
  50117. export * from "babylonjs/Maths/math.viewport";
  50118. }
  50119. declare module "babylonjs/Helpers/videoDome" {
  50120. import { Scene } from "babylonjs/scene";
  50121. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50122. import { Mesh } from "babylonjs/Meshes/mesh";
  50123. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50124. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50125. import "babylonjs/Meshes/Builders/sphereBuilder";
  50126. /**
  50127. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50128. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50129. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50130. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50131. */
  50132. export class VideoDome extends TransformNode {
  50133. /**
  50134. * Define the video source as a Monoscopic panoramic 360 video.
  50135. */
  50136. static readonly MODE_MONOSCOPIC: number;
  50137. /**
  50138. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50139. */
  50140. static readonly MODE_TOPBOTTOM: number;
  50141. /**
  50142. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50143. */
  50144. static readonly MODE_SIDEBYSIDE: number;
  50145. private _halfDome;
  50146. private _useDirectMapping;
  50147. /**
  50148. * The video texture being displayed on the sphere
  50149. */
  50150. protected _videoTexture: VideoTexture;
  50151. /**
  50152. * Gets the video texture being displayed on the sphere
  50153. */
  50154. readonly videoTexture: VideoTexture;
  50155. /**
  50156. * The skybox material
  50157. */
  50158. protected _material: BackgroundMaterial;
  50159. /**
  50160. * The surface used for the skybox
  50161. */
  50162. protected _mesh: Mesh;
  50163. /**
  50164. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50165. */
  50166. private _halfDomeMask;
  50167. /**
  50168. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50169. * Also see the options.resolution property.
  50170. */
  50171. fovMultiplier: number;
  50172. private _videoMode;
  50173. /**
  50174. * Gets or set the current video mode for the video. It can be:
  50175. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50176. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50177. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50178. */
  50179. videoMode: number;
  50180. /**
  50181. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50182. *
  50183. */
  50184. /**
  50185. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50186. */
  50187. halfDome: boolean;
  50188. /**
  50189. * Oberserver used in Stereoscopic VR Mode.
  50190. */
  50191. private _onBeforeCameraRenderObserver;
  50192. /**
  50193. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50194. * @param name Element's name, child elements will append suffixes for their own names.
  50195. * @param urlsOrVideo defines the url(s) or the video element to use
  50196. * @param options An object containing optional or exposed sub element properties
  50197. */
  50198. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50199. resolution?: number;
  50200. clickToPlay?: boolean;
  50201. autoPlay?: boolean;
  50202. loop?: boolean;
  50203. size?: number;
  50204. poster?: string;
  50205. faceForward?: boolean;
  50206. useDirectMapping?: boolean;
  50207. halfDomeMode?: boolean;
  50208. }, scene: Scene);
  50209. private _changeVideoMode;
  50210. /**
  50211. * Releases resources associated with this node.
  50212. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50213. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50214. */
  50215. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50216. }
  50217. }
  50218. declare module "babylonjs/Helpers/index" {
  50219. export * from "babylonjs/Helpers/environmentHelper";
  50220. export * from "babylonjs/Helpers/photoDome";
  50221. export * from "babylonjs/Helpers/sceneHelpers";
  50222. export * from "babylonjs/Helpers/videoDome";
  50223. }
  50224. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50225. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50226. import { IDisposable } from "babylonjs/scene";
  50227. import { Engine } from "babylonjs/Engines/engine";
  50228. /**
  50229. * This class can be used to get instrumentation data from a Babylon engine
  50230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50231. */
  50232. export class EngineInstrumentation implements IDisposable {
  50233. /**
  50234. * Define the instrumented engine.
  50235. */
  50236. engine: Engine;
  50237. private _captureGPUFrameTime;
  50238. private _gpuFrameTimeToken;
  50239. private _gpuFrameTime;
  50240. private _captureShaderCompilationTime;
  50241. private _shaderCompilationTime;
  50242. private _onBeginFrameObserver;
  50243. private _onEndFrameObserver;
  50244. private _onBeforeShaderCompilationObserver;
  50245. private _onAfterShaderCompilationObserver;
  50246. /**
  50247. * Gets the perf counter used for GPU frame time
  50248. */
  50249. readonly gpuFrameTimeCounter: PerfCounter;
  50250. /**
  50251. * Gets the GPU frame time capture status
  50252. */
  50253. /**
  50254. * Enable or disable the GPU frame time capture
  50255. */
  50256. captureGPUFrameTime: boolean;
  50257. /**
  50258. * Gets the perf counter used for shader compilation time
  50259. */
  50260. readonly shaderCompilationTimeCounter: PerfCounter;
  50261. /**
  50262. * Gets the shader compilation time capture status
  50263. */
  50264. /**
  50265. * Enable or disable the shader compilation time capture
  50266. */
  50267. captureShaderCompilationTime: boolean;
  50268. /**
  50269. * Instantiates a new engine instrumentation.
  50270. * This class can be used to get instrumentation data from a Babylon engine
  50271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50272. * @param engine Defines the engine to instrument
  50273. */
  50274. constructor(
  50275. /**
  50276. * Define the instrumented engine.
  50277. */
  50278. engine: Engine);
  50279. /**
  50280. * Dispose and release associated resources.
  50281. */
  50282. dispose(): void;
  50283. }
  50284. }
  50285. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50286. import { Scene, IDisposable } from "babylonjs/scene";
  50287. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50288. /**
  50289. * This class can be used to get instrumentation data from a Babylon engine
  50290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50291. */
  50292. export class SceneInstrumentation implements IDisposable {
  50293. /**
  50294. * Defines the scene to instrument
  50295. */
  50296. scene: Scene;
  50297. private _captureActiveMeshesEvaluationTime;
  50298. private _activeMeshesEvaluationTime;
  50299. private _captureRenderTargetsRenderTime;
  50300. private _renderTargetsRenderTime;
  50301. private _captureFrameTime;
  50302. private _frameTime;
  50303. private _captureRenderTime;
  50304. private _renderTime;
  50305. private _captureInterFrameTime;
  50306. private _interFrameTime;
  50307. private _captureParticlesRenderTime;
  50308. private _particlesRenderTime;
  50309. private _captureSpritesRenderTime;
  50310. private _spritesRenderTime;
  50311. private _capturePhysicsTime;
  50312. private _physicsTime;
  50313. private _captureAnimationsTime;
  50314. private _animationsTime;
  50315. private _captureCameraRenderTime;
  50316. private _cameraRenderTime;
  50317. private _onBeforeActiveMeshesEvaluationObserver;
  50318. private _onAfterActiveMeshesEvaluationObserver;
  50319. private _onBeforeRenderTargetsRenderObserver;
  50320. private _onAfterRenderTargetsRenderObserver;
  50321. private _onAfterRenderObserver;
  50322. private _onBeforeDrawPhaseObserver;
  50323. private _onAfterDrawPhaseObserver;
  50324. private _onBeforeAnimationsObserver;
  50325. private _onBeforeParticlesRenderingObserver;
  50326. private _onAfterParticlesRenderingObserver;
  50327. private _onBeforeSpritesRenderingObserver;
  50328. private _onAfterSpritesRenderingObserver;
  50329. private _onBeforePhysicsObserver;
  50330. private _onAfterPhysicsObserver;
  50331. private _onAfterAnimationsObserver;
  50332. private _onBeforeCameraRenderObserver;
  50333. private _onAfterCameraRenderObserver;
  50334. /**
  50335. * Gets the perf counter used for active meshes evaluation time
  50336. */
  50337. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50338. /**
  50339. * Gets the active meshes evaluation time capture status
  50340. */
  50341. /**
  50342. * Enable or disable the active meshes evaluation time capture
  50343. */
  50344. captureActiveMeshesEvaluationTime: boolean;
  50345. /**
  50346. * Gets the perf counter used for render targets render time
  50347. */
  50348. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50349. /**
  50350. * Gets the render targets render time capture status
  50351. */
  50352. /**
  50353. * Enable or disable the render targets render time capture
  50354. */
  50355. captureRenderTargetsRenderTime: boolean;
  50356. /**
  50357. * Gets the perf counter used for particles render time
  50358. */
  50359. readonly particlesRenderTimeCounter: PerfCounter;
  50360. /**
  50361. * Gets the particles render time capture status
  50362. */
  50363. /**
  50364. * Enable or disable the particles render time capture
  50365. */
  50366. captureParticlesRenderTime: boolean;
  50367. /**
  50368. * Gets the perf counter used for sprites render time
  50369. */
  50370. readonly spritesRenderTimeCounter: PerfCounter;
  50371. /**
  50372. * Gets the sprites render time capture status
  50373. */
  50374. /**
  50375. * Enable or disable the sprites render time capture
  50376. */
  50377. captureSpritesRenderTime: boolean;
  50378. /**
  50379. * Gets the perf counter used for physics time
  50380. */
  50381. readonly physicsTimeCounter: PerfCounter;
  50382. /**
  50383. * Gets the physics time capture status
  50384. */
  50385. /**
  50386. * Enable or disable the physics time capture
  50387. */
  50388. capturePhysicsTime: boolean;
  50389. /**
  50390. * Gets the perf counter used for animations time
  50391. */
  50392. readonly animationsTimeCounter: PerfCounter;
  50393. /**
  50394. * Gets the animations time capture status
  50395. */
  50396. /**
  50397. * Enable or disable the animations time capture
  50398. */
  50399. captureAnimationsTime: boolean;
  50400. /**
  50401. * Gets the perf counter used for frame time capture
  50402. */
  50403. readonly frameTimeCounter: PerfCounter;
  50404. /**
  50405. * Gets the frame time capture status
  50406. */
  50407. /**
  50408. * Enable or disable the frame time capture
  50409. */
  50410. captureFrameTime: boolean;
  50411. /**
  50412. * Gets the perf counter used for inter-frames time capture
  50413. */
  50414. readonly interFrameTimeCounter: PerfCounter;
  50415. /**
  50416. * Gets the inter-frames time capture status
  50417. */
  50418. /**
  50419. * Enable or disable the inter-frames time capture
  50420. */
  50421. captureInterFrameTime: boolean;
  50422. /**
  50423. * Gets the perf counter used for render time capture
  50424. */
  50425. readonly renderTimeCounter: PerfCounter;
  50426. /**
  50427. * Gets the render time capture status
  50428. */
  50429. /**
  50430. * Enable or disable the render time capture
  50431. */
  50432. captureRenderTime: boolean;
  50433. /**
  50434. * Gets the perf counter used for camera render time capture
  50435. */
  50436. readonly cameraRenderTimeCounter: PerfCounter;
  50437. /**
  50438. * Gets the camera render time capture status
  50439. */
  50440. /**
  50441. * Enable or disable the camera render time capture
  50442. */
  50443. captureCameraRenderTime: boolean;
  50444. /**
  50445. * Gets the perf counter used for draw calls
  50446. */
  50447. readonly drawCallsCounter: PerfCounter;
  50448. /**
  50449. * Instantiates a new scene instrumentation.
  50450. * This class can be used to get instrumentation data from a Babylon engine
  50451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50452. * @param scene Defines the scene to instrument
  50453. */
  50454. constructor(
  50455. /**
  50456. * Defines the scene to instrument
  50457. */
  50458. scene: Scene);
  50459. /**
  50460. * Dispose and release associated resources.
  50461. */
  50462. dispose(): void;
  50463. }
  50464. }
  50465. declare module "babylonjs/Instrumentation/index" {
  50466. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50467. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50468. export * from "babylonjs/Instrumentation/timeToken";
  50469. }
  50470. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50471. /** @hidden */
  50472. export var glowMapGenerationPixelShader: {
  50473. name: string;
  50474. shader: string;
  50475. };
  50476. }
  50477. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50478. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50479. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50480. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50481. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50483. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50484. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50485. /** @hidden */
  50486. export var glowMapGenerationVertexShader: {
  50487. name: string;
  50488. shader: string;
  50489. };
  50490. }
  50491. declare module "babylonjs/Layers/effectLayer" {
  50492. import { Observable } from "babylonjs/Misc/observable";
  50493. import { Nullable } from "babylonjs/types";
  50494. import { Camera } from "babylonjs/Cameras/camera";
  50495. import { Scene } from "babylonjs/scene";
  50496. import { ISize } from "babylonjs/Maths/math.size";
  50497. import { Color4 } from "babylonjs/Maths/math.color";
  50498. import { Engine } from "babylonjs/Engines/engine";
  50499. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50501. import { Mesh } from "babylonjs/Meshes/mesh";
  50502. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50504. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50505. import { Effect } from "babylonjs/Materials/effect";
  50506. import { Material } from "babylonjs/Materials/material";
  50507. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50508. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50509. /**
  50510. * Effect layer options. This helps customizing the behaviour
  50511. * of the effect layer.
  50512. */
  50513. export interface IEffectLayerOptions {
  50514. /**
  50515. * Multiplication factor apply to the canvas size to compute the render target size
  50516. * used to generated the objects (the smaller the faster).
  50517. */
  50518. mainTextureRatio: number;
  50519. /**
  50520. * Enforces a fixed size texture to ensure effect stability across devices.
  50521. */
  50522. mainTextureFixedSize?: number;
  50523. /**
  50524. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50525. */
  50526. alphaBlendingMode: number;
  50527. /**
  50528. * The camera attached to the layer.
  50529. */
  50530. camera: Nullable<Camera>;
  50531. /**
  50532. * The rendering group to draw the layer in.
  50533. */
  50534. renderingGroupId: number;
  50535. }
  50536. /**
  50537. * The effect layer Helps adding post process effect blended with the main pass.
  50538. *
  50539. * This can be for instance use to generate glow or higlight effects on the scene.
  50540. *
  50541. * The effect layer class can not be used directly and is intented to inherited from to be
  50542. * customized per effects.
  50543. */
  50544. export abstract class EffectLayer {
  50545. private _vertexBuffers;
  50546. private _indexBuffer;
  50547. private _cachedDefines;
  50548. private _effectLayerMapGenerationEffect;
  50549. private _effectLayerOptions;
  50550. private _mergeEffect;
  50551. protected _scene: Scene;
  50552. protected _engine: Engine;
  50553. protected _maxSize: number;
  50554. protected _mainTextureDesiredSize: ISize;
  50555. protected _mainTexture: RenderTargetTexture;
  50556. protected _shouldRender: boolean;
  50557. protected _postProcesses: PostProcess[];
  50558. protected _textures: BaseTexture[];
  50559. protected _emissiveTextureAndColor: {
  50560. texture: Nullable<BaseTexture>;
  50561. color: Color4;
  50562. };
  50563. /**
  50564. * The name of the layer
  50565. */
  50566. name: string;
  50567. /**
  50568. * The clear color of the texture used to generate the glow map.
  50569. */
  50570. neutralColor: Color4;
  50571. /**
  50572. * Specifies wether the highlight layer is enabled or not.
  50573. */
  50574. isEnabled: boolean;
  50575. /**
  50576. * Gets the camera attached to the layer.
  50577. */
  50578. readonly camera: Nullable<Camera>;
  50579. /**
  50580. * Gets the rendering group id the layer should render in.
  50581. */
  50582. renderingGroupId: number;
  50583. /**
  50584. * An event triggered when the effect layer has been disposed.
  50585. */
  50586. onDisposeObservable: Observable<EffectLayer>;
  50587. /**
  50588. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50589. */
  50590. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50591. /**
  50592. * An event triggered when the generated texture is being merged in the scene.
  50593. */
  50594. onBeforeComposeObservable: Observable<EffectLayer>;
  50595. /**
  50596. * An event triggered when the generated texture has been merged in the scene.
  50597. */
  50598. onAfterComposeObservable: Observable<EffectLayer>;
  50599. /**
  50600. * An event triggered when the efffect layer changes its size.
  50601. */
  50602. onSizeChangedObservable: Observable<EffectLayer>;
  50603. /** @hidden */
  50604. static _SceneComponentInitialization: (scene: Scene) => void;
  50605. /**
  50606. * Instantiates a new effect Layer and references it in the scene.
  50607. * @param name The name of the layer
  50608. * @param scene The scene to use the layer in
  50609. */
  50610. constructor(
  50611. /** The Friendly of the effect in the scene */
  50612. name: string, scene: Scene);
  50613. /**
  50614. * Get the effect name of the layer.
  50615. * @return The effect name
  50616. */
  50617. abstract getEffectName(): string;
  50618. /**
  50619. * Checks for the readiness of the element composing the layer.
  50620. * @param subMesh the mesh to check for
  50621. * @param useInstances specify wether or not to use instances to render the mesh
  50622. * @return true if ready otherwise, false
  50623. */
  50624. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50625. /**
  50626. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50627. * @returns true if the effect requires stencil during the main canvas render pass.
  50628. */
  50629. abstract needStencil(): boolean;
  50630. /**
  50631. * Create the merge effect. This is the shader use to blit the information back
  50632. * to the main canvas at the end of the scene rendering.
  50633. * @returns The effect containing the shader used to merge the effect on the main canvas
  50634. */
  50635. protected abstract _createMergeEffect(): Effect;
  50636. /**
  50637. * Creates the render target textures and post processes used in the effect layer.
  50638. */
  50639. protected abstract _createTextureAndPostProcesses(): void;
  50640. /**
  50641. * Implementation specific of rendering the generating effect on the main canvas.
  50642. * @param effect The effect used to render through
  50643. */
  50644. protected abstract _internalRender(effect: Effect): void;
  50645. /**
  50646. * Sets the required values for both the emissive texture and and the main color.
  50647. */
  50648. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50649. /**
  50650. * Free any resources and references associated to a mesh.
  50651. * Internal use
  50652. * @param mesh The mesh to free.
  50653. */
  50654. abstract _disposeMesh(mesh: Mesh): void;
  50655. /**
  50656. * Serializes this layer (Glow or Highlight for example)
  50657. * @returns a serialized layer object
  50658. */
  50659. abstract serialize?(): any;
  50660. /**
  50661. * Initializes the effect layer with the required options.
  50662. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50663. */
  50664. protected _init(options: Partial<IEffectLayerOptions>): void;
  50665. /**
  50666. * Generates the index buffer of the full screen quad blending to the main canvas.
  50667. */
  50668. private _generateIndexBuffer;
  50669. /**
  50670. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50671. */
  50672. private _generateVertexBuffer;
  50673. /**
  50674. * Sets the main texture desired size which is the closest power of two
  50675. * of the engine canvas size.
  50676. */
  50677. private _setMainTextureSize;
  50678. /**
  50679. * Creates the main texture for the effect layer.
  50680. */
  50681. protected _createMainTexture(): void;
  50682. /**
  50683. * Adds specific effects defines.
  50684. * @param defines The defines to add specifics to.
  50685. */
  50686. protected _addCustomEffectDefines(defines: string[]): void;
  50687. /**
  50688. * Checks for the readiness of the element composing the layer.
  50689. * @param subMesh the mesh to check for
  50690. * @param useInstances specify wether or not to use instances to render the mesh
  50691. * @param emissiveTexture the associated emissive texture used to generate the glow
  50692. * @return true if ready otherwise, false
  50693. */
  50694. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50695. /**
  50696. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50697. */
  50698. render(): void;
  50699. /**
  50700. * Determine if a given mesh will be used in the current effect.
  50701. * @param mesh mesh to test
  50702. * @returns true if the mesh will be used
  50703. */
  50704. hasMesh(mesh: AbstractMesh): boolean;
  50705. /**
  50706. * Returns true if the layer contains information to display, otherwise false.
  50707. * @returns true if the glow layer should be rendered
  50708. */
  50709. shouldRender(): boolean;
  50710. /**
  50711. * Returns true if the mesh should render, otherwise false.
  50712. * @param mesh The mesh to render
  50713. * @returns true if it should render otherwise false
  50714. */
  50715. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50716. /**
  50717. * Returns true if the mesh can be rendered, otherwise false.
  50718. * @param mesh The mesh to render
  50719. * @param material The material used on the mesh
  50720. * @returns true if it can be rendered otherwise false
  50721. */
  50722. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50723. /**
  50724. * Returns true if the mesh should render, otherwise false.
  50725. * @param mesh The mesh to render
  50726. * @returns true if it should render otherwise false
  50727. */
  50728. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50729. /**
  50730. * Renders the submesh passed in parameter to the generation map.
  50731. */
  50732. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50733. /**
  50734. * Rebuild the required buffers.
  50735. * @hidden Internal use only.
  50736. */
  50737. _rebuild(): void;
  50738. /**
  50739. * Dispose only the render target textures and post process.
  50740. */
  50741. private _disposeTextureAndPostProcesses;
  50742. /**
  50743. * Dispose the highlight layer and free resources.
  50744. */
  50745. dispose(): void;
  50746. /**
  50747. * Gets the class name of the effect layer
  50748. * @returns the string with the class name of the effect layer
  50749. */
  50750. getClassName(): string;
  50751. /**
  50752. * Creates an effect layer from parsed effect layer data
  50753. * @param parsedEffectLayer defines effect layer data
  50754. * @param scene defines the current scene
  50755. * @param rootUrl defines the root URL containing the effect layer information
  50756. * @returns a parsed effect Layer
  50757. */
  50758. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50759. }
  50760. }
  50761. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50762. import { Scene } from "babylonjs/scene";
  50763. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50764. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50765. import { AbstractScene } from "babylonjs/abstractScene";
  50766. module "babylonjs/abstractScene" {
  50767. interface AbstractScene {
  50768. /**
  50769. * The list of effect layers (highlights/glow) added to the scene
  50770. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50771. * @see http://doc.babylonjs.com/how_to/glow_layer
  50772. */
  50773. effectLayers: Array<EffectLayer>;
  50774. /**
  50775. * Removes the given effect layer from this scene.
  50776. * @param toRemove defines the effect layer to remove
  50777. * @returns the index of the removed effect layer
  50778. */
  50779. removeEffectLayer(toRemove: EffectLayer): number;
  50780. /**
  50781. * Adds the given effect layer to this scene
  50782. * @param newEffectLayer defines the effect layer to add
  50783. */
  50784. addEffectLayer(newEffectLayer: EffectLayer): void;
  50785. }
  50786. }
  50787. /**
  50788. * Defines the layer scene component responsible to manage any effect layers
  50789. * in a given scene.
  50790. */
  50791. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50792. /**
  50793. * The component name helpfull to identify the component in the list of scene components.
  50794. */
  50795. readonly name: string;
  50796. /**
  50797. * The scene the component belongs to.
  50798. */
  50799. scene: Scene;
  50800. private _engine;
  50801. private _renderEffects;
  50802. private _needStencil;
  50803. private _previousStencilState;
  50804. /**
  50805. * Creates a new instance of the component for the given scene
  50806. * @param scene Defines the scene to register the component in
  50807. */
  50808. constructor(scene: Scene);
  50809. /**
  50810. * Registers the component in a given scene
  50811. */
  50812. register(): void;
  50813. /**
  50814. * Rebuilds the elements related to this component in case of
  50815. * context lost for instance.
  50816. */
  50817. rebuild(): void;
  50818. /**
  50819. * Serializes the component data to the specified json object
  50820. * @param serializationObject The object to serialize to
  50821. */
  50822. serialize(serializationObject: any): void;
  50823. /**
  50824. * Adds all the elements from the container to the scene
  50825. * @param container the container holding the elements
  50826. */
  50827. addFromContainer(container: AbstractScene): void;
  50828. /**
  50829. * Removes all the elements in the container from the scene
  50830. * @param container contains the elements to remove
  50831. * @param dispose if the removed element should be disposed (default: false)
  50832. */
  50833. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50834. /**
  50835. * Disposes the component and the associated ressources.
  50836. */
  50837. dispose(): void;
  50838. private _isReadyForMesh;
  50839. private _renderMainTexture;
  50840. private _setStencil;
  50841. private _setStencilBack;
  50842. private _draw;
  50843. private _drawCamera;
  50844. private _drawRenderingGroup;
  50845. }
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50848. /** @hidden */
  50849. export var glowMapMergePixelShader: {
  50850. name: string;
  50851. shader: string;
  50852. };
  50853. }
  50854. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50855. /** @hidden */
  50856. export var glowMapMergeVertexShader: {
  50857. name: string;
  50858. shader: string;
  50859. };
  50860. }
  50861. declare module "babylonjs/Layers/glowLayer" {
  50862. import { Nullable } from "babylonjs/types";
  50863. import { Camera } from "babylonjs/Cameras/camera";
  50864. import { Scene } from "babylonjs/scene";
  50865. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50867. import { Mesh } from "babylonjs/Meshes/mesh";
  50868. import { Texture } from "babylonjs/Materials/Textures/texture";
  50869. import { Effect } from "babylonjs/Materials/effect";
  50870. import { Material } from "babylonjs/Materials/material";
  50871. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50872. import { Color4 } from "babylonjs/Maths/math.color";
  50873. import "babylonjs/Shaders/glowMapMerge.fragment";
  50874. import "babylonjs/Shaders/glowMapMerge.vertex";
  50875. import "babylonjs/Layers/effectLayerSceneComponent";
  50876. module "babylonjs/abstractScene" {
  50877. interface AbstractScene {
  50878. /**
  50879. * Return a the first highlight layer of the scene with a given name.
  50880. * @param name The name of the highlight layer to look for.
  50881. * @return The highlight layer if found otherwise null.
  50882. */
  50883. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50884. }
  50885. }
  50886. /**
  50887. * Glow layer options. This helps customizing the behaviour
  50888. * of the glow layer.
  50889. */
  50890. export interface IGlowLayerOptions {
  50891. /**
  50892. * Multiplication factor apply to the canvas size to compute the render target size
  50893. * used to generated the glowing objects (the smaller the faster).
  50894. */
  50895. mainTextureRatio: number;
  50896. /**
  50897. * Enforces a fixed size texture to ensure resize independant blur.
  50898. */
  50899. mainTextureFixedSize?: number;
  50900. /**
  50901. * How big is the kernel of the blur texture.
  50902. */
  50903. blurKernelSize: number;
  50904. /**
  50905. * The camera attached to the layer.
  50906. */
  50907. camera: Nullable<Camera>;
  50908. /**
  50909. * Enable MSAA by chosing the number of samples.
  50910. */
  50911. mainTextureSamples?: number;
  50912. /**
  50913. * The rendering group to draw the layer in.
  50914. */
  50915. renderingGroupId: number;
  50916. }
  50917. /**
  50918. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50919. *
  50920. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50921. * glowy meshes to your scene.
  50922. *
  50923. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50924. */
  50925. export class GlowLayer extends EffectLayer {
  50926. /**
  50927. * Effect Name of the layer.
  50928. */
  50929. static readonly EffectName: string;
  50930. /**
  50931. * The default blur kernel size used for the glow.
  50932. */
  50933. static DefaultBlurKernelSize: number;
  50934. /**
  50935. * The default texture size ratio used for the glow.
  50936. */
  50937. static DefaultTextureRatio: number;
  50938. /**
  50939. * Sets the kernel size of the blur.
  50940. */
  50941. /**
  50942. * Gets the kernel size of the blur.
  50943. */
  50944. blurKernelSize: number;
  50945. /**
  50946. * Sets the glow intensity.
  50947. */
  50948. /**
  50949. * Gets the glow intensity.
  50950. */
  50951. intensity: number;
  50952. private _options;
  50953. private _intensity;
  50954. private _horizontalBlurPostprocess1;
  50955. private _verticalBlurPostprocess1;
  50956. private _horizontalBlurPostprocess2;
  50957. private _verticalBlurPostprocess2;
  50958. private _blurTexture1;
  50959. private _blurTexture2;
  50960. private _postProcesses1;
  50961. private _postProcesses2;
  50962. private _includedOnlyMeshes;
  50963. private _excludedMeshes;
  50964. /**
  50965. * Callback used to let the user override the color selection on a per mesh basis
  50966. */
  50967. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50968. /**
  50969. * Callback used to let the user override the texture selection on a per mesh basis
  50970. */
  50971. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50972. /**
  50973. * Instantiates a new glow Layer and references it to the scene.
  50974. * @param name The name of the layer
  50975. * @param scene The scene to use the layer in
  50976. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50977. */
  50978. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50979. /**
  50980. * Get the effect name of the layer.
  50981. * @return The effect name
  50982. */
  50983. getEffectName(): string;
  50984. /**
  50985. * Create the merge effect. This is the shader use to blit the information back
  50986. * to the main canvas at the end of the scene rendering.
  50987. */
  50988. protected _createMergeEffect(): Effect;
  50989. /**
  50990. * Creates the render target textures and post processes used in the glow layer.
  50991. */
  50992. protected _createTextureAndPostProcesses(): void;
  50993. /**
  50994. * Checks for the readiness of the element composing the layer.
  50995. * @param subMesh the mesh to check for
  50996. * @param useInstances specify wether or not to use instances to render the mesh
  50997. * @param emissiveTexture the associated emissive texture used to generate the glow
  50998. * @return true if ready otherwise, false
  50999. */
  51000. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51001. /**
  51002. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51003. */
  51004. needStencil(): boolean;
  51005. /**
  51006. * Returns true if the mesh can be rendered, otherwise false.
  51007. * @param mesh The mesh to render
  51008. * @param material The material used on the mesh
  51009. * @returns true if it can be rendered otherwise false
  51010. */
  51011. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51012. /**
  51013. * Implementation specific of rendering the generating effect on the main canvas.
  51014. * @param effect The effect used to render through
  51015. */
  51016. protected _internalRender(effect: Effect): void;
  51017. /**
  51018. * Sets the required values for both the emissive texture and and the main color.
  51019. */
  51020. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51021. /**
  51022. * Returns true if the mesh should render, otherwise false.
  51023. * @param mesh The mesh to render
  51024. * @returns true if it should render otherwise false
  51025. */
  51026. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51027. /**
  51028. * Adds specific effects defines.
  51029. * @param defines The defines to add specifics to.
  51030. */
  51031. protected _addCustomEffectDefines(defines: string[]): void;
  51032. /**
  51033. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51034. * @param mesh The mesh to exclude from the glow layer
  51035. */
  51036. addExcludedMesh(mesh: Mesh): void;
  51037. /**
  51038. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51039. * @param mesh The mesh to remove
  51040. */
  51041. removeExcludedMesh(mesh: Mesh): void;
  51042. /**
  51043. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51044. * @param mesh The mesh to include in the glow layer
  51045. */
  51046. addIncludedOnlyMesh(mesh: Mesh): void;
  51047. /**
  51048. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51049. * @param mesh The mesh to remove
  51050. */
  51051. removeIncludedOnlyMesh(mesh: Mesh): void;
  51052. /**
  51053. * Determine if a given mesh will be used in the glow layer
  51054. * @param mesh The mesh to test
  51055. * @returns true if the mesh will be highlighted by the current glow layer
  51056. */
  51057. hasMesh(mesh: AbstractMesh): boolean;
  51058. /**
  51059. * Free any resources and references associated to a mesh.
  51060. * Internal use
  51061. * @param mesh The mesh to free.
  51062. * @hidden
  51063. */
  51064. _disposeMesh(mesh: Mesh): void;
  51065. /**
  51066. * Gets the class name of the effect layer
  51067. * @returns the string with the class name of the effect layer
  51068. */
  51069. getClassName(): string;
  51070. /**
  51071. * Serializes this glow layer
  51072. * @returns a serialized glow layer object
  51073. */
  51074. serialize(): any;
  51075. /**
  51076. * Creates a Glow Layer from parsed glow layer data
  51077. * @param parsedGlowLayer defines glow layer data
  51078. * @param scene defines the current scene
  51079. * @param rootUrl defines the root URL containing the glow layer information
  51080. * @returns a parsed Glow Layer
  51081. */
  51082. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51083. }
  51084. }
  51085. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51086. /** @hidden */
  51087. export var glowBlurPostProcessPixelShader: {
  51088. name: string;
  51089. shader: string;
  51090. };
  51091. }
  51092. declare module "babylonjs/Layers/highlightLayer" {
  51093. import { Observable } from "babylonjs/Misc/observable";
  51094. import { Nullable } from "babylonjs/types";
  51095. import { Camera } from "babylonjs/Cameras/camera";
  51096. import { Scene } from "babylonjs/scene";
  51097. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51099. import { Mesh } from "babylonjs/Meshes/mesh";
  51100. import { Effect } from "babylonjs/Materials/effect";
  51101. import { Material } from "babylonjs/Materials/material";
  51102. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51103. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51104. import "babylonjs/Shaders/glowMapMerge.fragment";
  51105. import "babylonjs/Shaders/glowMapMerge.vertex";
  51106. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51107. module "babylonjs/abstractScene" {
  51108. interface AbstractScene {
  51109. /**
  51110. * Return a the first highlight layer of the scene with a given name.
  51111. * @param name The name of the highlight layer to look for.
  51112. * @return The highlight layer if found otherwise null.
  51113. */
  51114. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51115. }
  51116. }
  51117. /**
  51118. * Highlight layer options. This helps customizing the behaviour
  51119. * of the highlight layer.
  51120. */
  51121. export interface IHighlightLayerOptions {
  51122. /**
  51123. * Multiplication factor apply to the canvas size to compute the render target size
  51124. * used to generated the glowing objects (the smaller the faster).
  51125. */
  51126. mainTextureRatio: number;
  51127. /**
  51128. * Enforces a fixed size texture to ensure resize independant blur.
  51129. */
  51130. mainTextureFixedSize?: number;
  51131. /**
  51132. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51133. * of the picture to blur (the smaller the faster).
  51134. */
  51135. blurTextureSizeRatio: number;
  51136. /**
  51137. * How big in texel of the blur texture is the vertical blur.
  51138. */
  51139. blurVerticalSize: number;
  51140. /**
  51141. * How big in texel of the blur texture is the horizontal blur.
  51142. */
  51143. blurHorizontalSize: number;
  51144. /**
  51145. * Alpha blending mode used to apply the blur. Default is combine.
  51146. */
  51147. alphaBlendingMode: number;
  51148. /**
  51149. * The camera attached to the layer.
  51150. */
  51151. camera: Nullable<Camera>;
  51152. /**
  51153. * Should we display highlight as a solid stroke?
  51154. */
  51155. isStroke?: boolean;
  51156. /**
  51157. * The rendering group to draw the layer in.
  51158. */
  51159. renderingGroupId: number;
  51160. }
  51161. /**
  51162. * The highlight layer Helps adding a glow effect around a mesh.
  51163. *
  51164. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51165. * glowy meshes to your scene.
  51166. *
  51167. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51168. */
  51169. export class HighlightLayer extends EffectLayer {
  51170. name: string;
  51171. /**
  51172. * Effect Name of the highlight layer.
  51173. */
  51174. static readonly EffectName: string;
  51175. /**
  51176. * The neutral color used during the preparation of the glow effect.
  51177. * This is black by default as the blend operation is a blend operation.
  51178. */
  51179. static NeutralColor: Color4;
  51180. /**
  51181. * Stencil value used for glowing meshes.
  51182. */
  51183. static GlowingMeshStencilReference: number;
  51184. /**
  51185. * Stencil value used for the other meshes in the scene.
  51186. */
  51187. static NormalMeshStencilReference: number;
  51188. /**
  51189. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51190. */
  51191. innerGlow: boolean;
  51192. /**
  51193. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51194. */
  51195. outerGlow: boolean;
  51196. /**
  51197. * Specifies the horizontal size of the blur.
  51198. */
  51199. /**
  51200. * Gets the horizontal size of the blur.
  51201. */
  51202. blurHorizontalSize: number;
  51203. /**
  51204. * Specifies the vertical size of the blur.
  51205. */
  51206. /**
  51207. * Gets the vertical size of the blur.
  51208. */
  51209. blurVerticalSize: number;
  51210. /**
  51211. * An event triggered when the highlight layer is being blurred.
  51212. */
  51213. onBeforeBlurObservable: Observable<HighlightLayer>;
  51214. /**
  51215. * An event triggered when the highlight layer has been blurred.
  51216. */
  51217. onAfterBlurObservable: Observable<HighlightLayer>;
  51218. private _instanceGlowingMeshStencilReference;
  51219. private _options;
  51220. private _downSamplePostprocess;
  51221. private _horizontalBlurPostprocess;
  51222. private _verticalBlurPostprocess;
  51223. private _blurTexture;
  51224. private _meshes;
  51225. private _excludedMeshes;
  51226. /**
  51227. * Instantiates a new highlight Layer and references it to the scene..
  51228. * @param name The name of the layer
  51229. * @param scene The scene to use the layer in
  51230. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51231. */
  51232. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51233. /**
  51234. * Get the effect name of the layer.
  51235. * @return The effect name
  51236. */
  51237. getEffectName(): string;
  51238. /**
  51239. * Create the merge effect. This is the shader use to blit the information back
  51240. * to the main canvas at the end of the scene rendering.
  51241. */
  51242. protected _createMergeEffect(): Effect;
  51243. /**
  51244. * Creates the render target textures and post processes used in the highlight layer.
  51245. */
  51246. protected _createTextureAndPostProcesses(): void;
  51247. /**
  51248. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51249. */
  51250. needStencil(): boolean;
  51251. /**
  51252. * Checks for the readiness of the element composing the layer.
  51253. * @param subMesh the mesh to check for
  51254. * @param useInstances specify wether or not to use instances to render the mesh
  51255. * @param emissiveTexture the associated emissive texture used to generate the glow
  51256. * @return true if ready otherwise, false
  51257. */
  51258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51259. /**
  51260. * Implementation specific of rendering the generating effect on the main canvas.
  51261. * @param effect The effect used to render through
  51262. */
  51263. protected _internalRender(effect: Effect): void;
  51264. /**
  51265. * Returns true if the layer contains information to display, otherwise false.
  51266. */
  51267. shouldRender(): boolean;
  51268. /**
  51269. * Returns true if the mesh should render, otherwise false.
  51270. * @param mesh The mesh to render
  51271. * @returns true if it should render otherwise false
  51272. */
  51273. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51274. /**
  51275. * Sets the required values for both the emissive texture and and the main color.
  51276. */
  51277. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51278. /**
  51279. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51280. * @param mesh The mesh to exclude from the highlight layer
  51281. */
  51282. addExcludedMesh(mesh: Mesh): void;
  51283. /**
  51284. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51285. * @param mesh The mesh to highlight
  51286. */
  51287. removeExcludedMesh(mesh: Mesh): void;
  51288. /**
  51289. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51290. * @param mesh mesh to test
  51291. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51292. */
  51293. hasMesh(mesh: AbstractMesh): boolean;
  51294. /**
  51295. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51296. * @param mesh The mesh to highlight
  51297. * @param color The color of the highlight
  51298. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51299. */
  51300. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51301. /**
  51302. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51303. * @param mesh The mesh to highlight
  51304. */
  51305. removeMesh(mesh: Mesh): void;
  51306. /**
  51307. * Force the stencil to the normal expected value for none glowing parts
  51308. */
  51309. private _defaultStencilReference;
  51310. /**
  51311. * Free any resources and references associated to a mesh.
  51312. * Internal use
  51313. * @param mesh The mesh to free.
  51314. * @hidden
  51315. */
  51316. _disposeMesh(mesh: Mesh): void;
  51317. /**
  51318. * Dispose the highlight layer and free resources.
  51319. */
  51320. dispose(): void;
  51321. /**
  51322. * Gets the class name of the effect layer
  51323. * @returns the string with the class name of the effect layer
  51324. */
  51325. getClassName(): string;
  51326. /**
  51327. * Serializes this Highlight layer
  51328. * @returns a serialized Highlight layer object
  51329. */
  51330. serialize(): any;
  51331. /**
  51332. * Creates a Highlight layer from parsed Highlight layer data
  51333. * @param parsedHightlightLayer defines the Highlight layer data
  51334. * @param scene defines the current scene
  51335. * @param rootUrl defines the root URL containing the Highlight layer information
  51336. * @returns a parsed Highlight layer
  51337. */
  51338. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51339. }
  51340. }
  51341. declare module "babylonjs/Layers/layerSceneComponent" {
  51342. import { Scene } from "babylonjs/scene";
  51343. import { ISceneComponent } from "babylonjs/sceneComponent";
  51344. import { Layer } from "babylonjs/Layers/layer";
  51345. import { AbstractScene } from "babylonjs/abstractScene";
  51346. module "babylonjs/abstractScene" {
  51347. interface AbstractScene {
  51348. /**
  51349. * The list of layers (background and foreground) of the scene
  51350. */
  51351. layers: Array<Layer>;
  51352. }
  51353. }
  51354. /**
  51355. * Defines the layer scene component responsible to manage any layers
  51356. * in a given scene.
  51357. */
  51358. export class LayerSceneComponent implements ISceneComponent {
  51359. /**
  51360. * The component name helpfull to identify the component in the list of scene components.
  51361. */
  51362. readonly name: string;
  51363. /**
  51364. * The scene the component belongs to.
  51365. */
  51366. scene: Scene;
  51367. private _engine;
  51368. /**
  51369. * Creates a new instance of the component for the given scene
  51370. * @param scene Defines the scene to register the component in
  51371. */
  51372. constructor(scene: Scene);
  51373. /**
  51374. * Registers the component in a given scene
  51375. */
  51376. register(): void;
  51377. /**
  51378. * Rebuilds the elements related to this component in case of
  51379. * context lost for instance.
  51380. */
  51381. rebuild(): void;
  51382. /**
  51383. * Disposes the component and the associated ressources.
  51384. */
  51385. dispose(): void;
  51386. private _draw;
  51387. private _drawCameraPredicate;
  51388. private _drawCameraBackground;
  51389. private _drawCameraForeground;
  51390. private _drawRenderTargetPredicate;
  51391. private _drawRenderTargetBackground;
  51392. private _drawRenderTargetForeground;
  51393. /**
  51394. * Adds all the elements from the container to the scene
  51395. * @param container the container holding the elements
  51396. */
  51397. addFromContainer(container: AbstractScene): void;
  51398. /**
  51399. * Removes all the elements in the container from the scene
  51400. * @param container contains the elements to remove
  51401. * @param dispose if the removed element should be disposed (default: false)
  51402. */
  51403. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51404. }
  51405. }
  51406. declare module "babylonjs/Shaders/layer.fragment" {
  51407. /** @hidden */
  51408. export var layerPixelShader: {
  51409. name: string;
  51410. shader: string;
  51411. };
  51412. }
  51413. declare module "babylonjs/Shaders/layer.vertex" {
  51414. /** @hidden */
  51415. export var layerVertexShader: {
  51416. name: string;
  51417. shader: string;
  51418. };
  51419. }
  51420. declare module "babylonjs/Layers/layer" {
  51421. import { Observable } from "babylonjs/Misc/observable";
  51422. import { Nullable } from "babylonjs/types";
  51423. import { Scene } from "babylonjs/scene";
  51424. import { Vector2 } from "babylonjs/Maths/math.vector";
  51425. import { Color4 } from "babylonjs/Maths/math.color";
  51426. import { Texture } from "babylonjs/Materials/Textures/texture";
  51427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51428. import "babylonjs/Shaders/layer.fragment";
  51429. import "babylonjs/Shaders/layer.vertex";
  51430. /**
  51431. * This represents a full screen 2d layer.
  51432. * This can be useful to display a picture in the background of your scene for instance.
  51433. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51434. */
  51435. export class Layer {
  51436. /**
  51437. * Define the name of the layer.
  51438. */
  51439. name: string;
  51440. /**
  51441. * Define the texture the layer should display.
  51442. */
  51443. texture: Nullable<Texture>;
  51444. /**
  51445. * Is the layer in background or foreground.
  51446. */
  51447. isBackground: boolean;
  51448. /**
  51449. * Define the color of the layer (instead of texture).
  51450. */
  51451. color: Color4;
  51452. /**
  51453. * Define the scale of the layer in order to zoom in out of the texture.
  51454. */
  51455. scale: Vector2;
  51456. /**
  51457. * Define an offset for the layer in order to shift the texture.
  51458. */
  51459. offset: Vector2;
  51460. /**
  51461. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51462. */
  51463. alphaBlendingMode: number;
  51464. /**
  51465. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51466. * Alpha test will not mix with the background color in case of transparency.
  51467. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51468. */
  51469. alphaTest: boolean;
  51470. /**
  51471. * Define a mask to restrict the layer to only some of the scene cameras.
  51472. */
  51473. layerMask: number;
  51474. /**
  51475. * Define the list of render target the layer is visible into.
  51476. */
  51477. renderTargetTextures: RenderTargetTexture[];
  51478. /**
  51479. * Define if the layer is only used in renderTarget or if it also
  51480. * renders in the main frame buffer of the canvas.
  51481. */
  51482. renderOnlyInRenderTargetTextures: boolean;
  51483. private _scene;
  51484. private _vertexBuffers;
  51485. private _indexBuffer;
  51486. private _effect;
  51487. private _alphaTestEffect;
  51488. /**
  51489. * An event triggered when the layer is disposed.
  51490. */
  51491. onDisposeObservable: Observable<Layer>;
  51492. private _onDisposeObserver;
  51493. /**
  51494. * Back compatibility with callback before the onDisposeObservable existed.
  51495. * The set callback will be triggered when the layer has been disposed.
  51496. */
  51497. onDispose: () => void;
  51498. /**
  51499. * An event triggered before rendering the scene
  51500. */
  51501. onBeforeRenderObservable: Observable<Layer>;
  51502. private _onBeforeRenderObserver;
  51503. /**
  51504. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51505. * The set callback will be triggered just before rendering the layer.
  51506. */
  51507. onBeforeRender: () => void;
  51508. /**
  51509. * An event triggered after rendering the scene
  51510. */
  51511. onAfterRenderObservable: Observable<Layer>;
  51512. private _onAfterRenderObserver;
  51513. /**
  51514. * Back compatibility with callback before the onAfterRenderObservable existed.
  51515. * The set callback will be triggered just after rendering the layer.
  51516. */
  51517. onAfterRender: () => void;
  51518. /**
  51519. * Instantiates a new layer.
  51520. * This represents a full screen 2d layer.
  51521. * This can be useful to display a picture in the background of your scene for instance.
  51522. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51523. * @param name Define the name of the layer in the scene
  51524. * @param imgUrl Define the url of the texture to display in the layer
  51525. * @param scene Define the scene the layer belongs to
  51526. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51527. * @param color Defines a color for the layer
  51528. */
  51529. constructor(
  51530. /**
  51531. * Define the name of the layer.
  51532. */
  51533. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51534. private _createIndexBuffer;
  51535. /** @hidden */
  51536. _rebuild(): void;
  51537. /**
  51538. * Renders the layer in the scene.
  51539. */
  51540. render(): void;
  51541. /**
  51542. * Disposes and releases the associated ressources.
  51543. */
  51544. dispose(): void;
  51545. }
  51546. }
  51547. declare module "babylonjs/Layers/index" {
  51548. export * from "babylonjs/Layers/effectLayer";
  51549. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51550. export * from "babylonjs/Layers/glowLayer";
  51551. export * from "babylonjs/Layers/highlightLayer";
  51552. export * from "babylonjs/Layers/layer";
  51553. export * from "babylonjs/Layers/layerSceneComponent";
  51554. }
  51555. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51556. /** @hidden */
  51557. export var lensFlarePixelShader: {
  51558. name: string;
  51559. shader: string;
  51560. };
  51561. }
  51562. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51563. /** @hidden */
  51564. export var lensFlareVertexShader: {
  51565. name: string;
  51566. shader: string;
  51567. };
  51568. }
  51569. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51570. import { Scene } from "babylonjs/scene";
  51571. import { Vector3 } from "babylonjs/Maths/math.vector";
  51572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51573. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51574. import "babylonjs/Shaders/lensFlare.fragment";
  51575. import "babylonjs/Shaders/lensFlare.vertex";
  51576. import { Viewport } from "babylonjs/Maths/math.viewport";
  51577. /**
  51578. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51579. * It is usually composed of several `lensFlare`.
  51580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51581. */
  51582. export class LensFlareSystem {
  51583. /**
  51584. * Define the name of the lens flare system
  51585. */
  51586. name: string;
  51587. /**
  51588. * List of lens flares used in this system.
  51589. */
  51590. lensFlares: LensFlare[];
  51591. /**
  51592. * Define a limit from the border the lens flare can be visible.
  51593. */
  51594. borderLimit: number;
  51595. /**
  51596. * Define a viewport border we do not want to see the lens flare in.
  51597. */
  51598. viewportBorder: number;
  51599. /**
  51600. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51601. */
  51602. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51603. /**
  51604. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51605. */
  51606. layerMask: number;
  51607. /**
  51608. * Define the id of the lens flare system in the scene.
  51609. * (equal to name by default)
  51610. */
  51611. id: string;
  51612. private _scene;
  51613. private _emitter;
  51614. private _vertexBuffers;
  51615. private _indexBuffer;
  51616. private _effect;
  51617. private _positionX;
  51618. private _positionY;
  51619. private _isEnabled;
  51620. /** @hidden */
  51621. static _SceneComponentInitialization: (scene: Scene) => void;
  51622. /**
  51623. * Instantiates a lens flare system.
  51624. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51625. * It is usually composed of several `lensFlare`.
  51626. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51627. * @param name Define the name of the lens flare system in the scene
  51628. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51629. * @param scene Define the scene the lens flare system belongs to
  51630. */
  51631. constructor(
  51632. /**
  51633. * Define the name of the lens flare system
  51634. */
  51635. name: string, emitter: any, scene: Scene);
  51636. /**
  51637. * Define if the lens flare system is enabled.
  51638. */
  51639. isEnabled: boolean;
  51640. /**
  51641. * Get the scene the effects belongs to.
  51642. * @returns the scene holding the lens flare system
  51643. */
  51644. getScene(): Scene;
  51645. /**
  51646. * Get the emitter of the lens flare system.
  51647. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51648. * @returns the emitter of the lens flare system
  51649. */
  51650. getEmitter(): any;
  51651. /**
  51652. * Set the emitter of the lens flare system.
  51653. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51654. * @param newEmitter Define the new emitter of the system
  51655. */
  51656. setEmitter(newEmitter: any): void;
  51657. /**
  51658. * Get the lens flare system emitter position.
  51659. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51660. * @returns the position
  51661. */
  51662. getEmitterPosition(): Vector3;
  51663. /**
  51664. * @hidden
  51665. */
  51666. computeEffectivePosition(globalViewport: Viewport): boolean;
  51667. /** @hidden */
  51668. _isVisible(): boolean;
  51669. /**
  51670. * @hidden
  51671. */
  51672. render(): boolean;
  51673. /**
  51674. * Dispose and release the lens flare with its associated resources.
  51675. */
  51676. dispose(): void;
  51677. /**
  51678. * Parse a lens flare system from a JSON repressentation
  51679. * @param parsedLensFlareSystem Define the JSON to parse
  51680. * @param scene Define the scene the parsed system should be instantiated in
  51681. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51682. * @returns the parsed system
  51683. */
  51684. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51685. /**
  51686. * Serialize the current Lens Flare System into a JSON representation.
  51687. * @returns the serialized JSON
  51688. */
  51689. serialize(): any;
  51690. }
  51691. }
  51692. declare module "babylonjs/LensFlares/lensFlare" {
  51693. import { Nullable } from "babylonjs/types";
  51694. import { Color3 } from "babylonjs/Maths/math.color";
  51695. import { Texture } from "babylonjs/Materials/Textures/texture";
  51696. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51697. /**
  51698. * This represents one of the lens effect in a `lensFlareSystem`.
  51699. * It controls one of the indiviual texture used in the effect.
  51700. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51701. */
  51702. export class LensFlare {
  51703. /**
  51704. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51705. */
  51706. size: number;
  51707. /**
  51708. * 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.
  51709. */
  51710. position: number;
  51711. /**
  51712. * Define the lens color.
  51713. */
  51714. color: Color3;
  51715. /**
  51716. * Define the lens texture.
  51717. */
  51718. texture: Nullable<Texture>;
  51719. /**
  51720. * Define the alpha mode to render this particular lens.
  51721. */
  51722. alphaMode: number;
  51723. private _system;
  51724. /**
  51725. * Creates a new Lens Flare.
  51726. * This represents one of the lens effect in a `lensFlareSystem`.
  51727. * It controls one of the indiviual texture used in the effect.
  51728. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51729. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51730. * @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.
  51731. * @param color Define the lens color
  51732. * @param imgUrl Define the lens texture url
  51733. * @param system Define the `lensFlareSystem` this flare is part of
  51734. * @returns The newly created Lens Flare
  51735. */
  51736. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51737. /**
  51738. * Instantiates a new Lens Flare.
  51739. * This represents one of the lens effect in a `lensFlareSystem`.
  51740. * It controls one of the indiviual texture used in the effect.
  51741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51742. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51743. * @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.
  51744. * @param color Define the lens color
  51745. * @param imgUrl Define the lens texture url
  51746. * @param system Define the `lensFlareSystem` this flare is part of
  51747. */
  51748. constructor(
  51749. /**
  51750. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51751. */
  51752. size: number,
  51753. /**
  51754. * 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.
  51755. */
  51756. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51757. /**
  51758. * Dispose and release the lens flare with its associated resources.
  51759. */
  51760. dispose(): void;
  51761. }
  51762. }
  51763. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51764. import { Nullable } from "babylonjs/types";
  51765. import { Scene } from "babylonjs/scene";
  51766. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51767. import { AbstractScene } from "babylonjs/abstractScene";
  51768. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51769. module "babylonjs/abstractScene" {
  51770. interface AbstractScene {
  51771. /**
  51772. * The list of lens flare system added to the scene
  51773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51774. */
  51775. lensFlareSystems: Array<LensFlareSystem>;
  51776. /**
  51777. * Removes the given lens flare system from this scene.
  51778. * @param toRemove The lens flare system to remove
  51779. * @returns The index of the removed lens flare system
  51780. */
  51781. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51782. /**
  51783. * Adds the given lens flare system to this scene
  51784. * @param newLensFlareSystem The lens flare system to add
  51785. */
  51786. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51787. /**
  51788. * Gets a lens flare system using its name
  51789. * @param name defines the name to look for
  51790. * @returns the lens flare system or null if not found
  51791. */
  51792. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51793. /**
  51794. * Gets a lens flare system using its id
  51795. * @param id defines the id to look for
  51796. * @returns the lens flare system or null if not found
  51797. */
  51798. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51799. }
  51800. }
  51801. /**
  51802. * Defines the lens flare scene component responsible to manage any lens flares
  51803. * in a given scene.
  51804. */
  51805. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51806. /**
  51807. * The component name helpfull to identify the component in the list of scene components.
  51808. */
  51809. readonly name: string;
  51810. /**
  51811. * The scene the component belongs to.
  51812. */
  51813. scene: Scene;
  51814. /**
  51815. * Creates a new instance of the component for the given scene
  51816. * @param scene Defines the scene to register the component in
  51817. */
  51818. constructor(scene: Scene);
  51819. /**
  51820. * Registers the component in a given scene
  51821. */
  51822. register(): void;
  51823. /**
  51824. * Rebuilds the elements related to this component in case of
  51825. * context lost for instance.
  51826. */
  51827. rebuild(): void;
  51828. /**
  51829. * Adds all the elements from the container to the scene
  51830. * @param container the container holding the elements
  51831. */
  51832. addFromContainer(container: AbstractScene): void;
  51833. /**
  51834. * Removes all the elements in the container from the scene
  51835. * @param container contains the elements to remove
  51836. * @param dispose if the removed element should be disposed (default: false)
  51837. */
  51838. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51839. /**
  51840. * Serializes the component data to the specified json object
  51841. * @param serializationObject The object to serialize to
  51842. */
  51843. serialize(serializationObject: any): void;
  51844. /**
  51845. * Disposes the component and the associated ressources.
  51846. */
  51847. dispose(): void;
  51848. private _draw;
  51849. }
  51850. }
  51851. declare module "babylonjs/LensFlares/index" {
  51852. export * from "babylonjs/LensFlares/lensFlare";
  51853. export * from "babylonjs/LensFlares/lensFlareSystem";
  51854. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51855. }
  51856. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51857. import { Scene } from "babylonjs/scene";
  51858. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51859. import { AbstractScene } from "babylonjs/abstractScene";
  51860. /**
  51861. * Defines the shadow generator component responsible to manage any shadow generators
  51862. * in a given scene.
  51863. */
  51864. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51865. /**
  51866. * The component name helpfull to identify the component in the list of scene components.
  51867. */
  51868. readonly name: string;
  51869. /**
  51870. * The scene the component belongs to.
  51871. */
  51872. scene: Scene;
  51873. /**
  51874. * Creates a new instance of the component for the given scene
  51875. * @param scene Defines the scene to register the component in
  51876. */
  51877. constructor(scene: Scene);
  51878. /**
  51879. * Registers the component in a given scene
  51880. */
  51881. register(): void;
  51882. /**
  51883. * Rebuilds the elements related to this component in case of
  51884. * context lost for instance.
  51885. */
  51886. rebuild(): void;
  51887. /**
  51888. * Serializes the component data to the specified json object
  51889. * @param serializationObject The object to serialize to
  51890. */
  51891. serialize(serializationObject: any): void;
  51892. /**
  51893. * Adds all the elements from the container to the scene
  51894. * @param container the container holding the elements
  51895. */
  51896. addFromContainer(container: AbstractScene): void;
  51897. /**
  51898. * Removes all the elements in the container from the scene
  51899. * @param container contains the elements to remove
  51900. * @param dispose if the removed element should be disposed (default: false)
  51901. */
  51902. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51903. /**
  51904. * Rebuilds the elements related to this component in case of
  51905. * context lost for instance.
  51906. */
  51907. dispose(): void;
  51908. private _gatherRenderTargets;
  51909. }
  51910. }
  51911. declare module "babylonjs/Lights/Shadows/index" {
  51912. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51913. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51914. }
  51915. declare module "babylonjs/Lights/pointLight" {
  51916. import { Scene } from "babylonjs/scene";
  51917. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51919. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51920. import { Effect } from "babylonjs/Materials/effect";
  51921. /**
  51922. * A point light is a light defined by an unique point in world space.
  51923. * The light is emitted in every direction from this point.
  51924. * A good example of a point light is a standard light bulb.
  51925. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51926. */
  51927. export class PointLight extends ShadowLight {
  51928. private _shadowAngle;
  51929. /**
  51930. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51931. * This specifies what angle the shadow will use to be created.
  51932. *
  51933. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51934. */
  51935. /**
  51936. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51937. * This specifies what angle the shadow will use to be created.
  51938. *
  51939. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51940. */
  51941. shadowAngle: number;
  51942. /**
  51943. * Gets the direction if it has been set.
  51944. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51945. */
  51946. /**
  51947. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51948. */
  51949. direction: Vector3;
  51950. /**
  51951. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51952. * A PointLight emits the light in every direction.
  51953. * It can cast shadows.
  51954. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51955. * ```javascript
  51956. * var pointLight = new PointLight("pl", camera.position, scene);
  51957. * ```
  51958. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51959. * @param name The light friendly name
  51960. * @param position The position of the point light in the scene
  51961. * @param scene The scene the lights belongs to
  51962. */
  51963. constructor(name: string, position: Vector3, scene: Scene);
  51964. /**
  51965. * Returns the string "PointLight"
  51966. * @returns the class name
  51967. */
  51968. getClassName(): string;
  51969. /**
  51970. * Returns the integer 0.
  51971. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51972. */
  51973. getTypeID(): number;
  51974. /**
  51975. * Specifies wether or not the shadowmap should be a cube texture.
  51976. * @returns true if the shadowmap needs to be a cube texture.
  51977. */
  51978. needCube(): boolean;
  51979. /**
  51980. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51983. */
  51984. getShadowDirection(faceIndex?: number): Vector3;
  51985. /**
  51986. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51987. * - fov = PI / 2
  51988. * - aspect ratio : 1.0
  51989. * - z-near and far equal to the active camera minZ and maxZ.
  51990. * Returns the PointLight.
  51991. */
  51992. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51993. protected _buildUniformLayout(): void;
  51994. /**
  51995. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51996. * @param effect The effect to update
  51997. * @param lightIndex The index of the light in the effect to update
  51998. * @returns The point light
  51999. */
  52000. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52001. /**
  52002. * Prepares the list of defines specific to the light type.
  52003. * @param defines the list of defines
  52004. * @param lightIndex defines the index of the light for the effect
  52005. */
  52006. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52007. }
  52008. }
  52009. declare module "babylonjs/Lights/index" {
  52010. export * from "babylonjs/Lights/light";
  52011. export * from "babylonjs/Lights/shadowLight";
  52012. export * from "babylonjs/Lights/Shadows/index";
  52013. export * from "babylonjs/Lights/directionalLight";
  52014. export * from "babylonjs/Lights/hemisphericLight";
  52015. export * from "babylonjs/Lights/pointLight";
  52016. export * from "babylonjs/Lights/spotLight";
  52017. }
  52018. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52019. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52020. /**
  52021. * Header information of HDR texture files.
  52022. */
  52023. export interface HDRInfo {
  52024. /**
  52025. * The height of the texture in pixels.
  52026. */
  52027. height: number;
  52028. /**
  52029. * The width of the texture in pixels.
  52030. */
  52031. width: number;
  52032. /**
  52033. * The index of the beginning of the data in the binary file.
  52034. */
  52035. dataPosition: number;
  52036. }
  52037. /**
  52038. * This groups tools to convert HDR texture to native colors array.
  52039. */
  52040. export class HDRTools {
  52041. private static Ldexp;
  52042. private static Rgbe2float;
  52043. private static readStringLine;
  52044. /**
  52045. * Reads header information from an RGBE texture stored in a native array.
  52046. * More information on this format are available here:
  52047. * https://en.wikipedia.org/wiki/RGBE_image_format
  52048. *
  52049. * @param uint8array The binary file stored in native array.
  52050. * @return The header information.
  52051. */
  52052. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52053. /**
  52054. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52055. * This RGBE texture needs to store the information as a panorama.
  52056. *
  52057. * More information on this format are available here:
  52058. * https://en.wikipedia.org/wiki/RGBE_image_format
  52059. *
  52060. * @param buffer The binary file stored in an array buffer.
  52061. * @param size The expected size of the extracted cubemap.
  52062. * @return The Cube Map information.
  52063. */
  52064. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52065. /**
  52066. * Returns the pixels data extracted from an RGBE texture.
  52067. * This pixels will be stored left to right up to down in the R G B order in one array.
  52068. *
  52069. * More information on this format are available here:
  52070. * https://en.wikipedia.org/wiki/RGBE_image_format
  52071. *
  52072. * @param uint8array The binary file stored in an array buffer.
  52073. * @param hdrInfo The header information of the file.
  52074. * @return The pixels data in RGB right to left up to down order.
  52075. */
  52076. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52077. private static RGBE_ReadPixels_RLE;
  52078. }
  52079. }
  52080. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52081. import { Nullable } from "babylonjs/types";
  52082. import { Scene } from "babylonjs/scene";
  52083. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52085. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52086. /**
  52087. * This represents a texture coming from an HDR input.
  52088. *
  52089. * The only supported format is currently panorama picture stored in RGBE format.
  52090. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52091. */
  52092. export class HDRCubeTexture extends BaseTexture {
  52093. private static _facesMapping;
  52094. private _generateHarmonics;
  52095. private _noMipmap;
  52096. private _textureMatrix;
  52097. private _size;
  52098. private _onLoad;
  52099. private _onError;
  52100. /**
  52101. * The texture URL.
  52102. */
  52103. url: string;
  52104. /**
  52105. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52106. */
  52107. coordinatesMode: number;
  52108. protected _isBlocking: boolean;
  52109. /**
  52110. * Sets wether or not the texture is blocking during loading.
  52111. */
  52112. /**
  52113. * Gets wether or not the texture is blocking during loading.
  52114. */
  52115. isBlocking: boolean;
  52116. protected _rotationY: number;
  52117. /**
  52118. * Sets texture matrix rotation angle around Y axis in radians.
  52119. */
  52120. /**
  52121. * Gets texture matrix rotation angle around Y axis radians.
  52122. */
  52123. rotationY: number;
  52124. /**
  52125. * Gets or sets the center of the bounding box associated with the cube texture
  52126. * It must define where the camera used to render the texture was set
  52127. */
  52128. boundingBoxPosition: Vector3;
  52129. private _boundingBoxSize;
  52130. /**
  52131. * Gets or sets the size of the bounding box associated with the cube texture
  52132. * When defined, the cubemap will switch to local mode
  52133. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52134. * @example https://www.babylonjs-playground.com/#RNASML
  52135. */
  52136. boundingBoxSize: Vector3;
  52137. /**
  52138. * Instantiates an HDRTexture from the following parameters.
  52139. *
  52140. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52141. * @param scene The scene the texture will be used in
  52142. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52143. * @param noMipmap Forces to not generate the mipmap if true
  52144. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52145. * @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)
  52146. * @param reserved Reserved flag for internal use.
  52147. */
  52148. 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>);
  52149. /**
  52150. * Get the current class name of the texture useful for serialization or dynamic coding.
  52151. * @returns "HDRCubeTexture"
  52152. */
  52153. getClassName(): string;
  52154. /**
  52155. * Occurs when the file is raw .hdr file.
  52156. */
  52157. private loadTexture;
  52158. clone(): HDRCubeTexture;
  52159. delayLoad(): void;
  52160. /**
  52161. * Get the texture reflection matrix used to rotate/transform the reflection.
  52162. * @returns the reflection matrix
  52163. */
  52164. getReflectionTextureMatrix(): Matrix;
  52165. /**
  52166. * Set the texture reflection matrix used to rotate/transform the reflection.
  52167. * @param value Define the reflection matrix to set
  52168. */
  52169. setReflectionTextureMatrix(value: Matrix): void;
  52170. /**
  52171. * Parses a JSON representation of an HDR Texture in order to create the texture
  52172. * @param parsedTexture Define the JSON representation
  52173. * @param scene Define the scene the texture should be created in
  52174. * @param rootUrl Define the root url in case we need to load relative dependencies
  52175. * @returns the newly created texture after parsing
  52176. */
  52177. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52178. serialize(): any;
  52179. }
  52180. }
  52181. declare module "babylonjs/Physics/physicsEngine" {
  52182. import { Nullable } from "babylonjs/types";
  52183. import { Vector3 } from "babylonjs/Maths/math.vector";
  52184. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52185. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52186. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52187. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52188. /**
  52189. * Class used to control physics engine
  52190. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52191. */
  52192. export class PhysicsEngine implements IPhysicsEngine {
  52193. private _physicsPlugin;
  52194. /**
  52195. * Global value used to control the smallest number supported by the simulation
  52196. */
  52197. static Epsilon: number;
  52198. private _impostors;
  52199. private _joints;
  52200. /**
  52201. * Gets the gravity vector used by the simulation
  52202. */
  52203. gravity: Vector3;
  52204. /**
  52205. * Factory used to create the default physics plugin.
  52206. * @returns The default physics plugin
  52207. */
  52208. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52209. /**
  52210. * Creates a new Physics Engine
  52211. * @param gravity defines the gravity vector used by the simulation
  52212. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52213. */
  52214. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52215. /**
  52216. * Sets the gravity vector used by the simulation
  52217. * @param gravity defines the gravity vector to use
  52218. */
  52219. setGravity(gravity: Vector3): void;
  52220. /**
  52221. * Set the time step of the physics engine.
  52222. * Default is 1/60.
  52223. * To slow it down, enter 1/600 for example.
  52224. * To speed it up, 1/30
  52225. * @param newTimeStep defines the new timestep to apply to this world.
  52226. */
  52227. setTimeStep(newTimeStep?: number): void;
  52228. /**
  52229. * Get the time step of the physics engine.
  52230. * @returns the current time step
  52231. */
  52232. getTimeStep(): number;
  52233. /**
  52234. * Release all resources
  52235. */
  52236. dispose(): void;
  52237. /**
  52238. * Gets the name of the current physics plugin
  52239. * @returns the name of the plugin
  52240. */
  52241. getPhysicsPluginName(): string;
  52242. /**
  52243. * Adding a new impostor for the impostor tracking.
  52244. * This will be done by the impostor itself.
  52245. * @param impostor the impostor to add
  52246. */
  52247. addImpostor(impostor: PhysicsImpostor): void;
  52248. /**
  52249. * Remove an impostor from the engine.
  52250. * This impostor and its mesh will not longer be updated by the physics engine.
  52251. * @param impostor the impostor to remove
  52252. */
  52253. removeImpostor(impostor: PhysicsImpostor): void;
  52254. /**
  52255. * Add a joint to the physics engine
  52256. * @param mainImpostor defines the main impostor to which the joint is added.
  52257. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52258. * @param joint defines the joint that will connect both impostors.
  52259. */
  52260. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52261. /**
  52262. * Removes a joint from the simulation
  52263. * @param mainImpostor defines the impostor used with the joint
  52264. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52265. * @param joint defines the joint to remove
  52266. */
  52267. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52268. /**
  52269. * Called by the scene. No need to call it.
  52270. * @param delta defines the timespam between frames
  52271. */
  52272. _step(delta: number): void;
  52273. /**
  52274. * Gets the current plugin used to run the simulation
  52275. * @returns current plugin
  52276. */
  52277. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52278. /**
  52279. * Gets the list of physic impostors
  52280. * @returns an array of PhysicsImpostor
  52281. */
  52282. getImpostors(): Array<PhysicsImpostor>;
  52283. /**
  52284. * Gets the impostor for a physics enabled object
  52285. * @param object defines the object impersonated by the impostor
  52286. * @returns the PhysicsImpostor or null if not found
  52287. */
  52288. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52289. /**
  52290. * Gets the impostor for a physics body object
  52291. * @param body defines physics body used by the impostor
  52292. * @returns the PhysicsImpostor or null if not found
  52293. */
  52294. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52295. /**
  52296. * Does a raycast in the physics world
  52297. * @param from when should the ray start?
  52298. * @param to when should the ray end?
  52299. * @returns PhysicsRaycastResult
  52300. */
  52301. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52302. }
  52303. }
  52304. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52305. import { Nullable } from "babylonjs/types";
  52306. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52308. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52309. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52310. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52311. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52312. /** @hidden */
  52313. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52314. private _useDeltaForWorldStep;
  52315. world: any;
  52316. name: string;
  52317. private _physicsMaterials;
  52318. private _fixedTimeStep;
  52319. private _cannonRaycastResult;
  52320. private _raycastResult;
  52321. private _physicsBodysToRemoveAfterStep;
  52322. BJSCANNON: any;
  52323. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52324. setGravity(gravity: Vector3): void;
  52325. setTimeStep(timeStep: number): void;
  52326. getTimeStep(): number;
  52327. executeStep(delta: number): void;
  52328. private _removeMarkedPhysicsBodiesFromWorld;
  52329. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52330. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52331. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52332. private _processChildMeshes;
  52333. removePhysicsBody(impostor: PhysicsImpostor): void;
  52334. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52335. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52336. private _addMaterial;
  52337. private _checkWithEpsilon;
  52338. private _createShape;
  52339. private _createHeightmap;
  52340. private _minus90X;
  52341. private _plus90X;
  52342. private _tmpPosition;
  52343. private _tmpDeltaPosition;
  52344. private _tmpUnityRotation;
  52345. private _updatePhysicsBodyTransformation;
  52346. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52348. isSupported(): boolean;
  52349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52354. getBodyMass(impostor: PhysicsImpostor): number;
  52355. getBodyFriction(impostor: PhysicsImpostor): number;
  52356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52357. getBodyRestitution(impostor: PhysicsImpostor): number;
  52358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52359. sleepBody(impostor: PhysicsImpostor): void;
  52360. wakeUpBody(impostor: PhysicsImpostor): void;
  52361. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52362. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52363. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52365. getRadius(impostor: PhysicsImpostor): number;
  52366. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52367. dispose(): void;
  52368. private _extendNamespace;
  52369. /**
  52370. * Does a raycast in the physics world
  52371. * @param from when should the ray start?
  52372. * @param to when should the ray end?
  52373. * @returns PhysicsRaycastResult
  52374. */
  52375. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52376. }
  52377. }
  52378. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52379. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52380. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52381. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52383. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52384. import { Nullable } from "babylonjs/types";
  52385. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52386. /** @hidden */
  52387. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52388. world: any;
  52389. name: string;
  52390. BJSOIMO: any;
  52391. private _raycastResult;
  52392. constructor(iterations?: number, oimoInjection?: any);
  52393. setGravity(gravity: Vector3): void;
  52394. setTimeStep(timeStep: number): void;
  52395. getTimeStep(): number;
  52396. private _tmpImpostorsArray;
  52397. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52398. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52399. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52400. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52401. private _tmpPositionVector;
  52402. removePhysicsBody(impostor: PhysicsImpostor): void;
  52403. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52404. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52405. isSupported(): boolean;
  52406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52413. getBodyMass(impostor: PhysicsImpostor): number;
  52414. getBodyFriction(impostor: PhysicsImpostor): number;
  52415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52416. getBodyRestitution(impostor: PhysicsImpostor): number;
  52417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52418. sleepBody(impostor: PhysicsImpostor): void;
  52419. wakeUpBody(impostor: PhysicsImpostor): void;
  52420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52421. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52424. getRadius(impostor: PhysicsImpostor): number;
  52425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52426. dispose(): void;
  52427. /**
  52428. * Does a raycast in the physics world
  52429. * @param from when should the ray start?
  52430. * @param to when should the ray end?
  52431. * @returns PhysicsRaycastResult
  52432. */
  52433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52434. }
  52435. }
  52436. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52437. import { Nullable } from "babylonjs/types";
  52438. import { Scene } from "babylonjs/scene";
  52439. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52440. import { Color4 } from "babylonjs/Maths/math.color";
  52441. import { Mesh } from "babylonjs/Meshes/mesh";
  52442. /**
  52443. * Class containing static functions to help procedurally build meshes
  52444. */
  52445. export class RibbonBuilder {
  52446. /**
  52447. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52448. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52449. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52450. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52451. * * 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
  52452. * * 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
  52453. * * 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
  52454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52457. * * 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
  52458. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52459. * * 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
  52460. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52462. * @param name defines the name of the mesh
  52463. * @param options defines the options used to create the mesh
  52464. * @param scene defines the hosting scene
  52465. * @returns the ribbon mesh
  52466. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52468. */
  52469. static CreateRibbon(name: string, options: {
  52470. pathArray: Vector3[][];
  52471. closeArray?: boolean;
  52472. closePath?: boolean;
  52473. offset?: number;
  52474. updatable?: boolean;
  52475. sideOrientation?: number;
  52476. frontUVs?: Vector4;
  52477. backUVs?: Vector4;
  52478. instance?: Mesh;
  52479. invertUV?: boolean;
  52480. uvs?: Vector2[];
  52481. colors?: Color4[];
  52482. }, scene?: Nullable<Scene>): Mesh;
  52483. }
  52484. }
  52485. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52486. import { Nullable } from "babylonjs/types";
  52487. import { Scene } from "babylonjs/scene";
  52488. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52489. import { Mesh } from "babylonjs/Meshes/mesh";
  52490. /**
  52491. * Class containing static functions to help procedurally build meshes
  52492. */
  52493. export class ShapeBuilder {
  52494. /**
  52495. * 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.
  52496. * * 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.
  52497. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52498. * * 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.
  52499. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52500. * * 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
  52501. * * 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
  52502. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52507. * @param name defines the name of the mesh
  52508. * @param options defines the options used to create the mesh
  52509. * @param scene defines the hosting scene
  52510. * @returns the extruded shape mesh
  52511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52513. */
  52514. static ExtrudeShape(name: string, options: {
  52515. shape: Vector3[];
  52516. path: Vector3[];
  52517. scale?: number;
  52518. rotation?: number;
  52519. cap?: number;
  52520. updatable?: boolean;
  52521. sideOrientation?: number;
  52522. frontUVs?: Vector4;
  52523. backUVs?: Vector4;
  52524. instance?: Mesh;
  52525. invertUV?: boolean;
  52526. }, scene?: Nullable<Scene>): Mesh;
  52527. /**
  52528. * Creates an custom extruded shape mesh.
  52529. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52530. * * 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.
  52531. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52532. * * 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
  52533. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52534. * * 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
  52535. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52536. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52537. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52538. * * 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
  52539. * * 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
  52540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52545. * @param name defines the name of the mesh
  52546. * @param options defines the options used to create the mesh
  52547. * @param scene defines the hosting scene
  52548. * @returns the custom extruded shape mesh
  52549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52550. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52552. */
  52553. static ExtrudeShapeCustom(name: string, options: {
  52554. shape: Vector3[];
  52555. path: Vector3[];
  52556. scaleFunction?: any;
  52557. rotationFunction?: any;
  52558. ribbonCloseArray?: boolean;
  52559. ribbonClosePath?: boolean;
  52560. cap?: number;
  52561. updatable?: boolean;
  52562. sideOrientation?: number;
  52563. frontUVs?: Vector4;
  52564. backUVs?: Vector4;
  52565. instance?: Mesh;
  52566. invertUV?: boolean;
  52567. }, scene?: Nullable<Scene>): Mesh;
  52568. private static _ExtrudeShapeGeneric;
  52569. }
  52570. }
  52571. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52572. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52573. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52574. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52575. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52576. import { Nullable } from "babylonjs/types";
  52577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52578. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52579. /**
  52580. * AmmoJS Physics plugin
  52581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52582. * @see https://github.com/kripken/ammo.js/
  52583. */
  52584. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52585. private _useDeltaForWorldStep;
  52586. /**
  52587. * Reference to the Ammo library
  52588. */
  52589. bjsAMMO: any;
  52590. /**
  52591. * Created ammoJS world which physics bodies are added to
  52592. */
  52593. world: any;
  52594. /**
  52595. * Name of the plugin
  52596. */
  52597. name: string;
  52598. private _timeStep;
  52599. private _fixedTimeStep;
  52600. private _maxSteps;
  52601. private _tmpQuaternion;
  52602. private _tmpAmmoTransform;
  52603. private _tmpAmmoQuaternion;
  52604. private _tmpAmmoConcreteContactResultCallback;
  52605. private _collisionConfiguration;
  52606. private _dispatcher;
  52607. private _overlappingPairCache;
  52608. private _solver;
  52609. private _softBodySolver;
  52610. private _tmpAmmoVectorA;
  52611. private _tmpAmmoVectorB;
  52612. private _tmpAmmoVectorC;
  52613. private _tmpAmmoVectorD;
  52614. private _tmpContactCallbackResult;
  52615. private _tmpAmmoVectorRCA;
  52616. private _tmpAmmoVectorRCB;
  52617. private _raycastResult;
  52618. private static readonly DISABLE_COLLISION_FLAG;
  52619. private static readonly KINEMATIC_FLAG;
  52620. private static readonly DISABLE_DEACTIVATION_FLAG;
  52621. /**
  52622. * Initializes the ammoJS plugin
  52623. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52624. * @param ammoInjection can be used to inject your own ammo reference
  52625. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52626. */
  52627. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52628. /**
  52629. * Sets the gravity of the physics world (m/(s^2))
  52630. * @param gravity Gravity to set
  52631. */
  52632. setGravity(gravity: Vector3): void;
  52633. /**
  52634. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52635. * @param timeStep timestep to use in seconds
  52636. */
  52637. setTimeStep(timeStep: number): void;
  52638. /**
  52639. * 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)
  52640. * @param fixedTimeStep fixedTimeStep to use in seconds
  52641. */
  52642. setFixedTimeStep(fixedTimeStep: number): void;
  52643. /**
  52644. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52645. * @param maxSteps the maximum number of steps by the physics engine per frame
  52646. */
  52647. setMaxSteps(maxSteps: number): void;
  52648. /**
  52649. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52650. * @returns the current timestep in seconds
  52651. */
  52652. getTimeStep(): number;
  52653. private _isImpostorInContact;
  52654. private _isImpostorPairInContact;
  52655. private _stepSimulation;
  52656. /**
  52657. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52658. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52659. * After the step the babylon meshes are set to the position of the physics imposters
  52660. * @param delta amount of time to step forward
  52661. * @param impostors array of imposters to update before/after the step
  52662. */
  52663. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52664. /**
  52665. * Update babylon mesh to match physics world object
  52666. * @param impostor imposter to match
  52667. */
  52668. private _afterSoftStep;
  52669. /**
  52670. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52671. * @param impostor imposter to match
  52672. */
  52673. private _ropeStep;
  52674. /**
  52675. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52676. * @param impostor imposter to match
  52677. */
  52678. private _softbodyOrClothStep;
  52679. private _tmpVector;
  52680. private _tmpMatrix;
  52681. /**
  52682. * Applies an impulse on the imposter
  52683. * @param impostor imposter to apply impulse to
  52684. * @param force amount of force to be applied to the imposter
  52685. * @param contactPoint the location to apply the impulse on the imposter
  52686. */
  52687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52688. /**
  52689. * Applies a force on the imposter
  52690. * @param impostor imposter to apply force
  52691. * @param force amount of force to be applied to the imposter
  52692. * @param contactPoint the location to apply the force on the imposter
  52693. */
  52694. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52695. /**
  52696. * Creates a physics body using the plugin
  52697. * @param impostor the imposter to create the physics body on
  52698. */
  52699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52700. /**
  52701. * Removes the physics body from the imposter and disposes of the body's memory
  52702. * @param impostor imposter to remove the physics body from
  52703. */
  52704. removePhysicsBody(impostor: PhysicsImpostor): void;
  52705. /**
  52706. * Generates a joint
  52707. * @param impostorJoint the imposter joint to create the joint with
  52708. */
  52709. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52710. /**
  52711. * Removes a joint
  52712. * @param impostorJoint the imposter joint to remove the joint from
  52713. */
  52714. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52715. private _addMeshVerts;
  52716. /**
  52717. * Initialise the soft body vertices to match its object's (mesh) vertices
  52718. * Softbody vertices (nodes) are in world space and to match this
  52719. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52720. * @param impostor to create the softbody for
  52721. */
  52722. private _softVertexData;
  52723. /**
  52724. * Create an impostor's soft body
  52725. * @param impostor to create the softbody for
  52726. */
  52727. private _createSoftbody;
  52728. /**
  52729. * Create cloth for an impostor
  52730. * @param impostor to create the softbody for
  52731. */
  52732. private _createCloth;
  52733. /**
  52734. * Create rope for an impostor
  52735. * @param impostor to create the softbody for
  52736. */
  52737. private _createRope;
  52738. private _addHullVerts;
  52739. private _createShape;
  52740. /**
  52741. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52742. * @param impostor imposter containing the physics body and babylon object
  52743. */
  52744. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52745. /**
  52746. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52747. * @param impostor imposter containing the physics body and babylon object
  52748. * @param newPosition new position
  52749. * @param newRotation new rotation
  52750. */
  52751. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52752. /**
  52753. * If this plugin is supported
  52754. * @returns true if its supported
  52755. */
  52756. isSupported(): boolean;
  52757. /**
  52758. * Sets the linear velocity of the physics body
  52759. * @param impostor imposter to set the velocity on
  52760. * @param velocity velocity to set
  52761. */
  52762. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52763. /**
  52764. * Sets the angular velocity of the physics body
  52765. * @param impostor imposter to set the velocity on
  52766. * @param velocity velocity to set
  52767. */
  52768. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52769. /**
  52770. * gets the linear velocity
  52771. * @param impostor imposter to get linear velocity from
  52772. * @returns linear velocity
  52773. */
  52774. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52775. /**
  52776. * gets the angular velocity
  52777. * @param impostor imposter to get angular velocity from
  52778. * @returns angular velocity
  52779. */
  52780. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52781. /**
  52782. * Sets the mass of physics body
  52783. * @param impostor imposter to set the mass on
  52784. * @param mass mass to set
  52785. */
  52786. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52787. /**
  52788. * Gets the mass of the physics body
  52789. * @param impostor imposter to get the mass from
  52790. * @returns mass
  52791. */
  52792. getBodyMass(impostor: PhysicsImpostor): number;
  52793. /**
  52794. * Gets friction of the impostor
  52795. * @param impostor impostor to get friction from
  52796. * @returns friction value
  52797. */
  52798. getBodyFriction(impostor: PhysicsImpostor): number;
  52799. /**
  52800. * Sets friction of the impostor
  52801. * @param impostor impostor to set friction on
  52802. * @param friction friction value
  52803. */
  52804. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52805. /**
  52806. * Gets restitution of the impostor
  52807. * @param impostor impostor to get restitution from
  52808. * @returns restitution value
  52809. */
  52810. getBodyRestitution(impostor: PhysicsImpostor): number;
  52811. /**
  52812. * Sets resitution of the impostor
  52813. * @param impostor impostor to set resitution on
  52814. * @param restitution resitution value
  52815. */
  52816. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52817. /**
  52818. * Gets pressure inside the impostor
  52819. * @param impostor impostor to get pressure from
  52820. * @returns pressure value
  52821. */
  52822. getBodyPressure(impostor: PhysicsImpostor): number;
  52823. /**
  52824. * Sets pressure inside a soft body impostor
  52825. * Cloth and rope must remain 0 pressure
  52826. * @param impostor impostor to set pressure on
  52827. * @param pressure pressure value
  52828. */
  52829. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52830. /**
  52831. * Gets stiffness of the impostor
  52832. * @param impostor impostor to get stiffness from
  52833. * @returns pressure value
  52834. */
  52835. getBodyStiffness(impostor: PhysicsImpostor): number;
  52836. /**
  52837. * Sets stiffness of the impostor
  52838. * @param impostor impostor to set stiffness on
  52839. * @param stiffness stiffness value from 0 to 1
  52840. */
  52841. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52842. /**
  52843. * Gets velocityIterations of the impostor
  52844. * @param impostor impostor to get velocity iterations from
  52845. * @returns velocityIterations value
  52846. */
  52847. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52848. /**
  52849. * Sets velocityIterations of the impostor
  52850. * @param impostor impostor to set velocity iterations on
  52851. * @param velocityIterations velocityIterations value
  52852. */
  52853. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52854. /**
  52855. * Gets positionIterations of the impostor
  52856. * @param impostor impostor to get position iterations from
  52857. * @returns positionIterations value
  52858. */
  52859. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52860. /**
  52861. * Sets positionIterations of the impostor
  52862. * @param impostor impostor to set position on
  52863. * @param positionIterations positionIterations value
  52864. */
  52865. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52866. /**
  52867. * Append an anchor to a cloth object
  52868. * @param impostor is the cloth impostor to add anchor to
  52869. * @param otherImpostor is the rigid impostor to anchor to
  52870. * @param width ratio across width from 0 to 1
  52871. * @param height ratio up height from 0 to 1
  52872. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52874. */
  52875. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52876. /**
  52877. * Append an hook to a rope object
  52878. * @param impostor is the rope impostor to add hook to
  52879. * @param otherImpostor is the rigid impostor to hook to
  52880. * @param length ratio along the rope from 0 to 1
  52881. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52882. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52883. */
  52884. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52885. /**
  52886. * Sleeps the physics body and stops it from being active
  52887. * @param impostor impostor to sleep
  52888. */
  52889. sleepBody(impostor: PhysicsImpostor): void;
  52890. /**
  52891. * Activates the physics body
  52892. * @param impostor impostor to activate
  52893. */
  52894. wakeUpBody(impostor: PhysicsImpostor): void;
  52895. /**
  52896. * Updates the distance parameters of the joint
  52897. * @param joint joint to update
  52898. * @param maxDistance maximum distance of the joint
  52899. * @param minDistance minimum distance of the joint
  52900. */
  52901. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52902. /**
  52903. * Sets a motor on the joint
  52904. * @param joint joint to set motor on
  52905. * @param speed speed of the motor
  52906. * @param maxForce maximum force of the motor
  52907. * @param motorIndex index of the motor
  52908. */
  52909. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52910. /**
  52911. * Sets the motors limit
  52912. * @param joint joint to set limit on
  52913. * @param upperLimit upper limit
  52914. * @param lowerLimit lower limit
  52915. */
  52916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52917. /**
  52918. * Syncs the position and rotation of a mesh with the impostor
  52919. * @param mesh mesh to sync
  52920. * @param impostor impostor to update the mesh with
  52921. */
  52922. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52923. /**
  52924. * Gets the radius of the impostor
  52925. * @param impostor impostor to get radius from
  52926. * @returns the radius
  52927. */
  52928. getRadius(impostor: PhysicsImpostor): number;
  52929. /**
  52930. * Gets the box size of the impostor
  52931. * @param impostor impostor to get box size from
  52932. * @param result the resulting box size
  52933. */
  52934. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52935. /**
  52936. * Disposes of the impostor
  52937. */
  52938. dispose(): void;
  52939. /**
  52940. * Does a raycast in the physics world
  52941. * @param from when should the ray start?
  52942. * @param to when should the ray end?
  52943. * @returns PhysicsRaycastResult
  52944. */
  52945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52946. }
  52947. }
  52948. declare module "babylonjs/Probes/reflectionProbe" {
  52949. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52950. import { Vector3 } from "babylonjs/Maths/math.vector";
  52951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52952. import { Nullable } from "babylonjs/types";
  52953. import { Scene } from "babylonjs/scene";
  52954. module "babylonjs/abstractScene" {
  52955. interface AbstractScene {
  52956. /**
  52957. * The list of reflection probes added to the scene
  52958. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52959. */
  52960. reflectionProbes: Array<ReflectionProbe>;
  52961. /**
  52962. * Removes the given reflection probe from this scene.
  52963. * @param toRemove The reflection probe to remove
  52964. * @returns The index of the removed reflection probe
  52965. */
  52966. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52967. /**
  52968. * Adds the given reflection probe to this scene.
  52969. * @param newReflectionProbe The reflection probe to add
  52970. */
  52971. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52972. }
  52973. }
  52974. /**
  52975. * Class used to generate realtime reflection / refraction cube textures
  52976. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52977. */
  52978. export class ReflectionProbe {
  52979. /** defines the name of the probe */
  52980. name: string;
  52981. private _scene;
  52982. private _renderTargetTexture;
  52983. private _projectionMatrix;
  52984. private _viewMatrix;
  52985. private _target;
  52986. private _add;
  52987. private _attachedMesh;
  52988. private _invertYAxis;
  52989. /** Gets or sets probe position (center of the cube map) */
  52990. position: Vector3;
  52991. /**
  52992. * Creates a new reflection probe
  52993. * @param name defines the name of the probe
  52994. * @param size defines the texture resolution (for each face)
  52995. * @param scene defines the hosting scene
  52996. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52997. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52998. */
  52999. constructor(
  53000. /** defines the name of the probe */
  53001. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53002. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53003. samples: number;
  53004. /** Gets or sets the refresh rate to use (on every frame by default) */
  53005. refreshRate: number;
  53006. /**
  53007. * Gets the hosting scene
  53008. * @returns a Scene
  53009. */
  53010. getScene(): Scene;
  53011. /** Gets the internal CubeTexture used to render to */
  53012. readonly cubeTexture: RenderTargetTexture;
  53013. /** Gets the list of meshes to render */
  53014. readonly renderList: Nullable<AbstractMesh[]>;
  53015. /**
  53016. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53017. * @param mesh defines the mesh to attach to
  53018. */
  53019. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53020. /**
  53021. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53022. * @param renderingGroupId The rendering group id corresponding to its index
  53023. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53024. */
  53025. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53026. /**
  53027. * Clean all associated resources
  53028. */
  53029. dispose(): void;
  53030. /**
  53031. * Converts the reflection probe information to a readable string for debug purpose.
  53032. * @param fullDetails Supports for multiple levels of logging within scene loading
  53033. * @returns the human readable reflection probe info
  53034. */
  53035. toString(fullDetails?: boolean): string;
  53036. /**
  53037. * Get the class name of the relfection probe.
  53038. * @returns "ReflectionProbe"
  53039. */
  53040. getClassName(): string;
  53041. /**
  53042. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53043. * @returns The JSON representation of the texture
  53044. */
  53045. serialize(): any;
  53046. /**
  53047. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53048. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53049. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53050. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53051. * @returns The parsed reflection probe if successful
  53052. */
  53053. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53054. }
  53055. }
  53056. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53057. /** @hidden */
  53058. export var _BabylonLoaderRegistered: boolean;
  53059. }
  53060. declare module "babylonjs/Loading/Plugins/index" {
  53061. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53062. }
  53063. declare module "babylonjs/Loading/index" {
  53064. export * from "babylonjs/Loading/loadingScreen";
  53065. export * from "babylonjs/Loading/Plugins/index";
  53066. export * from "babylonjs/Loading/sceneLoader";
  53067. export * from "babylonjs/Loading/sceneLoaderFlags";
  53068. }
  53069. declare module "babylonjs/Materials/Background/index" {
  53070. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53071. }
  53072. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53073. import { Scene } from "babylonjs/scene";
  53074. import { Color3 } from "babylonjs/Maths/math.color";
  53075. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53077. /**
  53078. * The Physically based simple base material of BJS.
  53079. *
  53080. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53081. * It is used as the base class for both the specGloss and metalRough conventions.
  53082. */
  53083. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53084. /**
  53085. * Number of Simultaneous lights allowed on the material.
  53086. */
  53087. maxSimultaneousLights: number;
  53088. /**
  53089. * If sets to true, disables all the lights affecting the material.
  53090. */
  53091. disableLighting: boolean;
  53092. /**
  53093. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53094. */
  53095. environmentTexture: BaseTexture;
  53096. /**
  53097. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53098. */
  53099. invertNormalMapX: boolean;
  53100. /**
  53101. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53102. */
  53103. invertNormalMapY: boolean;
  53104. /**
  53105. * Normal map used in the model.
  53106. */
  53107. normalTexture: BaseTexture;
  53108. /**
  53109. * Emissivie color used to self-illuminate the model.
  53110. */
  53111. emissiveColor: Color3;
  53112. /**
  53113. * Emissivie texture used to self-illuminate the model.
  53114. */
  53115. emissiveTexture: BaseTexture;
  53116. /**
  53117. * Occlusion Channel Strenght.
  53118. */
  53119. occlusionStrength: number;
  53120. /**
  53121. * Occlusion Texture of the material (adding extra occlusion effects).
  53122. */
  53123. occlusionTexture: BaseTexture;
  53124. /**
  53125. * Defines the alpha limits in alpha test mode.
  53126. */
  53127. alphaCutOff: number;
  53128. /**
  53129. * Gets the current double sided mode.
  53130. */
  53131. /**
  53132. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53133. */
  53134. doubleSided: boolean;
  53135. /**
  53136. * Stores the pre-calculated light information of a mesh in a texture.
  53137. */
  53138. lightmapTexture: BaseTexture;
  53139. /**
  53140. * If true, the light map contains occlusion information instead of lighting info.
  53141. */
  53142. useLightmapAsShadowmap: boolean;
  53143. /**
  53144. * Instantiates a new PBRMaterial instance.
  53145. *
  53146. * @param name The material name
  53147. * @param scene The scene the material will be use in.
  53148. */
  53149. constructor(name: string, scene: Scene);
  53150. getClassName(): string;
  53151. }
  53152. }
  53153. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53154. import { Scene } from "babylonjs/scene";
  53155. import { Color3 } from "babylonjs/Maths/math.color";
  53156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53157. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53158. /**
  53159. * The PBR material of BJS following the metal roughness convention.
  53160. *
  53161. * This fits to the PBR convention in the GLTF definition:
  53162. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53163. */
  53164. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53165. /**
  53166. * The base color has two different interpretations depending on the value of metalness.
  53167. * When the material is a metal, the base color is the specific measured reflectance value
  53168. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53169. * of the material.
  53170. */
  53171. baseColor: Color3;
  53172. /**
  53173. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53174. * well as opacity information in the alpha channel.
  53175. */
  53176. baseTexture: BaseTexture;
  53177. /**
  53178. * Specifies the metallic scalar value of the material.
  53179. * Can also be used to scale the metalness values of the metallic texture.
  53180. */
  53181. metallic: number;
  53182. /**
  53183. * Specifies the roughness scalar value of the material.
  53184. * Can also be used to scale the roughness values of the metallic texture.
  53185. */
  53186. roughness: number;
  53187. /**
  53188. * Texture containing both the metallic value in the B channel and the
  53189. * roughness value in the G channel to keep better precision.
  53190. */
  53191. metallicRoughnessTexture: BaseTexture;
  53192. /**
  53193. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53194. *
  53195. * @param name The material name
  53196. * @param scene The scene the material will be use in.
  53197. */
  53198. constructor(name: string, scene: Scene);
  53199. /**
  53200. * Return the currrent class name of the material.
  53201. */
  53202. getClassName(): string;
  53203. /**
  53204. * Makes a duplicate of the current material.
  53205. * @param name - name to use for the new material.
  53206. */
  53207. clone(name: string): PBRMetallicRoughnessMaterial;
  53208. /**
  53209. * Serialize the material to a parsable JSON object.
  53210. */
  53211. serialize(): any;
  53212. /**
  53213. * Parses a JSON object correponding to the serialize function.
  53214. */
  53215. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53216. }
  53217. }
  53218. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53219. import { Scene } from "babylonjs/scene";
  53220. import { Color3 } from "babylonjs/Maths/math.color";
  53221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53222. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53223. /**
  53224. * The PBR material of BJS following the specular glossiness convention.
  53225. *
  53226. * This fits to the PBR convention in the GLTF definition:
  53227. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53228. */
  53229. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53230. /**
  53231. * Specifies the diffuse color of the material.
  53232. */
  53233. diffuseColor: Color3;
  53234. /**
  53235. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53236. * channel.
  53237. */
  53238. diffuseTexture: BaseTexture;
  53239. /**
  53240. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53241. */
  53242. specularColor: Color3;
  53243. /**
  53244. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53245. */
  53246. glossiness: number;
  53247. /**
  53248. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53249. */
  53250. specularGlossinessTexture: BaseTexture;
  53251. /**
  53252. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53253. *
  53254. * @param name The material name
  53255. * @param scene The scene the material will be use in.
  53256. */
  53257. constructor(name: string, scene: Scene);
  53258. /**
  53259. * Return the currrent class name of the material.
  53260. */
  53261. getClassName(): string;
  53262. /**
  53263. * Makes a duplicate of the current material.
  53264. * @param name - name to use for the new material.
  53265. */
  53266. clone(name: string): PBRSpecularGlossinessMaterial;
  53267. /**
  53268. * Serialize the material to a parsable JSON object.
  53269. */
  53270. serialize(): any;
  53271. /**
  53272. * Parses a JSON object correponding to the serialize function.
  53273. */
  53274. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53275. }
  53276. }
  53277. declare module "babylonjs/Materials/PBR/index" {
  53278. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53279. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53280. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53281. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53282. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53283. }
  53284. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53285. import { Nullable } from "babylonjs/types";
  53286. import { Scene } from "babylonjs/scene";
  53287. import { Matrix } from "babylonjs/Maths/math.vector";
  53288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53289. /**
  53290. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53291. * It can help converting any input color in a desired output one. This can then be used to create effects
  53292. * from sepia, black and white to sixties or futuristic rendering...
  53293. *
  53294. * The only supported format is currently 3dl.
  53295. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53296. */
  53297. export class ColorGradingTexture extends BaseTexture {
  53298. /**
  53299. * The current texture matrix. (will always be identity in color grading texture)
  53300. */
  53301. private _textureMatrix;
  53302. /**
  53303. * The texture URL.
  53304. */
  53305. url: string;
  53306. /**
  53307. * Empty line regex stored for GC.
  53308. */
  53309. private static _noneEmptyLineRegex;
  53310. private _engine;
  53311. /**
  53312. * Instantiates a ColorGradingTexture from the following parameters.
  53313. *
  53314. * @param url The location of the color gradind data (currently only supporting 3dl)
  53315. * @param scene The scene the texture will be used in
  53316. */
  53317. constructor(url: string, scene: Scene);
  53318. /**
  53319. * Returns the texture matrix used in most of the material.
  53320. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53321. */
  53322. getTextureMatrix(): Matrix;
  53323. /**
  53324. * Occurs when the file being loaded is a .3dl LUT file.
  53325. */
  53326. private load3dlTexture;
  53327. /**
  53328. * Starts the loading process of the texture.
  53329. */
  53330. private loadTexture;
  53331. /**
  53332. * Clones the color gradind texture.
  53333. */
  53334. clone(): ColorGradingTexture;
  53335. /**
  53336. * Called during delayed load for textures.
  53337. */
  53338. delayLoad(): void;
  53339. /**
  53340. * Parses a color grading texture serialized by Babylon.
  53341. * @param parsedTexture The texture information being parsedTexture
  53342. * @param scene The scene to load the texture in
  53343. * @param rootUrl The root url of the data assets to load
  53344. * @return A color gradind texture
  53345. */
  53346. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53347. /**
  53348. * Serializes the LUT texture to json format.
  53349. */
  53350. serialize(): any;
  53351. }
  53352. }
  53353. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53355. import { Scene } from "babylonjs/scene";
  53356. import { Nullable } from "babylonjs/types";
  53357. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53358. /**
  53359. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53360. */
  53361. export class EquiRectangularCubeTexture extends BaseTexture {
  53362. /** The six faces of the cube. */
  53363. private static _FacesMapping;
  53364. private _noMipmap;
  53365. private _onLoad;
  53366. private _onError;
  53367. /** The size of the cubemap. */
  53368. private _size;
  53369. /** The buffer of the image. */
  53370. private _buffer;
  53371. /** The width of the input image. */
  53372. private _width;
  53373. /** The height of the input image. */
  53374. private _height;
  53375. /** The URL to the image. */
  53376. url: string;
  53377. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53378. coordinatesMode: number;
  53379. /**
  53380. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53381. * @param url The location of the image
  53382. * @param scene The scene the texture will be used in
  53383. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53384. * @param noMipmap Forces to not generate the mipmap if true
  53385. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53386. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53387. * @param onLoad — defines a callback called when texture is loaded
  53388. * @param onError — defines a callback called if there is an error
  53389. */
  53390. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53391. /**
  53392. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53393. */
  53394. private loadImage;
  53395. /**
  53396. * Convert the image buffer into a cubemap and create a CubeTexture.
  53397. */
  53398. private loadTexture;
  53399. /**
  53400. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53401. * @param buffer The ArrayBuffer that should be converted.
  53402. * @returns The buffer as Float32Array.
  53403. */
  53404. private getFloat32ArrayFromArrayBuffer;
  53405. /**
  53406. * Get the current class name of the texture useful for serialization or dynamic coding.
  53407. * @returns "EquiRectangularCubeTexture"
  53408. */
  53409. getClassName(): string;
  53410. /**
  53411. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53412. * @returns A clone of the current EquiRectangularCubeTexture.
  53413. */
  53414. clone(): EquiRectangularCubeTexture;
  53415. }
  53416. }
  53417. declare module "babylonjs/Misc/tga" {
  53418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53419. /**
  53420. * Based on jsTGALoader - Javascript loader for TGA file
  53421. * By Vincent Thibault
  53422. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53423. */
  53424. export class TGATools {
  53425. private static _TYPE_INDEXED;
  53426. private static _TYPE_RGB;
  53427. private static _TYPE_GREY;
  53428. private static _TYPE_RLE_INDEXED;
  53429. private static _TYPE_RLE_RGB;
  53430. private static _TYPE_RLE_GREY;
  53431. private static _ORIGIN_MASK;
  53432. private static _ORIGIN_SHIFT;
  53433. private static _ORIGIN_BL;
  53434. private static _ORIGIN_BR;
  53435. private static _ORIGIN_UL;
  53436. private static _ORIGIN_UR;
  53437. /**
  53438. * Gets the header of a TGA file
  53439. * @param data defines the TGA data
  53440. * @returns the header
  53441. */
  53442. static GetTGAHeader(data: Uint8Array): any;
  53443. /**
  53444. * Uploads TGA content to a Babylon Texture
  53445. * @hidden
  53446. */
  53447. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53448. /** @hidden */
  53449. 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;
  53450. /** @hidden */
  53451. 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;
  53452. /** @hidden */
  53453. 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;
  53454. /** @hidden */
  53455. 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;
  53456. /** @hidden */
  53457. 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;
  53458. /** @hidden */
  53459. 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;
  53460. }
  53461. }
  53462. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53463. import { Nullable } from "babylonjs/types";
  53464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53465. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53466. /**
  53467. * Implementation of the TGA Texture Loader.
  53468. * @hidden
  53469. */
  53470. export class _TGATextureLoader implements IInternalTextureLoader {
  53471. /**
  53472. * Defines wether the loader supports cascade loading the different faces.
  53473. */
  53474. readonly supportCascades: boolean;
  53475. /**
  53476. * This returns if the loader support the current file information.
  53477. * @param extension defines the file extension of the file being loaded
  53478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53479. * @param fallback defines the fallback internal texture if any
  53480. * @param isBase64 defines whether the texture is encoded as a base64
  53481. * @param isBuffer defines whether the texture data are stored as a buffer
  53482. * @returns true if the loader can load the specified file
  53483. */
  53484. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53485. /**
  53486. * Transform the url before loading if required.
  53487. * @param rootUrl the url of the texture
  53488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53489. * @returns the transformed texture
  53490. */
  53491. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53492. /**
  53493. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53494. * @param rootUrl the url of the texture
  53495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53496. * @returns the fallback texture
  53497. */
  53498. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53499. /**
  53500. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53501. * @param data contains the texture data
  53502. * @param texture defines the BabylonJS internal texture
  53503. * @param createPolynomials will be true if polynomials have been requested
  53504. * @param onLoad defines the callback to trigger once the texture is ready
  53505. * @param onError defines the callback to trigger in case of error
  53506. */
  53507. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53508. /**
  53509. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53510. * @param data contains the texture data
  53511. * @param texture defines the BabylonJS internal texture
  53512. * @param callback defines the method to call once ready to upload
  53513. */
  53514. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53515. }
  53516. }
  53517. declare module "babylonjs/Misc/basis" {
  53518. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53519. /**
  53520. * Info about the .basis files
  53521. */
  53522. class BasisFileInfo {
  53523. /**
  53524. * If the file has alpha
  53525. */
  53526. hasAlpha: boolean;
  53527. /**
  53528. * Info about each image of the basis file
  53529. */
  53530. images: Array<{
  53531. levels: Array<{
  53532. width: number;
  53533. height: number;
  53534. transcodedPixels: ArrayBufferView;
  53535. }>;
  53536. }>;
  53537. }
  53538. /**
  53539. * Result of transcoding a basis file
  53540. */
  53541. class TranscodeResult {
  53542. /**
  53543. * Info about the .basis file
  53544. */
  53545. fileInfo: BasisFileInfo;
  53546. /**
  53547. * Format to use when loading the file
  53548. */
  53549. format: number;
  53550. }
  53551. /**
  53552. * Configuration options for the Basis transcoder
  53553. */
  53554. export class BasisTranscodeConfiguration {
  53555. /**
  53556. * Supported compression formats used to determine the supported output format of the transcoder
  53557. */
  53558. supportedCompressionFormats?: {
  53559. /**
  53560. * etc1 compression format
  53561. */
  53562. etc1?: boolean;
  53563. /**
  53564. * s3tc compression format
  53565. */
  53566. s3tc?: boolean;
  53567. /**
  53568. * pvrtc compression format
  53569. */
  53570. pvrtc?: boolean;
  53571. /**
  53572. * etc2 compression format
  53573. */
  53574. etc2?: boolean;
  53575. };
  53576. /**
  53577. * If mipmap levels should be loaded for transcoded images (Default: true)
  53578. */
  53579. loadMipmapLevels?: boolean;
  53580. /**
  53581. * Index of a single image to load (Default: all images)
  53582. */
  53583. loadSingleImage?: number;
  53584. }
  53585. /**
  53586. * Used to load .Basis files
  53587. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53588. */
  53589. export class BasisTools {
  53590. private static _IgnoreSupportedFormats;
  53591. /**
  53592. * URL to use when loading the basis transcoder
  53593. */
  53594. static JSModuleURL: string;
  53595. /**
  53596. * URL to use when loading the wasm module for the transcoder
  53597. */
  53598. static WasmModuleURL: string;
  53599. /**
  53600. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53601. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53602. * @returns internal format corresponding to the Basis format
  53603. */
  53604. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53605. private static _WorkerPromise;
  53606. private static _Worker;
  53607. private static _actionId;
  53608. private static _CreateWorkerAsync;
  53609. /**
  53610. * Transcodes a loaded image file to compressed pixel data
  53611. * @param imageData image data to transcode
  53612. * @param config configuration options for the transcoding
  53613. * @returns a promise resulting in the transcoded image
  53614. */
  53615. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53616. /**
  53617. * Loads a texture from the transcode result
  53618. * @param texture texture load to
  53619. * @param transcodeResult the result of transcoding the basis file to load from
  53620. */
  53621. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53622. }
  53623. }
  53624. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53625. import { Nullable } from "babylonjs/types";
  53626. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53627. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53628. /**
  53629. * Loader for .basis file format
  53630. */
  53631. export class _BasisTextureLoader implements IInternalTextureLoader {
  53632. /**
  53633. * Defines whether the loader supports cascade loading the different faces.
  53634. */
  53635. readonly supportCascades: boolean;
  53636. /**
  53637. * This returns if the loader support the current file information.
  53638. * @param extension defines the file extension of the file being loaded
  53639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53640. * @param fallback defines the fallback internal texture if any
  53641. * @param isBase64 defines whether the texture is encoded as a base64
  53642. * @param isBuffer defines whether the texture data are stored as a buffer
  53643. * @returns true if the loader can load the specified file
  53644. */
  53645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53646. /**
  53647. * Transform the url before loading if required.
  53648. * @param rootUrl the url of the texture
  53649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53650. * @returns the transformed texture
  53651. */
  53652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53653. /**
  53654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53655. * @param rootUrl the url of the texture
  53656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53657. * @returns the fallback texture
  53658. */
  53659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53660. /**
  53661. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53662. * @param data contains the texture data
  53663. * @param texture defines the BabylonJS internal texture
  53664. * @param createPolynomials will be true if polynomials have been requested
  53665. * @param onLoad defines the callback to trigger once the texture is ready
  53666. * @param onError defines the callback to trigger in case of error
  53667. */
  53668. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53669. /**
  53670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53671. * @param data contains the texture data
  53672. * @param texture defines the BabylonJS internal texture
  53673. * @param callback defines the method to call once ready to upload
  53674. */
  53675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53676. }
  53677. }
  53678. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53679. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53680. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53681. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53682. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53683. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53684. }
  53685. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53686. import { Scene } from "babylonjs/scene";
  53687. import { Texture } from "babylonjs/Materials/Textures/texture";
  53688. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53689. /**
  53690. * 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.
  53691. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53692. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53693. */
  53694. export class CustomProceduralTexture extends ProceduralTexture {
  53695. private _animate;
  53696. private _time;
  53697. private _config;
  53698. private _texturePath;
  53699. /**
  53700. * Instantiates a new Custom Procedural Texture.
  53701. * 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.
  53702. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53704. * @param name Define the name of the texture
  53705. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53706. * @param size Define the size of the texture to create
  53707. * @param scene Define the scene the texture belongs to
  53708. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53709. * @param generateMipMaps Define if the texture should creates mip maps or not
  53710. */
  53711. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53712. private _loadJson;
  53713. /**
  53714. * Is the texture ready to be used ? (rendered at least once)
  53715. * @returns true if ready, otherwise, false.
  53716. */
  53717. isReady(): boolean;
  53718. /**
  53719. * Render the texture to its associated render target.
  53720. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53721. */
  53722. render(useCameraPostProcess?: boolean): void;
  53723. /**
  53724. * Update the list of dependant textures samplers in the shader.
  53725. */
  53726. updateTextures(): void;
  53727. /**
  53728. * Update the uniform values of the procedural texture in the shader.
  53729. */
  53730. updateShaderUniforms(): void;
  53731. /**
  53732. * Define if the texture animates or not.
  53733. */
  53734. animate: boolean;
  53735. }
  53736. }
  53737. declare module "babylonjs/Shaders/noise.fragment" {
  53738. /** @hidden */
  53739. export var noisePixelShader: {
  53740. name: string;
  53741. shader: string;
  53742. };
  53743. }
  53744. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53745. import { Nullable } from "babylonjs/types";
  53746. import { Scene } from "babylonjs/scene";
  53747. import { Texture } from "babylonjs/Materials/Textures/texture";
  53748. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53749. import "babylonjs/Shaders/noise.fragment";
  53750. /**
  53751. * Class used to generate noise procedural textures
  53752. */
  53753. export class NoiseProceduralTexture extends ProceduralTexture {
  53754. private _time;
  53755. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53756. brightness: number;
  53757. /** Defines the number of octaves to process */
  53758. octaves: number;
  53759. /** Defines the level of persistence (0.8 by default) */
  53760. persistence: number;
  53761. /** Gets or sets animation speed factor (default is 1) */
  53762. animationSpeedFactor: number;
  53763. /**
  53764. * Creates a new NoiseProceduralTexture
  53765. * @param name defines the name fo the texture
  53766. * @param size defines the size of the texture (default is 256)
  53767. * @param scene defines the hosting scene
  53768. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53769. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53770. */
  53771. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53772. private _updateShaderUniforms;
  53773. protected _getDefines(): string;
  53774. /** Generate the current state of the procedural texture */
  53775. render(useCameraPostProcess?: boolean): void;
  53776. /**
  53777. * Serializes this noise procedural texture
  53778. * @returns a serialized noise procedural texture object
  53779. */
  53780. serialize(): any;
  53781. /**
  53782. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53783. * @param parsedTexture defines parsed texture data
  53784. * @param scene defines the current scene
  53785. * @param rootUrl defines the root URL containing noise procedural texture information
  53786. * @returns a parsed NoiseProceduralTexture
  53787. */
  53788. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53789. }
  53790. }
  53791. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53792. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53793. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53794. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53795. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53796. }
  53797. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53798. import { Nullable } from "babylonjs/types";
  53799. import { Scene } from "babylonjs/scene";
  53800. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53802. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53803. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53804. /**
  53805. * Raw cube texture where the raw buffers are passed in
  53806. */
  53807. export class RawCubeTexture extends CubeTexture {
  53808. /**
  53809. * Creates a cube texture where the raw buffers are passed in.
  53810. * @param scene defines the scene the texture is attached to
  53811. * @param data defines the array of data to use to create each face
  53812. * @param size defines the size of the textures
  53813. * @param format defines the format of the data
  53814. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53815. * @param generateMipMaps defines if the engine should generate the mip levels
  53816. * @param invertY defines if data must be stored with Y axis inverted
  53817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53818. * @param compression defines the compression used (null by default)
  53819. */
  53820. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53821. /**
  53822. * Updates the raw cube texture.
  53823. * @param data defines the data to store
  53824. * @param format defines the data format
  53825. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53826. * @param invertY defines if data must be stored with Y axis inverted
  53827. * @param compression defines the compression used (null by default)
  53828. * @param level defines which level of the texture to update
  53829. */
  53830. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53831. /**
  53832. * Updates a raw cube texture with RGBD encoded data.
  53833. * @param data defines the array of data [mipmap][face] to use to create each face
  53834. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53835. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53836. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53837. * @returns a promsie that resolves when the operation is complete
  53838. */
  53839. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53840. /**
  53841. * Clones the raw cube texture.
  53842. * @return a new cube texture
  53843. */
  53844. clone(): CubeTexture;
  53845. /** @hidden */
  53846. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53847. }
  53848. }
  53849. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53850. import { Scene } from "babylonjs/scene";
  53851. import { Texture } from "babylonjs/Materials/Textures/texture";
  53852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53853. /**
  53854. * Class used to store 3D textures containing user data
  53855. */
  53856. export class RawTexture3D extends Texture {
  53857. /** Gets or sets the texture format to use */
  53858. format: number;
  53859. private _engine;
  53860. /**
  53861. * Create a new RawTexture3D
  53862. * @param data defines the data of the texture
  53863. * @param width defines the width of the texture
  53864. * @param height defines the height of the texture
  53865. * @param depth defines the depth of the texture
  53866. * @param format defines the texture format to use
  53867. * @param scene defines the hosting scene
  53868. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53869. * @param invertY defines if texture must be stored with Y axis inverted
  53870. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53871. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53872. */
  53873. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53874. /** Gets or sets the texture format to use */
  53875. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53876. /**
  53877. * Update the texture with new data
  53878. * @param data defines the data to store in the texture
  53879. */
  53880. update(data: ArrayBufferView): void;
  53881. }
  53882. }
  53883. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53884. import { Scene } from "babylonjs/scene";
  53885. import { Plane } from "babylonjs/Maths/math.plane";
  53886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53887. /**
  53888. * Creates a refraction texture used by refraction channel of the standard material.
  53889. * It is like a mirror but to see through a material.
  53890. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53891. */
  53892. export class RefractionTexture extends RenderTargetTexture {
  53893. /**
  53894. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53895. * 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.
  53896. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53897. */
  53898. refractionPlane: Plane;
  53899. /**
  53900. * Define how deep under the surface we should see.
  53901. */
  53902. depth: number;
  53903. /**
  53904. * Creates a refraction texture used by refraction channel of the standard material.
  53905. * It is like a mirror but to see through a material.
  53906. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53907. * @param name Define the texture name
  53908. * @param size Define the size of the underlying texture
  53909. * @param scene Define the scene the refraction belongs to
  53910. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53911. */
  53912. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53913. /**
  53914. * Clone the refraction texture.
  53915. * @returns the cloned texture
  53916. */
  53917. clone(): RefractionTexture;
  53918. /**
  53919. * Serialize the texture to a JSON representation you could use in Parse later on
  53920. * @returns the serialized JSON representation
  53921. */
  53922. serialize(): any;
  53923. }
  53924. }
  53925. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53926. import { Nullable } from "babylonjs/types";
  53927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53928. import { Matrix } from "babylonjs/Maths/math.vector";
  53929. import { Engine } from "babylonjs/Engines/engine";
  53930. import { Scene } from "babylonjs/scene";
  53931. /**
  53932. * Defines the options related to the creation of an HtmlElementTexture
  53933. */
  53934. export interface IHtmlElementTextureOptions {
  53935. /**
  53936. * Defines wether mip maps should be created or not.
  53937. */
  53938. generateMipMaps?: boolean;
  53939. /**
  53940. * Defines the sampling mode of the texture.
  53941. */
  53942. samplingMode?: number;
  53943. /**
  53944. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53945. */
  53946. engine: Nullable<Engine>;
  53947. /**
  53948. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53949. */
  53950. scene: Nullable<Scene>;
  53951. }
  53952. /**
  53953. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53954. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53955. * is automatically managed.
  53956. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53957. * in your application.
  53958. *
  53959. * As the update is not automatic, you need to call them manually.
  53960. */
  53961. export class HtmlElementTexture extends BaseTexture {
  53962. /**
  53963. * The texture URL.
  53964. */
  53965. element: HTMLVideoElement | HTMLCanvasElement;
  53966. private static readonly DefaultOptions;
  53967. private _textureMatrix;
  53968. private _engine;
  53969. private _isVideo;
  53970. private _generateMipMaps;
  53971. private _samplingMode;
  53972. /**
  53973. * Instantiates a HtmlElementTexture from the following parameters.
  53974. *
  53975. * @param name Defines the name of the texture
  53976. * @param element Defines the video or canvas the texture is filled with
  53977. * @param options Defines the other none mandatory texture creation options
  53978. */
  53979. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53980. private _createInternalTexture;
  53981. /**
  53982. * Returns the texture matrix used in most of the material.
  53983. */
  53984. getTextureMatrix(): Matrix;
  53985. /**
  53986. * Updates the content of the texture.
  53987. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53988. */
  53989. update(invertY?: Nullable<boolean>): void;
  53990. }
  53991. }
  53992. declare module "babylonjs/Materials/Textures/index" {
  53993. export * from "babylonjs/Materials/Textures/baseTexture";
  53994. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53995. export * from "babylonjs/Materials/Textures/cubeTexture";
  53996. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53997. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53998. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53999. export * from "babylonjs/Materials/Textures/internalTexture";
  54000. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54001. export * from "babylonjs/Materials/Textures/Loaders/index";
  54002. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54003. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54004. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54005. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54006. export * from "babylonjs/Materials/Textures/rawTexture";
  54007. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54008. export * from "babylonjs/Materials/Textures/refractionTexture";
  54009. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54010. export * from "babylonjs/Materials/Textures/texture";
  54011. export * from "babylonjs/Materials/Textures/videoTexture";
  54012. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54013. }
  54014. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54015. /**
  54016. * Enum used to define the target of a block
  54017. */
  54018. export enum NodeMaterialBlockTargets {
  54019. /** Vertex shader */
  54020. Vertex = 1,
  54021. /** Fragment shader */
  54022. Fragment = 2,
  54023. /** Neutral */
  54024. Neutral = 4,
  54025. /** Vertex and Fragment */
  54026. VertexAndFragment = 3
  54027. }
  54028. }
  54029. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54030. /**
  54031. * Defines the kind of connection point for node based material
  54032. */
  54033. export enum NodeMaterialBlockConnectionPointTypes {
  54034. /** Float */
  54035. Float = 1,
  54036. /** Int */
  54037. Int = 2,
  54038. /** Vector2 */
  54039. Vector2 = 4,
  54040. /** Vector3 */
  54041. Vector3 = 8,
  54042. /** Vector4 */
  54043. Vector4 = 16,
  54044. /** Color3 */
  54045. Color3 = 32,
  54046. /** Color4 */
  54047. Color4 = 64,
  54048. /** Matrix */
  54049. Matrix = 128,
  54050. /** Detect type based on connection */
  54051. AutoDetect = 1024,
  54052. /** Output type that will be defined by input type */
  54053. BasedOnInput = 2048,
  54054. /** Output type that will be defined by inverting input type (color <-> vector) */
  54055. InvertInput = 4096
  54056. }
  54057. }
  54058. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54060. /**
  54061. * Root class for all node material optimizers
  54062. */
  54063. export class NodeMaterialOptimizer {
  54064. /**
  54065. * Function used to optimize a NodeMaterial graph
  54066. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54067. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54068. */
  54069. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54070. }
  54071. }
  54072. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54076. import { Scene } from "babylonjs/scene";
  54077. /**
  54078. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54079. */
  54080. export class TransformBlock extends NodeMaterialBlock {
  54081. /**
  54082. * Defines the value to use to complement W value to transform it to a Vector4
  54083. */
  54084. complementW: number;
  54085. /**
  54086. * Defines the value to use to complement z value to transform it to a Vector4
  54087. */
  54088. complementZ: number;
  54089. /**
  54090. * Creates a new TransformBlock
  54091. * @param name defines the block name
  54092. */
  54093. constructor(name: string);
  54094. /**
  54095. * Gets the current class name
  54096. * @returns the class name
  54097. */
  54098. getClassName(): string;
  54099. /**
  54100. * Gets the vector input
  54101. */
  54102. readonly vector: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the output component
  54105. */
  54106. readonly output: NodeMaterialConnectionPoint;
  54107. /**
  54108. * Gets the matrix transform input
  54109. */
  54110. readonly transform: NodeMaterialConnectionPoint;
  54111. protected _buildBlock(state: NodeMaterialBuildState): this;
  54112. serialize(): any;
  54113. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54114. }
  54115. }
  54116. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54120. /**
  54121. * Block used to output the vertex position
  54122. */
  54123. export class VertexOutputBlock extends NodeMaterialBlock {
  54124. /**
  54125. * Creates a new VertexOutputBlock
  54126. * @param name defines the block name
  54127. */
  54128. constructor(name: string);
  54129. /**
  54130. * Gets the current class name
  54131. * @returns the class name
  54132. */
  54133. getClassName(): string;
  54134. /**
  54135. * Gets the vector input component
  54136. */
  54137. readonly vector: NodeMaterialConnectionPoint;
  54138. protected _buildBlock(state: NodeMaterialBuildState): this;
  54139. }
  54140. }
  54141. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54145. /**
  54146. * Block used to output the final color
  54147. */
  54148. export class FragmentOutputBlock extends NodeMaterialBlock {
  54149. /**
  54150. * Create a new FragmentOutputBlock
  54151. * @param name defines the block name
  54152. */
  54153. constructor(name: string);
  54154. /**
  54155. * Gets the current class name
  54156. * @returns the class name
  54157. */
  54158. getClassName(): string;
  54159. /**
  54160. * Gets the rgba input component
  54161. */
  54162. readonly rgba: NodeMaterialConnectionPoint;
  54163. /**
  54164. * Gets the rgb input component
  54165. */
  54166. readonly rgb: NodeMaterialConnectionPoint;
  54167. /**
  54168. * Gets the a input component
  54169. */
  54170. readonly a: NodeMaterialConnectionPoint;
  54171. protected _buildBlock(state: NodeMaterialBuildState): this;
  54172. }
  54173. }
  54174. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54175. /**
  54176. * Enum used to define well known values e.g. values automatically provided by the system
  54177. */
  54178. export enum NodeMaterialWellKnownValues {
  54179. /** World */
  54180. World = 1,
  54181. /** View */
  54182. View = 2,
  54183. /** Projection */
  54184. Projection = 3,
  54185. /** ViewProjection */
  54186. ViewProjection = 4,
  54187. /** WorldView */
  54188. WorldView = 5,
  54189. /** WorldViewProjection */
  54190. WorldViewProjection = 6,
  54191. /** CameraPosition */
  54192. CameraPosition = 7,
  54193. /** Fog Color */
  54194. FogColor = 8
  54195. }
  54196. }
  54197. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54203. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54204. import { Effect } from "babylonjs/Materials/effect";
  54205. import { Mesh } from "babylonjs/Meshes/mesh";
  54206. import { Nullable } from "babylonjs/types";
  54207. import { Scene } from "babylonjs/scene";
  54208. /**
  54209. * Block used to read a reflection texture from a sampler
  54210. */
  54211. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54212. private _define3DName;
  54213. private _defineCubicName;
  54214. private _defineExplicitName;
  54215. private _defineProjectionName;
  54216. private _defineLocalCubicName;
  54217. private _defineSphericalName;
  54218. private _definePlanarName;
  54219. private _defineEquirectangularName;
  54220. private _defineMirroredEquirectangularFixedName;
  54221. private _defineEquirectangularFixedName;
  54222. private _defineSkyboxName;
  54223. private _cubeSamplerName;
  54224. private _2DSamplerName;
  54225. private _positionUVWName;
  54226. private _directionWName;
  54227. private _reflectionCoordsName;
  54228. private _reflection2DCoordsName;
  54229. private _reflectionColorName;
  54230. private _reflectionMatrixName;
  54231. /**
  54232. * Gets or sets the texture associated with the node
  54233. */
  54234. texture: Nullable<BaseTexture>;
  54235. /**
  54236. * Create a new TextureBlock
  54237. * @param name defines the block name
  54238. */
  54239. constructor(name: string);
  54240. /**
  54241. * Gets the current class name
  54242. * @returns the class name
  54243. */
  54244. getClassName(): string;
  54245. /**
  54246. * Gets the world position input component
  54247. */
  54248. readonly position: NodeMaterialConnectionPoint;
  54249. /**
  54250. * Gets the world position input component
  54251. */
  54252. readonly worldPosition: NodeMaterialConnectionPoint;
  54253. /**
  54254. * Gets the world normal input component
  54255. */
  54256. readonly worldNormal: NodeMaterialConnectionPoint;
  54257. /**
  54258. * Gets the world input component
  54259. */
  54260. readonly world: NodeMaterialConnectionPoint;
  54261. /**
  54262. * Gets the camera (or eye) position component
  54263. */
  54264. readonly cameraPosition: NodeMaterialConnectionPoint;
  54265. /**
  54266. * Gets the view input component
  54267. */
  54268. readonly view: NodeMaterialConnectionPoint;
  54269. /**
  54270. * Gets the rgb output component
  54271. */
  54272. readonly rgb: NodeMaterialConnectionPoint;
  54273. /**
  54274. * Gets the r output component
  54275. */
  54276. readonly r: NodeMaterialConnectionPoint;
  54277. /**
  54278. * Gets the g output component
  54279. */
  54280. readonly g: NodeMaterialConnectionPoint;
  54281. /**
  54282. * Gets the b output component
  54283. */
  54284. readonly b: NodeMaterialConnectionPoint;
  54285. autoConfigure(): void;
  54286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54287. isReady(): boolean;
  54288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54289. private _injectVertexCode;
  54290. private _writeOutput;
  54291. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54292. serialize(): any;
  54293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54294. }
  54295. }
  54296. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54298. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54299. import { Scene } from "babylonjs/scene";
  54300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54301. import { Matrix } from "babylonjs/Maths/math.vector";
  54302. import { Mesh } from "babylonjs/Meshes/mesh";
  54303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54304. import { Observable } from "babylonjs/Misc/observable";
  54305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54306. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54307. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54308. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54309. import { Nullable } from "babylonjs/types";
  54310. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54311. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54312. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54313. /**
  54314. * Interface used to configure the node material editor
  54315. */
  54316. export interface INodeMaterialEditorOptions {
  54317. /** Define the URl to load node editor script */
  54318. editorURL?: string;
  54319. }
  54320. /** @hidden */
  54321. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54322. /** BONES */
  54323. NUM_BONE_INFLUENCERS: number;
  54324. BonesPerMesh: number;
  54325. BONETEXTURE: boolean;
  54326. /** MORPH TARGETS */
  54327. MORPHTARGETS: boolean;
  54328. MORPHTARGETS_NORMAL: boolean;
  54329. MORPHTARGETS_TANGENT: boolean;
  54330. MORPHTARGETS_UV: boolean;
  54331. NUM_MORPH_INFLUENCERS: number;
  54332. /** IMAGE PROCESSING */
  54333. IMAGEPROCESSING: boolean;
  54334. VIGNETTE: boolean;
  54335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54336. VIGNETTEBLENDMODEOPAQUE: boolean;
  54337. TONEMAPPING: boolean;
  54338. TONEMAPPING_ACES: boolean;
  54339. CONTRAST: boolean;
  54340. EXPOSURE: boolean;
  54341. COLORCURVES: boolean;
  54342. COLORGRADING: boolean;
  54343. COLORGRADING3D: boolean;
  54344. SAMPLER3DGREENDEPTH: boolean;
  54345. SAMPLER3DBGRMAP: boolean;
  54346. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54347. constructor();
  54348. setValue(name: string, value: boolean): void;
  54349. }
  54350. /**
  54351. * Class used to configure NodeMaterial
  54352. */
  54353. export interface INodeMaterialOptions {
  54354. /**
  54355. * Defines if blocks should emit comments
  54356. */
  54357. emitComments: boolean;
  54358. }
  54359. /**
  54360. * Class used to create a node based material built by assembling shader blocks
  54361. */
  54362. export class NodeMaterial extends PushMaterial {
  54363. private static _BuildIdGenerator;
  54364. private _options;
  54365. private _vertexCompilationState;
  54366. private _fragmentCompilationState;
  54367. private _sharedData;
  54368. private _buildId;
  54369. private _buildWasSuccessful;
  54370. private _cachedWorldViewMatrix;
  54371. private _cachedWorldViewProjectionMatrix;
  54372. private _optimizers;
  54373. private _animationFrame;
  54374. /** Define the URl to load node editor script */
  54375. static EditorURL: string;
  54376. private BJSNODEMATERIALEDITOR;
  54377. /** Get the inspector from bundle or global */
  54378. private _getGlobalNodeMaterialEditor;
  54379. /**
  54380. * 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)
  54381. */
  54382. ignoreAlpha: boolean;
  54383. /**
  54384. * Defines the maximum number of lights that can be used in the material
  54385. */
  54386. maxSimultaneousLights: number;
  54387. /**
  54388. * Observable raised when the material is built
  54389. */
  54390. onBuildObservable: Observable<NodeMaterial>;
  54391. /**
  54392. * Gets or sets the root nodes of the material vertex shader
  54393. */
  54394. _vertexOutputNodes: NodeMaterialBlock[];
  54395. /**
  54396. * Gets or sets the root nodes of the material fragment (pixel) shader
  54397. */
  54398. _fragmentOutputNodes: NodeMaterialBlock[];
  54399. /** Gets or sets options to control the node material overall behavior */
  54400. options: INodeMaterialOptions;
  54401. /**
  54402. * Default configuration related to image processing available in the standard Material.
  54403. */
  54404. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54405. /**
  54406. * Gets the image processing configuration used either in this material.
  54407. */
  54408. /**
  54409. * Sets the Default image processing configuration used either in the this material.
  54410. *
  54411. * If sets to null, the scene one is in use.
  54412. */
  54413. imageProcessingConfiguration: ImageProcessingConfiguration;
  54414. /**
  54415. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54416. */
  54417. attachedBlocks: NodeMaterialBlock[];
  54418. /**
  54419. * Create a new node based material
  54420. * @param name defines the material name
  54421. * @param scene defines the hosting scene
  54422. * @param options defines creation option
  54423. */
  54424. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54425. /**
  54426. * Gets the current class name of the material e.g. "NodeMaterial"
  54427. * @returns the class name
  54428. */
  54429. getClassName(): string;
  54430. /**
  54431. * Keep track of the image processing observer to allow dispose and replace.
  54432. */
  54433. private _imageProcessingObserver;
  54434. /**
  54435. * Attaches a new image processing configuration to the Standard Material.
  54436. * @param configuration
  54437. */
  54438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54439. /**
  54440. * Get a block by its name
  54441. * @param name defines the name of the block to retrieve
  54442. * @returns the required block or null if not found
  54443. */
  54444. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54445. /**
  54446. * Gets the list of input blocks attached to this material
  54447. * @returns an array of InputBlocks
  54448. */
  54449. getInputBlocks(): InputBlock[];
  54450. /**
  54451. * Adds a new optimizer to the list of optimizers
  54452. * @param optimizer defines the optimizers to add
  54453. * @returns the current material
  54454. */
  54455. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54456. /**
  54457. * Remove an optimizer from the list of optimizers
  54458. * @param optimizer defines the optimizers to remove
  54459. * @returns the current material
  54460. */
  54461. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54462. /**
  54463. * Add a new block to the list of output nodes
  54464. * @param node defines the node to add
  54465. * @returns the current material
  54466. */
  54467. addOutputNode(node: NodeMaterialBlock): this;
  54468. /**
  54469. * Remove a block from the list of root nodes
  54470. * @param node defines the node to remove
  54471. * @returns the current material
  54472. */
  54473. removeOutputNode(node: NodeMaterialBlock): this;
  54474. private _addVertexOutputNode;
  54475. private _removeVertexOutputNode;
  54476. private _addFragmentOutputNode;
  54477. private _removeFragmentOutputNode;
  54478. /**
  54479. * Specifies if the material will require alpha blending
  54480. * @returns a boolean specifying if alpha blending is needed
  54481. */
  54482. needAlphaBlending(): boolean;
  54483. /**
  54484. * Specifies if this material should be rendered in alpha test mode
  54485. * @returns a boolean specifying if an alpha test is needed.
  54486. */
  54487. needAlphaTesting(): boolean;
  54488. private _initializeBlock;
  54489. private _resetDualBlocks;
  54490. /**
  54491. * Build the material and generates the inner effect
  54492. * @param verbose defines if the build should log activity
  54493. */
  54494. build(verbose?: boolean): void;
  54495. /**
  54496. * Runs an otpimization phase to try to improve the shader code
  54497. */
  54498. optimize(): void;
  54499. private _prepareDefinesForAttributes;
  54500. /**
  54501. * Get if the submesh is ready to be used and all its information available.
  54502. * Child classes can use it to update shaders
  54503. * @param mesh defines the mesh to check
  54504. * @param subMesh defines which submesh to check
  54505. * @param useInstances specifies that instances should be used
  54506. * @returns a boolean indicating that the submesh is ready or not
  54507. */
  54508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54509. /**
  54510. * Get a string representing the shaders built by the current node graph
  54511. */
  54512. readonly compiledShaders: string;
  54513. /**
  54514. * Binds the world matrix to the material
  54515. * @param world defines the world transformation matrix
  54516. */
  54517. bindOnlyWorldMatrix(world: Matrix): void;
  54518. /**
  54519. * Binds the submesh to this material by preparing the effect and shader to draw
  54520. * @param world defines the world transformation matrix
  54521. * @param mesh defines the mesh containing the submesh
  54522. * @param subMesh defines the submesh to bind the material to
  54523. */
  54524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54525. /**
  54526. * Gets the active textures from the material
  54527. * @returns an array of textures
  54528. */
  54529. getActiveTextures(): BaseTexture[];
  54530. /**
  54531. * Gets the list of texture blocks
  54532. * @returns an array of texture blocks
  54533. */
  54534. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54535. /**
  54536. * Specifies if the material uses a texture
  54537. * @param texture defines the texture to check against the material
  54538. * @returns a boolean specifying if the material uses the texture
  54539. */
  54540. hasTexture(texture: BaseTexture): boolean;
  54541. /**
  54542. * Disposes the material
  54543. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54544. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54545. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54546. */
  54547. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54548. /** Creates the node editor window. */
  54549. private _createNodeEditor;
  54550. /**
  54551. * Launch the node material editor
  54552. * @param config Define the configuration of the editor
  54553. * @return a promise fulfilled when the node editor is visible
  54554. */
  54555. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54556. /**
  54557. * Clear the current material
  54558. */
  54559. clear(): void;
  54560. /**
  54561. * Clear the current material and set it to a default state
  54562. */
  54563. setToDefault(): void;
  54564. /**
  54565. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54566. * @param url defines the url to load from
  54567. * @returns a promise that will fullfil when the material is fully loaded
  54568. */
  54569. loadAsync(url: string): Promise<unknown>;
  54570. private _gatherBlocks;
  54571. /**
  54572. * Generate a string containing the code declaration required to create an equivalent of this material
  54573. * @returns a string
  54574. */
  54575. generateCode(): string;
  54576. /**
  54577. * Serializes this material in a JSON representation
  54578. * @returns the serialized material object
  54579. */
  54580. serialize(): any;
  54581. private _restoreConnections;
  54582. /**
  54583. * Clear the current graph and load a new one from a serialization object
  54584. * @param source defines the JSON representation of the material
  54585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54586. */
  54587. loadFromSerialization(source: any, rootUrl?: string): void;
  54588. /**
  54589. * Creates a node material from parsed material data
  54590. * @param source defines the JSON representation of the material
  54591. * @param scene defines the hosting scene
  54592. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54593. * @returns a new node material
  54594. */
  54595. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54596. /**
  54597. * Creates a new node material set to default basic configuration
  54598. * @param name defines the name of the material
  54599. * @param scene defines the hosting scene
  54600. * @returns a new NodeMaterial
  54601. */
  54602. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54603. }
  54604. }
  54605. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54611. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54612. import { Effect } from "babylonjs/Materials/effect";
  54613. import { Mesh } from "babylonjs/Meshes/mesh";
  54614. import { Nullable } from "babylonjs/types";
  54615. import { Scene } from "babylonjs/scene";
  54616. /**
  54617. * Block used to read a texture from a sampler
  54618. */
  54619. export class TextureBlock extends NodeMaterialBlock {
  54620. private _defineName;
  54621. private _samplerName;
  54622. private _transformedUVName;
  54623. private _textureTransformName;
  54624. private _textureInfoName;
  54625. private _mainUVName;
  54626. private _mainUVDefineName;
  54627. /**
  54628. * Gets or sets the texture associated with the node
  54629. */
  54630. texture: Nullable<BaseTexture>;
  54631. /**
  54632. * Create a new TextureBlock
  54633. * @param name defines the block name
  54634. */
  54635. constructor(name: string);
  54636. /**
  54637. * Gets the current class name
  54638. * @returns the class name
  54639. */
  54640. getClassName(): string;
  54641. /**
  54642. * Gets the uv input component
  54643. */
  54644. readonly uv: NodeMaterialConnectionPoint;
  54645. /**
  54646. * Gets the rgba output component
  54647. */
  54648. readonly rgba: NodeMaterialConnectionPoint;
  54649. /**
  54650. * Gets the rgb output component
  54651. */
  54652. readonly rgb: NodeMaterialConnectionPoint;
  54653. /**
  54654. * Gets the r output component
  54655. */
  54656. readonly r: NodeMaterialConnectionPoint;
  54657. /**
  54658. * Gets the g output component
  54659. */
  54660. readonly g: NodeMaterialConnectionPoint;
  54661. /**
  54662. * Gets the b output component
  54663. */
  54664. readonly b: NodeMaterialConnectionPoint;
  54665. /**
  54666. * Gets the a output component
  54667. */
  54668. readonly a: NodeMaterialConnectionPoint;
  54669. autoConfigure(): void;
  54670. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54672. isReady(): boolean;
  54673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54674. private _injectVertexCode;
  54675. private _writeOutput;
  54676. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54677. serialize(): any;
  54678. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54679. }
  54680. }
  54681. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54684. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54685. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54686. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54687. /**
  54688. * Class used to store shared data between 2 NodeMaterialBuildState
  54689. */
  54690. export class NodeMaterialBuildStateSharedData {
  54691. /**
  54692. * Gets the list of emitted varyings
  54693. */
  54694. temps: string[];
  54695. /**
  54696. * Gets the list of emitted varyings
  54697. */
  54698. varyings: string[];
  54699. /**
  54700. * Gets the varying declaration string
  54701. */
  54702. varyingDeclaration: string;
  54703. /**
  54704. * Input blocks
  54705. */
  54706. inputBlocks: InputBlock[];
  54707. /**
  54708. * Input blocks
  54709. */
  54710. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54711. /**
  54712. * Bindable blocks (Blocks that need to set data to the effect)
  54713. */
  54714. bindableBlocks: NodeMaterialBlock[];
  54715. /**
  54716. * List of blocks that can provide a compilation fallback
  54717. */
  54718. blocksWithFallbacks: NodeMaterialBlock[];
  54719. /**
  54720. * List of blocks that can provide a define update
  54721. */
  54722. blocksWithDefines: NodeMaterialBlock[];
  54723. /**
  54724. * List of blocks that can provide a repeatable content
  54725. */
  54726. repeatableContentBlocks: NodeMaterialBlock[];
  54727. /**
  54728. * List of blocks that can provide a dynamic list of uniforms
  54729. */
  54730. dynamicUniformBlocks: NodeMaterialBlock[];
  54731. /**
  54732. * List of blocks that can block the isReady function for the material
  54733. */
  54734. blockingBlocks: NodeMaterialBlock[];
  54735. /**
  54736. * Gets the list of animated inputs
  54737. */
  54738. animatedInputs: InputBlock[];
  54739. /**
  54740. * Build Id used to avoid multiple recompilations
  54741. */
  54742. buildId: number;
  54743. /** List of emitted variables */
  54744. variableNames: {
  54745. [key: string]: number;
  54746. };
  54747. /** List of emitted defines */
  54748. defineNames: {
  54749. [key: string]: number;
  54750. };
  54751. /** Should emit comments? */
  54752. emitComments: boolean;
  54753. /** Emit build activity */
  54754. verbose: boolean;
  54755. /**
  54756. * Gets the compilation hints emitted at compilation time
  54757. */
  54758. hints: {
  54759. needWorldViewMatrix: boolean;
  54760. needWorldViewProjectionMatrix: boolean;
  54761. needAlphaBlending: boolean;
  54762. needAlphaTesting: boolean;
  54763. };
  54764. /**
  54765. * List of compilation checks
  54766. */
  54767. checks: {
  54768. emitVertex: boolean;
  54769. emitFragment: boolean;
  54770. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54771. };
  54772. /** Creates a new shared data */
  54773. constructor();
  54774. /**
  54775. * Emits console errors and exceptions if there is a failing check
  54776. */
  54777. emitErrors(): void;
  54778. }
  54779. }
  54780. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54781. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54782. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54783. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54784. /**
  54785. * Class used to store node based material build state
  54786. */
  54787. export class NodeMaterialBuildState {
  54788. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54789. supportUniformBuffers: boolean;
  54790. /**
  54791. * Gets the list of emitted attributes
  54792. */
  54793. attributes: string[];
  54794. /**
  54795. * Gets the list of emitted uniforms
  54796. */
  54797. uniforms: string[];
  54798. /**
  54799. * Gets the list of emitted uniform buffers
  54800. */
  54801. uniformBuffers: string[];
  54802. /**
  54803. * Gets the list of emitted samplers
  54804. */
  54805. samplers: string[];
  54806. /**
  54807. * Gets the list of emitted functions
  54808. */
  54809. functions: {
  54810. [key: string]: string;
  54811. };
  54812. /**
  54813. * Gets the target of the compilation state
  54814. */
  54815. target: NodeMaterialBlockTargets;
  54816. /**
  54817. * Gets the list of emitted counters
  54818. */
  54819. counters: {
  54820. [key: string]: number;
  54821. };
  54822. /**
  54823. * Shared data between multiple NodeMaterialBuildState instances
  54824. */
  54825. sharedData: NodeMaterialBuildStateSharedData;
  54826. /** @hidden */
  54827. _vertexState: NodeMaterialBuildState;
  54828. /** @hidden */
  54829. _attributeDeclaration: string;
  54830. /** @hidden */
  54831. _uniformDeclaration: string;
  54832. /** @hidden */
  54833. _samplerDeclaration: string;
  54834. /** @hidden */
  54835. _varyingTransfer: string;
  54836. private _repeatableContentAnchorIndex;
  54837. /** @hidden */
  54838. _builtCompilationString: string;
  54839. /**
  54840. * Gets the emitted compilation strings
  54841. */
  54842. compilationString: string;
  54843. /**
  54844. * Finalize the compilation strings
  54845. * @param state defines the current compilation state
  54846. */
  54847. finalize(state: NodeMaterialBuildState): void;
  54848. /** @hidden */
  54849. readonly _repeatableContentAnchor: string;
  54850. /** @hidden */
  54851. _getFreeVariableName(prefix: string): string;
  54852. /** @hidden */
  54853. _getFreeDefineName(prefix: string): string;
  54854. /** @hidden */
  54855. _excludeVariableName(name: string): void;
  54856. /** @hidden */
  54857. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54858. /** @hidden */
  54859. _emitFunction(name: string, code: string, comments: string): void;
  54860. /** @hidden */
  54861. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54862. replaceStrings?: {
  54863. search: RegExp;
  54864. replace: string;
  54865. }[];
  54866. repeatKey?: string;
  54867. }): string;
  54868. /** @hidden */
  54869. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54870. repeatKey?: string;
  54871. removeAttributes?: boolean;
  54872. removeUniforms?: boolean;
  54873. removeVaryings?: boolean;
  54874. removeIfDef?: boolean;
  54875. replaceStrings?: {
  54876. search: RegExp;
  54877. replace: string;
  54878. }[];
  54879. }, storeKey?: string): void;
  54880. /** @hidden */
  54881. _registerTempVariable(name: string): boolean;
  54882. /** @hidden */
  54883. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54884. /** @hidden */
  54885. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54886. }
  54887. }
  54888. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54889. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54891. import { Nullable } from "babylonjs/types";
  54892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54893. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54894. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54896. import { Mesh } from "babylonjs/Meshes/mesh";
  54897. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54898. import { Scene } from "babylonjs/scene";
  54899. /**
  54900. * Defines a block that can be used inside a node based material
  54901. */
  54902. export class NodeMaterialBlock {
  54903. private _buildId;
  54904. private _buildTarget;
  54905. private _target;
  54906. private _isFinalMerger;
  54907. private _isInput;
  54908. protected _codeVariableName: string;
  54909. /** @hidden */
  54910. _inputs: NodeMaterialConnectionPoint[];
  54911. /** @hidden */
  54912. _outputs: NodeMaterialConnectionPoint[];
  54913. /**
  54914. * Gets or sets the name of the block
  54915. */
  54916. name: string;
  54917. /**
  54918. * Gets or sets the unique id of the node
  54919. */
  54920. uniqueId: number;
  54921. /**
  54922. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54923. */
  54924. readonly isFinalMerger: boolean;
  54925. /**
  54926. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54927. */
  54928. readonly isInput: boolean;
  54929. /**
  54930. * Gets or sets the build Id
  54931. */
  54932. buildId: number;
  54933. /**
  54934. * Gets or sets the target of the block
  54935. */
  54936. target: NodeMaterialBlockTargets;
  54937. /**
  54938. * Gets the list of input points
  54939. */
  54940. readonly inputs: NodeMaterialConnectionPoint[];
  54941. /** Gets the list of output points */
  54942. readonly outputs: NodeMaterialConnectionPoint[];
  54943. /**
  54944. * Find an input by its name
  54945. * @param name defines the name of the input to look for
  54946. * @returns the input or null if not found
  54947. */
  54948. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54949. /**
  54950. * Find an output by its name
  54951. * @param name defines the name of the outputto look for
  54952. * @returns the output or null if not found
  54953. */
  54954. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54955. /**
  54956. * Creates a new NodeMaterialBlock
  54957. * @param name defines the block name
  54958. * @param target defines the target of that block (Vertex by default)
  54959. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54960. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54961. */
  54962. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54963. /**
  54964. * Initialize the block and prepare the context for build
  54965. * @param state defines the state that will be used for the build
  54966. */
  54967. initialize(state: NodeMaterialBuildState): void;
  54968. /**
  54969. * Bind data to effect. Will only be called for blocks with isBindable === true
  54970. * @param effect defines the effect to bind data to
  54971. * @param nodeMaterial defines the hosting NodeMaterial
  54972. * @param mesh defines the mesh that will be rendered
  54973. */
  54974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54975. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54976. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54977. protected _writeFloat(value: number): string;
  54978. /**
  54979. * Gets the current class name e.g. "NodeMaterialBlock"
  54980. * @returns the class name
  54981. */
  54982. getClassName(): string;
  54983. /**
  54984. * Register a new input. Must be called inside a block constructor
  54985. * @param name defines the connection point name
  54986. * @param type defines the connection point type
  54987. * @param isOptional defines a boolean indicating that this input can be omitted
  54988. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54989. * @returns the current block
  54990. */
  54991. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54992. /**
  54993. * Register a new output. Must be called inside a block constructor
  54994. * @param name defines the connection point name
  54995. * @param type defines the connection point type
  54996. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54997. * @returns the current block
  54998. */
  54999. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55000. /**
  55001. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55002. * @param forOutput defines an optional connection point to check compatibility with
  55003. * @returns the first available input or null
  55004. */
  55005. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55006. /**
  55007. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55008. * @param forBlock defines an optional block to check compatibility with
  55009. * @returns the first available input or null
  55010. */
  55011. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55012. /**
  55013. * Gets the sibling of the given output
  55014. * @param current defines the current output
  55015. * @returns the next output in the list or null
  55016. */
  55017. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55018. /**
  55019. * Connect current block with another block
  55020. * @param other defines the block to connect with
  55021. * @param options define the various options to help pick the right connections
  55022. * @returns the current block
  55023. */
  55024. connectTo(other: NodeMaterialBlock, options?: {
  55025. input?: string;
  55026. output?: string;
  55027. outputSwizzle?: string;
  55028. }): this | undefined;
  55029. protected _buildBlock(state: NodeMaterialBuildState): void;
  55030. /**
  55031. * Add uniforms, samplers and uniform buffers at compilation time
  55032. * @param state defines the state to update
  55033. * @param nodeMaterial defines the node material requesting the update
  55034. * @param defines defines the material defines to update
  55035. */
  55036. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55037. /**
  55038. * Add potential fallbacks if shader compilation fails
  55039. * @param mesh defines the mesh to be rendered
  55040. * @param fallbacks defines the current prioritized list of fallbacks
  55041. */
  55042. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55043. /**
  55044. * Update defines for shader compilation
  55045. * @param mesh defines the mesh to be rendered
  55046. * @param nodeMaterial defines the node material requesting the update
  55047. * @param defines defines the material defines to update
  55048. * @param useInstances specifies that instances should be used
  55049. */
  55050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55051. /**
  55052. * Initialize defines for shader compilation
  55053. * @param mesh defines the mesh to be rendered
  55054. * @param nodeMaterial defines the node material requesting the update
  55055. * @param defines defines the material defines to be prepared
  55056. * @param useInstances specifies that instances should be used
  55057. */
  55058. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55059. /**
  55060. * Lets the block try to connect some inputs automatically
  55061. * @param material defines the hosting NodeMaterial
  55062. */
  55063. autoConfigure(material: NodeMaterial): void;
  55064. /**
  55065. * Function called when a block is declared as repeatable content generator
  55066. * @param vertexShaderState defines the current compilation state for the vertex shader
  55067. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55068. * @param mesh defines the mesh to be rendered
  55069. * @param defines defines the material defines to update
  55070. */
  55071. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55072. /**
  55073. * Checks if the block is ready
  55074. * @param mesh defines the mesh to be rendered
  55075. * @param nodeMaterial defines the node material requesting the update
  55076. * @param defines defines the material defines to update
  55077. * @param useInstances specifies that instances should be used
  55078. * @returns true if the block is ready
  55079. */
  55080. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55081. private _processBuild;
  55082. /**
  55083. * Compile the current node and generate the shader code
  55084. * @param state defines the current compilation state (uniforms, samplers, current string)
  55085. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  55086. * @returns true if already built
  55087. */
  55088. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  55089. protected _inputRename(name: string): string;
  55090. protected _outputRename(name: string): string;
  55091. protected _dumpPropertiesCode(): string;
  55092. /** @hidden */
  55093. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55094. /**
  55095. * Clone the current block to a new identical block
  55096. * @param scene defines the hosting scene
  55097. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55098. * @returns a copy of the current block
  55099. */
  55100. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55101. /**
  55102. * Serializes this block in a JSON representation
  55103. * @returns the serialized block object
  55104. */
  55105. serialize(): any;
  55106. /** @hidden */
  55107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55108. }
  55109. }
  55110. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55111. /**
  55112. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55113. */
  55114. export enum NodeMaterialBlockConnectionPointMode {
  55115. /** Value is an uniform */
  55116. Uniform = 0,
  55117. /** Value is a mesh attribute */
  55118. Attribute = 1,
  55119. /** Value is a varying between vertex and fragment shaders */
  55120. Varying = 2,
  55121. /** Mode is undefined */
  55122. Undefined = 3
  55123. }
  55124. }
  55125. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55126. /**
  55127. * Enum defining the type of animations supported by InputBlock
  55128. */
  55129. export enum AnimatedInputBlockTypes {
  55130. /** No animation */
  55131. None = 0,
  55132. /** Time based animation. Will only work for floats */
  55133. Time = 1
  55134. }
  55135. }
  55136. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55138. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55139. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55140. import { Nullable } from "babylonjs/types";
  55141. import { Effect } from "babylonjs/Materials/effect";
  55142. import { Matrix } from "babylonjs/Maths/math.vector";
  55143. import { Scene } from "babylonjs/scene";
  55144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55146. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55147. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55148. /**
  55149. * Block used to expose an input value
  55150. */
  55151. export class InputBlock extends NodeMaterialBlock {
  55152. private _mode;
  55153. private _associatedVariableName;
  55154. private _storedValue;
  55155. private _valueCallback;
  55156. private _type;
  55157. private _animationType;
  55158. /** @hidden */
  55159. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55160. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55161. visibleInInspector: boolean;
  55162. /**
  55163. * Gets or sets the connection point type (default is float)
  55164. */
  55165. readonly type: NodeMaterialBlockConnectionPointTypes;
  55166. /**
  55167. * Creates a new InputBlock
  55168. * @param name defines the block name
  55169. * @param target defines the target of that block (Vertex by default)
  55170. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55171. */
  55172. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55173. /**
  55174. * Gets the output component
  55175. */
  55176. readonly output: NodeMaterialConnectionPoint;
  55177. /**
  55178. * Set the source of this connection point to a vertex attribute
  55179. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55180. * @returns the current connection point
  55181. */
  55182. setAsAttribute(attributeName?: string): InputBlock;
  55183. /**
  55184. * Set the source of this connection point to a well known value
  55185. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55186. * @returns the current connection point
  55187. */
  55188. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55189. /**
  55190. * Gets or sets the value of that point.
  55191. * Please note that this value will be ignored if valueCallback is defined
  55192. */
  55193. value: any;
  55194. /**
  55195. * Gets or sets a callback used to get the value of that point.
  55196. * Please note that setting this value will force the connection point to ignore the value property
  55197. */
  55198. valueCallback: () => any;
  55199. /**
  55200. * Gets or sets the associated variable name in the shader
  55201. */
  55202. associatedVariableName: string;
  55203. /** Gets or sets the type of animation applied to the input */
  55204. animationType: AnimatedInputBlockTypes;
  55205. /**
  55206. * Gets a boolean indicating that this connection point not defined yet
  55207. */
  55208. readonly isUndefined: boolean;
  55209. /**
  55210. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55211. * In this case the connection point name must be the name of the uniform to use.
  55212. * Can only be set on inputs
  55213. */
  55214. isUniform: boolean;
  55215. /**
  55216. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55217. * In this case the connection point name must be the name of the attribute to use
  55218. * Can only be set on inputs
  55219. */
  55220. isAttribute: boolean;
  55221. /**
  55222. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55223. * Can only be set on exit points
  55224. */
  55225. isVarying: boolean;
  55226. /**
  55227. * Gets a boolean indicating that the current connection point is a well known value
  55228. */
  55229. readonly isWellKnownValue: boolean;
  55230. /**
  55231. * Gets or sets the current well known value or null if not defined as well know value
  55232. */
  55233. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55234. /**
  55235. * Gets the current class name
  55236. * @returns the class name
  55237. */
  55238. getClassName(): string;
  55239. /**
  55240. * Animate the input if animationType !== None
  55241. * @param scene defines the rendering scene
  55242. */
  55243. animate(scene: Scene): void;
  55244. private _emitDefine;
  55245. /**
  55246. * Set the input block to its default value (based on its type)
  55247. */
  55248. setDefaultValue(): void;
  55249. protected _dumpPropertiesCode(): string;
  55250. private _emit;
  55251. /** @hidden */
  55252. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55253. /** @hidden */
  55254. _transmit(effect: Effect, scene: Scene): void;
  55255. protected _buildBlock(state: NodeMaterialBuildState): void;
  55256. serialize(): any;
  55257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55258. }
  55259. }
  55260. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55261. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55262. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55263. import { Nullable } from "babylonjs/types";
  55264. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55266. /**
  55267. * Defines a connection point for a block
  55268. */
  55269. export class NodeMaterialConnectionPoint {
  55270. /** @hidden */
  55271. _ownerBlock: NodeMaterialBlock;
  55272. /** @hidden */
  55273. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55274. private _endpoints;
  55275. private _associatedVariableName;
  55276. /** @hidden */
  55277. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55278. private _type;
  55279. /** @hidden */
  55280. _enforceAssociatedVariableName: boolean;
  55281. /**
  55282. * Gets or sets the additional types supported byt this connection point
  55283. */
  55284. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55285. /**
  55286. * Gets or sets the associated variable name in the shader
  55287. */
  55288. associatedVariableName: string;
  55289. /**
  55290. * Gets or sets the connection point type (default is float)
  55291. */
  55292. type: NodeMaterialBlockConnectionPointTypes;
  55293. /**
  55294. * Gets or sets the connection point name
  55295. */
  55296. name: string;
  55297. /**
  55298. * Gets or sets a boolean indicating that this connection point can be omitted
  55299. */
  55300. isOptional: boolean;
  55301. /**
  55302. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55303. */
  55304. define: string;
  55305. /** Gets or sets the target of that connection point */
  55306. target: NodeMaterialBlockTargets;
  55307. /**
  55308. * Gets a boolean indicating that the current point is connected
  55309. */
  55310. readonly isConnected: boolean;
  55311. /**
  55312. * Gets a boolean indicating that the current point is connected to an input block
  55313. */
  55314. readonly isConnectedToInputBlock: boolean;
  55315. /**
  55316. * Gets a the connected input block (if any)
  55317. */
  55318. readonly connectInputBlock: Nullable<InputBlock>;
  55319. /** Get the other side of the connection (if any) */
  55320. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55321. /** Get the block that owns this connection point */
  55322. readonly ownerBlock: NodeMaterialBlock;
  55323. /** Get the block connected on the other side of this connection (if any) */
  55324. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55325. /** Get the block connected on the endpoints of this connection (if any) */
  55326. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55327. /** Gets the list of connected endpoints */
  55328. readonly endpoints: NodeMaterialConnectionPoint[];
  55329. /** Gets a boolean indicating if that output point is connected to at least one input */
  55330. readonly hasEndpoints: boolean;
  55331. /**
  55332. * Creates a new connection point
  55333. * @param name defines the connection point name
  55334. * @param ownerBlock defines the block hosting this connection point
  55335. */
  55336. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55337. /**
  55338. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55339. * @returns the class name
  55340. */
  55341. getClassName(): string;
  55342. /**
  55343. * Gets an boolean indicating if the current point can be connected to another point
  55344. * @param connectionPoint defines the other connection point
  55345. * @returns true if the connection is possible
  55346. */
  55347. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55348. /**
  55349. * Connect this point to another connection point
  55350. * @param connectionPoint defines the other connection point
  55351. * @returns the current connection point
  55352. */
  55353. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55354. /**
  55355. * Disconnect this point from one of his endpoint
  55356. * @param endpoint defines the other connection point
  55357. * @returns the current connection point
  55358. */
  55359. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55360. /**
  55361. * Serializes this point in a JSON representation
  55362. * @returns the serialized point object
  55363. */
  55364. serialize(): any;
  55365. }
  55366. }
  55367. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55371. import { Mesh } from "babylonjs/Meshes/mesh";
  55372. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55374. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55375. /**
  55376. * Block used to add support for vertex skinning (bones)
  55377. */
  55378. export class BonesBlock extends NodeMaterialBlock {
  55379. /**
  55380. * Creates a new BonesBlock
  55381. * @param name defines the block name
  55382. */
  55383. constructor(name: string);
  55384. /**
  55385. * Initialize the block and prepare the context for build
  55386. * @param state defines the state that will be used for the build
  55387. */
  55388. initialize(state: NodeMaterialBuildState): void;
  55389. /**
  55390. * Gets the current class name
  55391. * @returns the class name
  55392. */
  55393. getClassName(): string;
  55394. /**
  55395. * Gets the matrix indices input component
  55396. */
  55397. readonly matricesIndices: NodeMaterialConnectionPoint;
  55398. /**
  55399. * Gets the matrix weights input component
  55400. */
  55401. readonly matricesWeights: NodeMaterialConnectionPoint;
  55402. /**
  55403. * Gets the extra matrix indices input component
  55404. */
  55405. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55406. /**
  55407. * Gets the extra matrix weights input component
  55408. */
  55409. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55410. /**
  55411. * Gets the world input component
  55412. */
  55413. readonly world: NodeMaterialConnectionPoint;
  55414. /**
  55415. * Gets the output component
  55416. */
  55417. readonly output: NodeMaterialConnectionPoint;
  55418. autoConfigure(): void;
  55419. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55422. protected _buildBlock(state: NodeMaterialBuildState): this;
  55423. }
  55424. }
  55425. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55430. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55431. /**
  55432. * Block used to add support for instances
  55433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55434. */
  55435. export class InstancesBlock extends NodeMaterialBlock {
  55436. /**
  55437. * Creates a new InstancesBlock
  55438. * @param name defines the block name
  55439. */
  55440. constructor(name: string);
  55441. /**
  55442. * Gets the current class name
  55443. * @returns the class name
  55444. */
  55445. getClassName(): string;
  55446. /**
  55447. * Gets the first world row input component
  55448. */
  55449. readonly world0: NodeMaterialConnectionPoint;
  55450. /**
  55451. * Gets the second world row input component
  55452. */
  55453. readonly world1: NodeMaterialConnectionPoint;
  55454. /**
  55455. * Gets the third world row input component
  55456. */
  55457. readonly world2: NodeMaterialConnectionPoint;
  55458. /**
  55459. * Gets the forth world row input component
  55460. */
  55461. readonly world3: NodeMaterialConnectionPoint;
  55462. /**
  55463. * Gets the world input component
  55464. */
  55465. readonly world: NodeMaterialConnectionPoint;
  55466. /**
  55467. * Gets the output component
  55468. */
  55469. readonly output: NodeMaterialConnectionPoint;
  55470. autoConfigure(): void;
  55471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55472. protected _buildBlock(state: NodeMaterialBuildState): this;
  55473. }
  55474. }
  55475. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55480. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55481. import { Effect } from "babylonjs/Materials/effect";
  55482. import { Mesh } from "babylonjs/Meshes/mesh";
  55483. /**
  55484. * Block used to add morph targets support to vertex shader
  55485. */
  55486. export class MorphTargetsBlock extends NodeMaterialBlock {
  55487. private _repeatableContentAnchor;
  55488. private _repeatebleContentGenerated;
  55489. /**
  55490. * Create a new MorphTargetsBlock
  55491. * @param name defines the block name
  55492. */
  55493. constructor(name: string);
  55494. /**
  55495. * Gets the current class name
  55496. * @returns the class name
  55497. */
  55498. getClassName(): string;
  55499. /**
  55500. * Gets the position input component
  55501. */
  55502. readonly position: NodeMaterialConnectionPoint;
  55503. /**
  55504. * Gets the normal input component
  55505. */
  55506. readonly normal: NodeMaterialConnectionPoint;
  55507. /**
  55508. * Gets the tangent input component
  55509. */
  55510. readonly tangent: NodeMaterialConnectionPoint;
  55511. /**
  55512. * Gets the tangent input component
  55513. */
  55514. readonly uv: NodeMaterialConnectionPoint;
  55515. /**
  55516. * Gets the position output component
  55517. */
  55518. readonly positionOutput: NodeMaterialConnectionPoint;
  55519. /**
  55520. * Gets the normal output component
  55521. */
  55522. readonly normalOutput: NodeMaterialConnectionPoint;
  55523. /**
  55524. * Gets the tangent output component
  55525. */
  55526. readonly tangentOutput: NodeMaterialConnectionPoint;
  55527. /**
  55528. * Gets the tangent output component
  55529. */
  55530. readonly uvOutput: NodeMaterialConnectionPoint;
  55531. initialize(state: NodeMaterialBuildState): void;
  55532. autoConfigure(): void;
  55533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55535. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55536. protected _buildBlock(state: NodeMaterialBuildState): this;
  55537. }
  55538. }
  55539. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55540. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55541. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55542. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55543. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55544. }
  55545. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55549. /**
  55550. * Block used to add an alpha test in the fragment shader
  55551. */
  55552. export class AlphaTestBlock extends NodeMaterialBlock {
  55553. /**
  55554. * Gets or sets the alpha value where alpha testing happens
  55555. */
  55556. alphaCutOff: number;
  55557. /**
  55558. * Create a new AlphaTestBlock
  55559. * @param name defines the block name
  55560. */
  55561. constructor(name: string);
  55562. /**
  55563. * Gets the current class name
  55564. * @returns the class name
  55565. */
  55566. getClassName(): string;
  55567. /**
  55568. * Gets the color input component
  55569. */
  55570. readonly color: NodeMaterialConnectionPoint;
  55571. /**
  55572. * Gets the alpha input component
  55573. */
  55574. readonly alpha: NodeMaterialConnectionPoint;
  55575. protected _buildBlock(state: NodeMaterialBuildState): this;
  55576. }
  55577. }
  55578. declare module "babylonjs/Materials/Node/Blocks/Fragment/fresnelBlock" {
  55579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55582. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55583. /**
  55584. * Block used to compute fresnel value
  55585. */
  55586. export class FresnelBlock extends NodeMaterialBlock {
  55587. /**
  55588. * Create a new FresnelBlock
  55589. * @param name defines the block name
  55590. */
  55591. constructor(name: string);
  55592. /**
  55593. * Gets the current class name
  55594. * @returns the class name
  55595. */
  55596. getClassName(): string;
  55597. /**
  55598. * Gets the world position input component
  55599. */
  55600. readonly worldPosition: NodeMaterialConnectionPoint;
  55601. /**
  55602. * Gets the world normal input component
  55603. */
  55604. readonly worldNormal: NodeMaterialConnectionPoint;
  55605. /**
  55606. * Gets the camera (or eye) position component
  55607. */
  55608. readonly cameraPosition: NodeMaterialConnectionPoint;
  55609. /**
  55610. * Gets the bias input component
  55611. */
  55612. readonly bias: NodeMaterialConnectionPoint;
  55613. /**
  55614. * Gets the camera (or eye) position component
  55615. */
  55616. readonly power: NodeMaterialConnectionPoint;
  55617. /**
  55618. * Gets the fresnel output component
  55619. */
  55620. readonly fresnel: NodeMaterialConnectionPoint;
  55621. autoConfigure(material: NodeMaterial): void;
  55622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55623. }
  55624. }
  55625. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55630. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55631. import { Effect } from "babylonjs/Materials/effect";
  55632. import { Mesh } from "babylonjs/Meshes/mesh";
  55633. /**
  55634. * Block used to add image processing support to fragment shader
  55635. */
  55636. export class ImageProcessingBlock extends NodeMaterialBlock {
  55637. /**
  55638. * Create a new ImageProcessingBlock
  55639. * @param name defines the block name
  55640. */
  55641. constructor(name: string);
  55642. /**
  55643. * Gets the current class name
  55644. * @returns the class name
  55645. */
  55646. getClassName(): string;
  55647. /**
  55648. * Gets the color input component
  55649. */
  55650. readonly color: NodeMaterialConnectionPoint;
  55651. /**
  55652. * Gets the output component
  55653. */
  55654. readonly output: NodeMaterialConnectionPoint;
  55655. /**
  55656. * Initialize the block and prepare the context for build
  55657. * @param state defines the state that will be used for the build
  55658. */
  55659. initialize(state: NodeMaterialBuildState): void;
  55660. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55663. protected _buildBlock(state: NodeMaterialBuildState): this;
  55664. }
  55665. }
  55666. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55667. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55668. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55669. export * from "babylonjs/Materials/Node/Blocks/Fragment/fresnelBlock";
  55670. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55671. }
  55672. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55675. import { Mesh } from "babylonjs/Meshes/mesh";
  55676. import { Effect } from "babylonjs/Materials/effect";
  55677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55679. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55680. /**
  55681. * Block used to add support for scene fog
  55682. */
  55683. export class FogBlock extends NodeMaterialBlock {
  55684. private _fogDistanceName;
  55685. private _fogParameters;
  55686. /**
  55687. * Create a new FogBlock
  55688. * @param name defines the block name
  55689. */
  55690. constructor(name: string);
  55691. /**
  55692. * Gets the current class name
  55693. * @returns the class name
  55694. */
  55695. getClassName(): string;
  55696. /**
  55697. * Gets the world position input component
  55698. */
  55699. readonly worldPosition: NodeMaterialConnectionPoint;
  55700. /**
  55701. * Gets the view input component
  55702. */
  55703. readonly view: NodeMaterialConnectionPoint;
  55704. /**
  55705. * Gets the color input component
  55706. */
  55707. readonly color: NodeMaterialConnectionPoint;
  55708. /**
  55709. * Gets the fog color input component
  55710. */
  55711. readonly fogColor: NodeMaterialConnectionPoint;
  55712. /**
  55713. * Gets the output component
  55714. */
  55715. readonly output: NodeMaterialConnectionPoint;
  55716. autoConfigure(): void;
  55717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55719. protected _buildBlock(state: NodeMaterialBuildState): this;
  55720. }
  55721. }
  55722. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55727. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55728. import { Effect } from "babylonjs/Materials/effect";
  55729. import { Mesh } from "babylonjs/Meshes/mesh";
  55730. import { Light } from "babylonjs/Lights/light";
  55731. import { Nullable } from "babylonjs/types";
  55732. import { Scene } from "babylonjs/scene";
  55733. /**
  55734. * Block used to add light in the fragment shader
  55735. */
  55736. export class LightBlock extends NodeMaterialBlock {
  55737. private _lightId;
  55738. /**
  55739. * Gets or sets the light associated with this block
  55740. */
  55741. light: Nullable<Light>;
  55742. /**
  55743. * Create a new LightBlock
  55744. * @param name defines the block name
  55745. */
  55746. constructor(name: string);
  55747. /**
  55748. * Gets the current class name
  55749. * @returns the class name
  55750. */
  55751. getClassName(): string;
  55752. /**
  55753. * Gets the world position input component
  55754. */
  55755. readonly worldPosition: NodeMaterialConnectionPoint;
  55756. /**
  55757. * Gets the world normal input component
  55758. */
  55759. readonly worldNormal: NodeMaterialConnectionPoint;
  55760. /**
  55761. * Gets the camera (or eye) position component
  55762. */
  55763. readonly cameraPosition: NodeMaterialConnectionPoint;
  55764. /**
  55765. * Gets the diffuse output component
  55766. */
  55767. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55768. /**
  55769. * Gets the specular output component
  55770. */
  55771. readonly specularOutput: NodeMaterialConnectionPoint;
  55772. autoConfigure(): void;
  55773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55774. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55775. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55776. private _injectVertexCode;
  55777. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55778. serialize(): any;
  55779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55780. }
  55781. }
  55782. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55783. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55784. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55785. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55786. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55787. }
  55788. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55789. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55790. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55791. }
  55792. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55796. /**
  55797. * Block used to multiply 2 values
  55798. */
  55799. export class MultiplyBlock extends NodeMaterialBlock {
  55800. /**
  55801. * Creates a new MultiplyBlock
  55802. * @param name defines the block name
  55803. */
  55804. constructor(name: string);
  55805. /**
  55806. * Gets the current class name
  55807. * @returns the class name
  55808. */
  55809. getClassName(): string;
  55810. /**
  55811. * Gets the left operand input component
  55812. */
  55813. readonly left: NodeMaterialConnectionPoint;
  55814. /**
  55815. * Gets the right operand input component
  55816. */
  55817. readonly right: NodeMaterialConnectionPoint;
  55818. /**
  55819. * Gets the output component
  55820. */
  55821. readonly output: NodeMaterialConnectionPoint;
  55822. protected _buildBlock(state: NodeMaterialBuildState): this;
  55823. }
  55824. }
  55825. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55829. /**
  55830. * Block used to add 2 vectors
  55831. */
  55832. export class AddBlock extends NodeMaterialBlock {
  55833. /**
  55834. * Creates a new AddBlock
  55835. * @param name defines the block name
  55836. */
  55837. constructor(name: string);
  55838. /**
  55839. * Gets the current class name
  55840. * @returns the class name
  55841. */
  55842. getClassName(): string;
  55843. /**
  55844. * Gets the left operand input component
  55845. */
  55846. readonly left: NodeMaterialConnectionPoint;
  55847. /**
  55848. * Gets the right operand input component
  55849. */
  55850. readonly right: NodeMaterialConnectionPoint;
  55851. /**
  55852. * Gets the output component
  55853. */
  55854. readonly output: NodeMaterialConnectionPoint;
  55855. protected _buildBlock(state: NodeMaterialBuildState): this;
  55856. }
  55857. }
  55858. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55862. /**
  55863. * Block used to scale a vector by a float
  55864. */
  55865. export class ScaleBlock extends NodeMaterialBlock {
  55866. /**
  55867. * Creates a new ScaleBlock
  55868. * @param name defines the block name
  55869. */
  55870. constructor(name: string);
  55871. /**
  55872. * Gets the current class name
  55873. * @returns the class name
  55874. */
  55875. getClassName(): string;
  55876. /**
  55877. * Gets the input component
  55878. */
  55879. readonly input: NodeMaterialConnectionPoint;
  55880. /**
  55881. * Gets the factor input component
  55882. */
  55883. readonly factor: NodeMaterialConnectionPoint;
  55884. /**
  55885. * Gets the output component
  55886. */
  55887. readonly output: NodeMaterialConnectionPoint;
  55888. protected _buildBlock(state: NodeMaterialBuildState): this;
  55889. }
  55890. }
  55891. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55895. /**
  55896. * Block used to clamp a float
  55897. */
  55898. export class ClampBlock extends NodeMaterialBlock {
  55899. /** Gets or sets the minimum range */
  55900. minimum: number;
  55901. /** Gets or sets the maximum range */
  55902. maximum: number;
  55903. /**
  55904. * Creates a new ClampBlock
  55905. * @param name defines the block name
  55906. */
  55907. constructor(name: string);
  55908. /**
  55909. * Gets the current class name
  55910. * @returns the class name
  55911. */
  55912. getClassName(): string;
  55913. /**
  55914. * Gets the value input component
  55915. */
  55916. readonly value: NodeMaterialConnectionPoint;
  55917. /**
  55918. * Gets the output component
  55919. */
  55920. readonly output: NodeMaterialConnectionPoint;
  55921. protected _buildBlock(state: NodeMaterialBuildState): this;
  55922. }
  55923. }
  55924. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55928. /**
  55929. * Block used to apply a cross product between 2 vectors
  55930. */
  55931. export class CrossBlock extends NodeMaterialBlock {
  55932. /**
  55933. * Creates a new CrossBlock
  55934. * @param name defines the block name
  55935. */
  55936. constructor(name: string);
  55937. /**
  55938. * Gets the current class name
  55939. * @returns the class name
  55940. */
  55941. getClassName(): string;
  55942. /**
  55943. * Gets the left operand input component
  55944. */
  55945. readonly left: NodeMaterialConnectionPoint;
  55946. /**
  55947. * Gets the right operand input component
  55948. */
  55949. readonly right: NodeMaterialConnectionPoint;
  55950. /**
  55951. * Gets the output component
  55952. */
  55953. readonly output: NodeMaterialConnectionPoint;
  55954. protected _buildBlock(state: NodeMaterialBuildState): this;
  55955. }
  55956. }
  55957. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55961. /**
  55962. * Block used to apply a dot product between 2 vectors
  55963. */
  55964. export class DotBlock extends NodeMaterialBlock {
  55965. /**
  55966. * Creates a new DotBlock
  55967. * @param name defines the block name
  55968. */
  55969. constructor(name: string);
  55970. /**
  55971. * Gets the current class name
  55972. * @returns the class name
  55973. */
  55974. getClassName(): string;
  55975. /**
  55976. * Gets the left operand input component
  55977. */
  55978. readonly left: NodeMaterialConnectionPoint;
  55979. /**
  55980. * Gets the right operand input component
  55981. */
  55982. readonly right: NodeMaterialConnectionPoint;
  55983. /**
  55984. * Gets the output component
  55985. */
  55986. readonly output: NodeMaterialConnectionPoint;
  55987. protected _buildBlock(state: NodeMaterialBuildState): this;
  55988. }
  55989. }
  55990. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55994. import { Vector2 } from "babylonjs/Maths/math.vector";
  55995. /**
  55996. * Block used to remap a float from a range to a new one
  55997. */
  55998. export class RemapBlock extends NodeMaterialBlock {
  55999. /**
  56000. * Gets or sets the source range
  56001. */
  56002. sourceRange: Vector2;
  56003. /**
  56004. * Gets or sets the target range
  56005. */
  56006. targetRange: Vector2;
  56007. /**
  56008. * Creates a new RemapBlock
  56009. * @param name defines the block name
  56010. */
  56011. constructor(name: string);
  56012. /**
  56013. * Gets the current class name
  56014. * @returns the class name
  56015. */
  56016. getClassName(): string;
  56017. /**
  56018. * Gets the input component
  56019. */
  56020. readonly input: NodeMaterialConnectionPoint;
  56021. /**
  56022. * Gets the output component
  56023. */
  56024. readonly output: NodeMaterialConnectionPoint;
  56025. protected _buildBlock(state: NodeMaterialBuildState): this;
  56026. }
  56027. }
  56028. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56032. /**
  56033. * Block used to normalize a vector
  56034. */
  56035. export class NormalizeBlock extends NodeMaterialBlock {
  56036. /**
  56037. * Creates a new NormalizeBlock
  56038. * @param name defines the block name
  56039. */
  56040. constructor(name: string);
  56041. /**
  56042. * Gets the current class name
  56043. * @returns the class name
  56044. */
  56045. getClassName(): string;
  56046. /**
  56047. * Gets the input component
  56048. */
  56049. readonly input: NodeMaterialConnectionPoint;
  56050. /**
  56051. * Gets the output component
  56052. */
  56053. readonly output: NodeMaterialConnectionPoint;
  56054. protected _buildBlock(state: NodeMaterialBuildState): this;
  56055. }
  56056. }
  56057. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56061. /**
  56062. * Operations supported by the Trigonometry block
  56063. */
  56064. export enum TrigonometryBlockOperations {
  56065. /** Cos */
  56066. Cos = 0,
  56067. /** Sin */
  56068. Sin = 1,
  56069. /** Abs */
  56070. Abs = 2,
  56071. /** Exp */
  56072. Exp = 3,
  56073. /** Exp2 */
  56074. Exp2 = 4
  56075. }
  56076. /**
  56077. * Block used to apply trigonometry operation to floats
  56078. */
  56079. export class TrigonometryBlock extends NodeMaterialBlock {
  56080. /**
  56081. * Gets or sets the operation applied by the block
  56082. */
  56083. operation: TrigonometryBlockOperations;
  56084. /**
  56085. * Creates a new TrigonometryBlock
  56086. * @param name defines the block name
  56087. */
  56088. constructor(name: string);
  56089. /**
  56090. * Gets the current class name
  56091. * @returns the class name
  56092. */
  56093. getClassName(): string;
  56094. /**
  56095. * Gets the input component
  56096. */
  56097. readonly input: NodeMaterialConnectionPoint;
  56098. /**
  56099. * Gets the output component
  56100. */
  56101. readonly output: NodeMaterialConnectionPoint;
  56102. protected _buildBlock(state: NodeMaterialBuildState): this;
  56103. }
  56104. }
  56105. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56109. /**
  56110. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56111. */
  56112. export class ColorMergerBlock extends NodeMaterialBlock {
  56113. /**
  56114. * Create a new ColorMergerBlock
  56115. * @param name defines the block name
  56116. */
  56117. constructor(name: string);
  56118. /**
  56119. * Gets the current class name
  56120. * @returns the class name
  56121. */
  56122. getClassName(): string;
  56123. /**
  56124. * Gets the r component (input)
  56125. */
  56126. readonly r: NodeMaterialConnectionPoint;
  56127. /**
  56128. * Gets the g component (input)
  56129. */
  56130. readonly g: NodeMaterialConnectionPoint;
  56131. /**
  56132. * Gets the b component (input)
  56133. */
  56134. readonly b: NodeMaterialConnectionPoint;
  56135. /**
  56136. * Gets the a component (input)
  56137. */
  56138. readonly a: NodeMaterialConnectionPoint;
  56139. /**
  56140. * Gets the rgba component (output)
  56141. */
  56142. readonly rgba: NodeMaterialConnectionPoint;
  56143. /**
  56144. * Gets the rgb component (output)
  56145. */
  56146. readonly rgb: NodeMaterialConnectionPoint;
  56147. protected _buildBlock(state: NodeMaterialBuildState): this;
  56148. }
  56149. }
  56150. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56154. /**
  56155. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56156. */
  56157. export class VectorMergerBlock extends NodeMaterialBlock {
  56158. /**
  56159. * Create a new VectorMergerBlock
  56160. * @param name defines the block name
  56161. */
  56162. constructor(name: string);
  56163. /**
  56164. * Gets the current class name
  56165. * @returns the class name
  56166. */
  56167. getClassName(): string;
  56168. /**
  56169. * Gets the x component (input)
  56170. */
  56171. readonly x: NodeMaterialConnectionPoint;
  56172. /**
  56173. * Gets the y component (input)
  56174. */
  56175. readonly y: NodeMaterialConnectionPoint;
  56176. /**
  56177. * Gets the z component (input)
  56178. */
  56179. readonly z: NodeMaterialConnectionPoint;
  56180. /**
  56181. * Gets the w component (input)
  56182. */
  56183. readonly w: NodeMaterialConnectionPoint;
  56184. /**
  56185. * Gets the xyzw component (output)
  56186. */
  56187. readonly xyzw: NodeMaterialConnectionPoint;
  56188. /**
  56189. * Gets the xyz component (output)
  56190. */
  56191. readonly xyz: NodeMaterialConnectionPoint;
  56192. /**
  56193. * Gets the xy component (output)
  56194. */
  56195. readonly xy: NodeMaterialConnectionPoint;
  56196. protected _buildBlock(state: NodeMaterialBuildState): this;
  56197. }
  56198. }
  56199. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56203. /**
  56204. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56205. */
  56206. export class ColorSplitterBlock extends NodeMaterialBlock {
  56207. /**
  56208. * Create a new ColorSplitterBlock
  56209. * @param name defines the block name
  56210. */
  56211. constructor(name: string);
  56212. /**
  56213. * Gets the current class name
  56214. * @returns the class name
  56215. */
  56216. getClassName(): string;
  56217. /**
  56218. * Gets the rgba component (input)
  56219. */
  56220. readonly rgba: NodeMaterialConnectionPoint;
  56221. /**
  56222. * Gets the rgb component (input)
  56223. */
  56224. readonly rgbIn: NodeMaterialConnectionPoint;
  56225. /**
  56226. * Gets the rgb component (output)
  56227. */
  56228. readonly rgbOut: NodeMaterialConnectionPoint;
  56229. /**
  56230. * Gets the r component (output)
  56231. */
  56232. readonly r: NodeMaterialConnectionPoint;
  56233. /**
  56234. * Gets the g component (output)
  56235. */
  56236. readonly g: NodeMaterialConnectionPoint;
  56237. /**
  56238. * Gets the b component (output)
  56239. */
  56240. readonly b: NodeMaterialConnectionPoint;
  56241. /**
  56242. * Gets the a component (output)
  56243. */
  56244. readonly a: NodeMaterialConnectionPoint;
  56245. protected _inputRename(name: string): string;
  56246. protected _outputRename(name: string): string;
  56247. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56248. }
  56249. }
  56250. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56251. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56253. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56254. /**
  56255. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56256. */
  56257. export class VectorSplitterBlock extends NodeMaterialBlock {
  56258. /**
  56259. * Create a new VectorSplitterBlock
  56260. * @param name defines the block name
  56261. */
  56262. constructor(name: string);
  56263. /**
  56264. * Gets the current class name
  56265. * @returns the class name
  56266. */
  56267. getClassName(): string;
  56268. /**
  56269. * Gets the xyzw component (input)
  56270. */
  56271. readonly xyzw: NodeMaterialConnectionPoint;
  56272. /**
  56273. * Gets the xyz component (input)
  56274. */
  56275. readonly xyzIn: NodeMaterialConnectionPoint;
  56276. /**
  56277. * Gets the xy component (input)
  56278. */
  56279. readonly xyIn: NodeMaterialConnectionPoint;
  56280. /**
  56281. * Gets the xyz component (output)
  56282. */
  56283. readonly xyzOut: NodeMaterialConnectionPoint;
  56284. /**
  56285. * Gets the xy component (output)
  56286. */
  56287. readonly xyOut: NodeMaterialConnectionPoint;
  56288. /**
  56289. * Gets the x component (output)
  56290. */
  56291. readonly x: NodeMaterialConnectionPoint;
  56292. /**
  56293. * Gets the y component (output)
  56294. */
  56295. readonly y: NodeMaterialConnectionPoint;
  56296. /**
  56297. * Gets the z component (output)
  56298. */
  56299. readonly z: NodeMaterialConnectionPoint;
  56300. /**
  56301. * Gets the w component (output)
  56302. */
  56303. readonly w: NodeMaterialConnectionPoint;
  56304. protected _inputRename(name: string): string;
  56305. protected _outputRename(name: string): string;
  56306. protected _buildBlock(state: NodeMaterialBuildState): this;
  56307. }
  56308. }
  56309. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56311. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56313. /**
  56314. * Block used to lerp 2 values
  56315. */
  56316. export class LerpBlock extends NodeMaterialBlock {
  56317. /**
  56318. * Creates a new LerpBlock
  56319. * @param name defines the block name
  56320. */
  56321. constructor(name: string);
  56322. /**
  56323. * Gets the current class name
  56324. * @returns the class name
  56325. */
  56326. getClassName(): string;
  56327. /**
  56328. * Gets the left operand input component
  56329. */
  56330. readonly left: NodeMaterialConnectionPoint;
  56331. /**
  56332. * Gets the right operand input component
  56333. */
  56334. readonly right: NodeMaterialConnectionPoint;
  56335. /**
  56336. * Gets the gradient operand input component
  56337. */
  56338. readonly gradient: NodeMaterialConnectionPoint;
  56339. /**
  56340. * Gets the output component
  56341. */
  56342. readonly output: NodeMaterialConnectionPoint;
  56343. protected _buildBlock(state: NodeMaterialBuildState): this;
  56344. }
  56345. }
  56346. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56350. /**
  56351. * Block used to divide 2 vectors
  56352. */
  56353. export class DivideBlock extends NodeMaterialBlock {
  56354. /**
  56355. * Creates a new DivideBlock
  56356. * @param name defines the block name
  56357. */
  56358. constructor(name: string);
  56359. /**
  56360. * Gets the current class name
  56361. * @returns the class name
  56362. */
  56363. getClassName(): string;
  56364. /**
  56365. * Gets the left operand input component
  56366. */
  56367. readonly left: NodeMaterialConnectionPoint;
  56368. /**
  56369. * Gets the right operand input component
  56370. */
  56371. readonly right: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the output component
  56374. */
  56375. readonly output: NodeMaterialConnectionPoint;
  56376. protected _buildBlock(state: NodeMaterialBuildState): this;
  56377. }
  56378. }
  56379. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56383. /**
  56384. * Block used to subtract 2 vectors
  56385. */
  56386. export class SubtractBlock extends NodeMaterialBlock {
  56387. /**
  56388. * Creates a new SubtractBlock
  56389. * @param name defines the block name
  56390. */
  56391. constructor(name: string);
  56392. /**
  56393. * Gets the current class name
  56394. * @returns the class name
  56395. */
  56396. getClassName(): string;
  56397. /**
  56398. * Gets the left operand input component
  56399. */
  56400. readonly left: NodeMaterialConnectionPoint;
  56401. /**
  56402. * Gets the right operand input component
  56403. */
  56404. readonly right: NodeMaterialConnectionPoint;
  56405. /**
  56406. * Gets the output component
  56407. */
  56408. readonly output: NodeMaterialConnectionPoint;
  56409. protected _buildBlock(state: NodeMaterialBuildState): this;
  56410. }
  56411. }
  56412. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56416. /**
  56417. * Block used to step a value
  56418. */
  56419. export class StepBlock extends NodeMaterialBlock {
  56420. /**
  56421. * Creates a new AddBlock
  56422. * @param name defines the block name
  56423. */
  56424. constructor(name: string);
  56425. /**
  56426. * Gets the current class name
  56427. * @returns the class name
  56428. */
  56429. getClassName(): string;
  56430. /**
  56431. * Gets the value operand input component
  56432. */
  56433. readonly value: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the edge operand input component
  56436. */
  56437. readonly edge: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the output component
  56440. */
  56441. readonly output: NodeMaterialConnectionPoint;
  56442. protected _buildBlock(state: NodeMaterialBuildState): this;
  56443. }
  56444. }
  56445. declare module "babylonjs/Materials/Node/Blocks/typeConverterBlock" {
  56446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56449. /**
  56450. * Block used to convert color to vector and vice versa
  56451. */
  56452. export class TypeConverterBlock extends NodeMaterialBlock {
  56453. /**
  56454. * Creates a new TypeConverterBlock
  56455. * @param name defines the block name
  56456. */
  56457. constructor(name: string);
  56458. /**
  56459. * Gets the current class name
  56460. * @returns the class name
  56461. */
  56462. getClassName(): string;
  56463. /**
  56464. * Gets the input component
  56465. */
  56466. readonly input: NodeMaterialConnectionPoint;
  56467. /**
  56468. * Gets the output component
  56469. */
  56470. readonly output: NodeMaterialConnectionPoint;
  56471. protected _buildBlock(state: NodeMaterialBuildState): this;
  56472. }
  56473. }
  56474. declare module "babylonjs/Materials/Node/Blocks/index" {
  56475. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56476. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56477. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56478. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56479. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56480. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56481. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56482. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56483. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56484. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56485. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56486. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56487. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56488. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56489. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  56490. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  56491. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  56492. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  56493. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  56494. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  56495. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  56496. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  56497. export * from "babylonjs/Materials/Node/Blocks/typeConverterBlock";
  56498. }
  56499. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56500. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56501. }
  56502. declare module "babylonjs/Materials/Node/index" {
  56503. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56504. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56505. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56506. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56507. export * from "babylonjs/Materials/Node/nodeMaterial";
  56508. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56509. export * from "babylonjs/Materials/Node/Blocks/index";
  56510. export * from "babylonjs/Materials/Node/Optimizers/index";
  56511. }
  56512. declare module "babylonjs/Materials/effectRenderer" {
  56513. import { Nullable } from "babylonjs/types";
  56514. import { Texture } from "babylonjs/Materials/Textures/texture";
  56515. import { Engine } from "babylonjs/Engines/engine";
  56516. import { Viewport } from "babylonjs/Maths/math.viewport";
  56517. import { Observable } from "babylonjs/Misc/observable";
  56518. import { Effect } from "babylonjs/Materials/effect";
  56519. import "babylonjs/Shaders/postprocess.vertex";
  56520. /**
  56521. * Effect Render Options
  56522. */
  56523. export interface IEffectRendererOptions {
  56524. /**
  56525. * Defines the vertices positions.
  56526. */
  56527. positions?: number[];
  56528. /**
  56529. * Defines the indices.
  56530. */
  56531. indices?: number[];
  56532. }
  56533. /**
  56534. * Helper class to render one or more effects
  56535. */
  56536. export class EffectRenderer {
  56537. private engine;
  56538. private static _DefaultOptions;
  56539. private _vertexBuffers;
  56540. private _indexBuffer;
  56541. private _ringBufferIndex;
  56542. private _ringScreenBuffer;
  56543. private _fullscreenViewport;
  56544. private _getNextFrameBuffer;
  56545. /**
  56546. * Creates an effect renderer
  56547. * @param engine the engine to use for rendering
  56548. * @param options defines the options of the effect renderer
  56549. */
  56550. constructor(engine: Engine, options?: IEffectRendererOptions);
  56551. /**
  56552. * Sets the current viewport in normalized coordinates 0-1
  56553. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56554. */
  56555. setViewport(viewport?: Viewport): void;
  56556. /**
  56557. * Sets the current effect wrapper to use during draw.
  56558. * The effect needs to be ready before calling this api.
  56559. * This also sets the default full screen position attribute.
  56560. * @param effectWrapper Defines the effect to draw with
  56561. */
  56562. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56563. /**
  56564. * Draws a full screen quad.
  56565. */
  56566. draw(): void;
  56567. /**
  56568. * renders one or more effects to a specified texture
  56569. * @param effectWrappers list of effects to renderer
  56570. * @param outputTexture texture to draw to, if null it will render to the screen
  56571. */
  56572. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56573. /**
  56574. * Disposes of the effect renderer
  56575. */
  56576. dispose(): void;
  56577. }
  56578. /**
  56579. * Options to create an EffectWrapper
  56580. */
  56581. interface EffectWrapperCreationOptions {
  56582. /**
  56583. * Engine to use to create the effect
  56584. */
  56585. engine: Engine;
  56586. /**
  56587. * Fragment shader for the effect
  56588. */
  56589. fragmentShader: string;
  56590. /**
  56591. * Vertex shader for the effect
  56592. */
  56593. vertexShader?: string;
  56594. /**
  56595. * Attributes to use in the shader
  56596. */
  56597. attributeNames?: Array<string>;
  56598. /**
  56599. * Uniforms to use in the shader
  56600. */
  56601. uniformNames?: Array<string>;
  56602. /**
  56603. * Texture sampler names to use in the shader
  56604. */
  56605. samplerNames?: Array<string>;
  56606. /**
  56607. * The friendly name of the effect displayed in Spector.
  56608. */
  56609. name?: string;
  56610. }
  56611. /**
  56612. * Wraps an effect to be used for rendering
  56613. */
  56614. export class EffectWrapper {
  56615. /**
  56616. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56617. */
  56618. onApplyObservable: Observable<{}>;
  56619. /**
  56620. * The underlying effect
  56621. */
  56622. effect: Effect;
  56623. /**
  56624. * Creates an effect to be renderer
  56625. * @param creationOptions options to create the effect
  56626. */
  56627. constructor(creationOptions: EffectWrapperCreationOptions);
  56628. /**
  56629. * Disposes of the effect wrapper
  56630. */
  56631. dispose(): void;
  56632. }
  56633. }
  56634. declare module "babylonjs/Materials/index" {
  56635. export * from "babylonjs/Materials/Background/index";
  56636. export * from "babylonjs/Materials/colorCurves";
  56637. export * from "babylonjs/Materials/effect";
  56638. export * from "babylonjs/Materials/fresnelParameters";
  56639. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56640. export * from "babylonjs/Materials/material";
  56641. export * from "babylonjs/Materials/materialDefines";
  56642. export * from "babylonjs/Materials/materialHelper";
  56643. export * from "babylonjs/Materials/multiMaterial";
  56644. export * from "babylonjs/Materials/PBR/index";
  56645. export * from "babylonjs/Materials/pushMaterial";
  56646. export * from "babylonjs/Materials/shaderMaterial";
  56647. export * from "babylonjs/Materials/standardMaterial";
  56648. export * from "babylonjs/Materials/Textures/index";
  56649. export * from "babylonjs/Materials/uniformBuffer";
  56650. export * from "babylonjs/Materials/materialFlags";
  56651. export * from "babylonjs/Materials/Node/index";
  56652. export * from "babylonjs/Materials/effectRenderer";
  56653. }
  56654. declare module "babylonjs/Maths/index" {
  56655. export * from "babylonjs/Maths/math.scalar";
  56656. export * from "babylonjs/Maths/math";
  56657. export * from "babylonjs/Maths/sphericalPolynomial";
  56658. }
  56659. declare module "babylonjs/Misc/workerPool" {
  56660. import { IDisposable } from "babylonjs/scene";
  56661. /**
  56662. * Helper class to push actions to a pool of workers.
  56663. */
  56664. export class WorkerPool implements IDisposable {
  56665. private _workerInfos;
  56666. private _pendingActions;
  56667. /**
  56668. * Constructor
  56669. * @param workers Array of workers to use for actions
  56670. */
  56671. constructor(workers: Array<Worker>);
  56672. /**
  56673. * Terminates all workers and clears any pending actions.
  56674. */
  56675. dispose(): void;
  56676. /**
  56677. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56678. * pended until a worker has completed its action.
  56679. * @param action The action to perform. Call onComplete when the action is complete.
  56680. */
  56681. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56682. private _execute;
  56683. }
  56684. }
  56685. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56686. import { IDisposable } from "babylonjs/scene";
  56687. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56688. /**
  56689. * Configuration for Draco compression
  56690. */
  56691. export interface IDracoCompressionConfiguration {
  56692. /**
  56693. * Configuration for the decoder.
  56694. */
  56695. decoder: {
  56696. /**
  56697. * The url to the WebAssembly module.
  56698. */
  56699. wasmUrl?: string;
  56700. /**
  56701. * The url to the WebAssembly binary.
  56702. */
  56703. wasmBinaryUrl?: string;
  56704. /**
  56705. * The url to the fallback JavaScript module.
  56706. */
  56707. fallbackUrl?: string;
  56708. };
  56709. }
  56710. /**
  56711. * Draco compression (https://google.github.io/draco/)
  56712. *
  56713. * This class wraps the Draco module.
  56714. *
  56715. * **Encoder**
  56716. *
  56717. * The encoder is not currently implemented.
  56718. *
  56719. * **Decoder**
  56720. *
  56721. * 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.
  56722. *
  56723. * To update the configuration, use the following code:
  56724. * ```javascript
  56725. * DracoCompression.Configuration = {
  56726. * decoder: {
  56727. * wasmUrl: "<url to the WebAssembly library>",
  56728. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56729. * fallbackUrl: "<url to the fallback JavaScript library>",
  56730. * }
  56731. * };
  56732. * ```
  56733. *
  56734. * 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.
  56735. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56736. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56737. *
  56738. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56739. * ```javascript
  56740. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56741. * ```
  56742. *
  56743. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56744. */
  56745. export class DracoCompression implements IDisposable {
  56746. private _workerPoolPromise?;
  56747. private _decoderModulePromise?;
  56748. /**
  56749. * The configuration. Defaults to the following urls:
  56750. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56751. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56752. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56753. */
  56754. static Configuration: IDracoCompressionConfiguration;
  56755. /**
  56756. * Returns true if the decoder configuration is available.
  56757. */
  56758. static readonly DecoderAvailable: boolean;
  56759. /**
  56760. * Default number of workers to create when creating the draco compression object.
  56761. */
  56762. static DefaultNumWorkers: number;
  56763. private static GetDefaultNumWorkers;
  56764. private static _Default;
  56765. /**
  56766. * Default instance for the draco compression object.
  56767. */
  56768. static readonly Default: DracoCompression;
  56769. /**
  56770. * Constructor
  56771. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56772. */
  56773. constructor(numWorkers?: number);
  56774. /**
  56775. * Stop all async operations and release resources.
  56776. */
  56777. dispose(): void;
  56778. /**
  56779. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56780. * @returns a promise that resolves when ready
  56781. */
  56782. whenReadyAsync(): Promise<void>;
  56783. /**
  56784. * Decode Draco compressed mesh data to vertex data.
  56785. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56786. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56787. * @returns A promise that resolves with the decoded vertex data
  56788. */
  56789. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56790. [kind: string]: number;
  56791. }): Promise<VertexData>;
  56792. }
  56793. }
  56794. declare module "babylonjs/Meshes/Compression/index" {
  56795. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56796. }
  56797. declare module "babylonjs/Meshes/csg" {
  56798. import { Nullable } from "babylonjs/types";
  56799. import { Scene } from "babylonjs/scene";
  56800. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56801. import { Mesh } from "babylonjs/Meshes/mesh";
  56802. import { Material } from "babylonjs/Materials/material";
  56803. /**
  56804. * Class for building Constructive Solid Geometry
  56805. */
  56806. export class CSG {
  56807. private polygons;
  56808. /**
  56809. * The world matrix
  56810. */
  56811. matrix: Matrix;
  56812. /**
  56813. * Stores the position
  56814. */
  56815. position: Vector3;
  56816. /**
  56817. * Stores the rotation
  56818. */
  56819. rotation: Vector3;
  56820. /**
  56821. * Stores the rotation quaternion
  56822. */
  56823. rotationQuaternion: Nullable<Quaternion>;
  56824. /**
  56825. * Stores the scaling vector
  56826. */
  56827. scaling: Vector3;
  56828. /**
  56829. * Convert the Mesh to CSG
  56830. * @param mesh The Mesh to convert to CSG
  56831. * @returns A new CSG from the Mesh
  56832. */
  56833. static FromMesh(mesh: Mesh): CSG;
  56834. /**
  56835. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56836. * @param polygons Polygons used to construct a CSG solid
  56837. */
  56838. private static FromPolygons;
  56839. /**
  56840. * Clones, or makes a deep copy, of the CSG
  56841. * @returns A new CSG
  56842. */
  56843. clone(): CSG;
  56844. /**
  56845. * Unions this CSG with another CSG
  56846. * @param csg The CSG to union against this CSG
  56847. * @returns The unioned CSG
  56848. */
  56849. union(csg: CSG): CSG;
  56850. /**
  56851. * Unions this CSG with another CSG in place
  56852. * @param csg The CSG to union against this CSG
  56853. */
  56854. unionInPlace(csg: CSG): void;
  56855. /**
  56856. * Subtracts this CSG with another CSG
  56857. * @param csg The CSG to subtract against this CSG
  56858. * @returns A new CSG
  56859. */
  56860. subtract(csg: CSG): CSG;
  56861. /**
  56862. * Subtracts this CSG with another CSG in place
  56863. * @param csg The CSG to subtact against this CSG
  56864. */
  56865. subtractInPlace(csg: CSG): void;
  56866. /**
  56867. * Intersect this CSG with another CSG
  56868. * @param csg The CSG to intersect against this CSG
  56869. * @returns A new CSG
  56870. */
  56871. intersect(csg: CSG): CSG;
  56872. /**
  56873. * Intersects this CSG with another CSG in place
  56874. * @param csg The CSG to intersect against this CSG
  56875. */
  56876. intersectInPlace(csg: CSG): void;
  56877. /**
  56878. * Return a new CSG solid with solid and empty space switched. This solid is
  56879. * not modified.
  56880. * @returns A new CSG solid with solid and empty space switched
  56881. */
  56882. inverse(): CSG;
  56883. /**
  56884. * Inverses the CSG in place
  56885. */
  56886. inverseInPlace(): void;
  56887. /**
  56888. * This is used to keep meshes transformations so they can be restored
  56889. * when we build back a Babylon Mesh
  56890. * NB : All CSG operations are performed in world coordinates
  56891. * @param csg The CSG to copy the transform attributes from
  56892. * @returns This CSG
  56893. */
  56894. copyTransformAttributes(csg: CSG): CSG;
  56895. /**
  56896. * Build Raw mesh from CSG
  56897. * Coordinates here are in world space
  56898. * @param name The name of the mesh geometry
  56899. * @param scene The Scene
  56900. * @param keepSubMeshes Specifies if the submeshes should be kept
  56901. * @returns A new Mesh
  56902. */
  56903. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56904. /**
  56905. * Build Mesh from CSG taking material and transforms into account
  56906. * @param name The name of the Mesh
  56907. * @param material The material of the Mesh
  56908. * @param scene The Scene
  56909. * @param keepSubMeshes Specifies if submeshes should be kept
  56910. * @returns The new Mesh
  56911. */
  56912. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56913. }
  56914. }
  56915. declare module "babylonjs/Meshes/trailMesh" {
  56916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56917. import { Mesh } from "babylonjs/Meshes/mesh";
  56918. import { Scene } from "babylonjs/scene";
  56919. /**
  56920. * Class used to create a trail following a mesh
  56921. */
  56922. export class TrailMesh extends Mesh {
  56923. private _generator;
  56924. private _autoStart;
  56925. private _running;
  56926. private _diameter;
  56927. private _length;
  56928. private _sectionPolygonPointsCount;
  56929. private _sectionVectors;
  56930. private _sectionNormalVectors;
  56931. private _beforeRenderObserver;
  56932. /**
  56933. * @constructor
  56934. * @param name The value used by scene.getMeshByName() to do a lookup.
  56935. * @param generator The mesh to generate a trail.
  56936. * @param scene The scene to add this mesh to.
  56937. * @param diameter Diameter of trailing mesh. Default is 1.
  56938. * @param length Length of trailing mesh. Default is 60.
  56939. * @param autoStart Automatically start trailing mesh. Default true.
  56940. */
  56941. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56942. /**
  56943. * "TrailMesh"
  56944. * @returns "TrailMesh"
  56945. */
  56946. getClassName(): string;
  56947. private _createMesh;
  56948. /**
  56949. * Start trailing mesh.
  56950. */
  56951. start(): void;
  56952. /**
  56953. * Stop trailing mesh.
  56954. */
  56955. stop(): void;
  56956. /**
  56957. * Update trailing mesh geometry.
  56958. */
  56959. update(): void;
  56960. /**
  56961. * Returns a new TrailMesh object.
  56962. * @param name is a string, the name given to the new mesh
  56963. * @param newGenerator use new generator object for cloned trail mesh
  56964. * @returns a new mesh
  56965. */
  56966. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56967. /**
  56968. * Serializes this trail mesh
  56969. * @param serializationObject object to write serialization to
  56970. */
  56971. serialize(serializationObject: any): void;
  56972. /**
  56973. * Parses a serialized trail mesh
  56974. * @param parsedMesh the serialized mesh
  56975. * @param scene the scene to create the trail mesh in
  56976. * @returns the created trail mesh
  56977. */
  56978. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56979. }
  56980. }
  56981. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56982. import { Nullable } from "babylonjs/types";
  56983. import { Scene } from "babylonjs/scene";
  56984. import { Vector4 } from "babylonjs/Maths/math.vector";
  56985. import { Color4 } from "babylonjs/Maths/math.color";
  56986. import { Mesh } from "babylonjs/Meshes/mesh";
  56987. /**
  56988. * Class containing static functions to help procedurally build meshes
  56989. */
  56990. export class TiledBoxBuilder {
  56991. /**
  56992. * Creates a box mesh
  56993. * 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)
  56994. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 box mesh
  57002. */
  57003. static CreateTiledBox(name: string, options: {
  57004. pattern?: number;
  57005. width?: number;
  57006. height?: number;
  57007. depth?: number;
  57008. tileSize?: number;
  57009. tileWidth?: number;
  57010. tileHeight?: number;
  57011. alignHorizontal?: number;
  57012. alignVertical?: number;
  57013. faceUV?: Vector4[];
  57014. faceColors?: Color4[];
  57015. sideOrientation?: number;
  57016. updatable?: boolean;
  57017. }, scene?: Nullable<Scene>): Mesh;
  57018. }
  57019. }
  57020. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57021. import { Vector4 } from "babylonjs/Maths/math.vector";
  57022. import { Mesh } from "babylonjs/Meshes/mesh";
  57023. /**
  57024. * Class containing static functions to help procedurally build meshes
  57025. */
  57026. export class TorusKnotBuilder {
  57027. /**
  57028. * Creates a torus knot mesh
  57029. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57030. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57031. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57032. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57036. * @param name defines the name of the mesh
  57037. * @param options defines the options used to create the mesh
  57038. * @param scene defines the hosting scene
  57039. * @returns the torus knot mesh
  57040. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57041. */
  57042. static CreateTorusKnot(name: string, options: {
  57043. radius?: number;
  57044. tube?: number;
  57045. radialSegments?: number;
  57046. tubularSegments?: number;
  57047. p?: number;
  57048. q?: number;
  57049. updatable?: boolean;
  57050. sideOrientation?: number;
  57051. frontUVs?: Vector4;
  57052. backUVs?: Vector4;
  57053. }, scene: any): Mesh;
  57054. }
  57055. }
  57056. declare module "babylonjs/Meshes/polygonMesh" {
  57057. import { Scene } from "babylonjs/scene";
  57058. import { Vector2 } from "babylonjs/Maths/math.vector";
  57059. import { Mesh } from "babylonjs/Meshes/mesh";
  57060. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57061. import { Path2 } from "babylonjs/Maths/math.path";
  57062. /**
  57063. * Polygon
  57064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57065. */
  57066. export class Polygon {
  57067. /**
  57068. * Creates a rectangle
  57069. * @param xmin bottom X coord
  57070. * @param ymin bottom Y coord
  57071. * @param xmax top X coord
  57072. * @param ymax top Y coord
  57073. * @returns points that make the resulting rectation
  57074. */
  57075. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57076. /**
  57077. * Creates a circle
  57078. * @param radius radius of circle
  57079. * @param cx scale in x
  57080. * @param cy scale in y
  57081. * @param numberOfSides number of sides that make up the circle
  57082. * @returns points that make the resulting circle
  57083. */
  57084. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57085. /**
  57086. * Creates a polygon from input string
  57087. * @param input Input polygon data
  57088. * @returns the parsed points
  57089. */
  57090. static Parse(input: string): Vector2[];
  57091. /**
  57092. * Starts building a polygon from x and y coordinates
  57093. * @param x x coordinate
  57094. * @param y y coordinate
  57095. * @returns the started path2
  57096. */
  57097. static StartingAt(x: number, y: number): Path2;
  57098. }
  57099. /**
  57100. * Builds a polygon
  57101. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57102. */
  57103. export class PolygonMeshBuilder {
  57104. private _points;
  57105. private _outlinepoints;
  57106. private _holes;
  57107. private _name;
  57108. private _scene;
  57109. private _epoints;
  57110. private _eholes;
  57111. private _addToepoint;
  57112. /**
  57113. * Babylon reference to the earcut plugin.
  57114. */
  57115. bjsEarcut: any;
  57116. /**
  57117. * Creates a PolygonMeshBuilder
  57118. * @param name name of the builder
  57119. * @param contours Path of the polygon
  57120. * @param scene scene to add to when creating the mesh
  57121. * @param earcutInjection can be used to inject your own earcut reference
  57122. */
  57123. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57124. /**
  57125. * Adds a whole within the polygon
  57126. * @param hole Array of points defining the hole
  57127. * @returns this
  57128. */
  57129. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57130. /**
  57131. * Creates the polygon
  57132. * @param updatable If the mesh should be updatable
  57133. * @param depth The depth of the mesh created
  57134. * @returns the created mesh
  57135. */
  57136. build(updatable?: boolean, depth?: number): Mesh;
  57137. /**
  57138. * Creates the polygon
  57139. * @param depth The depth of the mesh created
  57140. * @returns the created VertexData
  57141. */
  57142. buildVertexData(depth?: number): VertexData;
  57143. /**
  57144. * Adds a side to the polygon
  57145. * @param positions points that make the polygon
  57146. * @param normals normals of the polygon
  57147. * @param uvs uvs of the polygon
  57148. * @param indices indices of the polygon
  57149. * @param bounds bounds of the polygon
  57150. * @param points points of the polygon
  57151. * @param depth depth of the polygon
  57152. * @param flip flip of the polygon
  57153. */
  57154. private addSide;
  57155. }
  57156. }
  57157. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57158. import { Scene } from "babylonjs/scene";
  57159. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57160. import { Color4 } from "babylonjs/Maths/math.color";
  57161. import { Mesh } from "babylonjs/Meshes/mesh";
  57162. import { Nullable } from "babylonjs/types";
  57163. /**
  57164. * Class containing static functions to help procedurally build meshes
  57165. */
  57166. export class PolygonBuilder {
  57167. /**
  57168. * Creates a polygon mesh
  57169. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57170. * * 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
  57171. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57174. * * Remember you can only change the shape positions, not their number when updating a polygon
  57175. * @param name defines the name of the mesh
  57176. * @param options defines the options used to create the mesh
  57177. * @param scene defines the hosting scene
  57178. * @param earcutInjection can be used to inject your own earcut reference
  57179. * @returns the polygon mesh
  57180. */
  57181. static CreatePolygon(name: string, options: {
  57182. shape: Vector3[];
  57183. holes?: Vector3[][];
  57184. depth?: number;
  57185. faceUV?: Vector4[];
  57186. faceColors?: Color4[];
  57187. updatable?: boolean;
  57188. sideOrientation?: number;
  57189. frontUVs?: Vector4;
  57190. backUVs?: Vector4;
  57191. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57192. /**
  57193. * Creates an extruded polygon mesh, with depth in the Y direction.
  57194. * * 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)
  57195. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57196. * @param name defines the name of the mesh
  57197. * @param options defines the options used to create the mesh
  57198. * @param scene defines the hosting scene
  57199. * @param earcutInjection can be used to inject your own earcut reference
  57200. * @returns the polygon mesh
  57201. */
  57202. static ExtrudePolygon(name: string, options: {
  57203. shape: Vector3[];
  57204. holes?: Vector3[][];
  57205. depth?: number;
  57206. faceUV?: Vector4[];
  57207. faceColors?: Color4[];
  57208. updatable?: boolean;
  57209. sideOrientation?: number;
  57210. frontUVs?: Vector4;
  57211. backUVs?: Vector4;
  57212. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57213. }
  57214. }
  57215. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57216. import { Scene } from "babylonjs/scene";
  57217. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57218. import { Mesh } from "babylonjs/Meshes/mesh";
  57219. import { Nullable } from "babylonjs/types";
  57220. /**
  57221. * Class containing static functions to help procedurally build meshes
  57222. */
  57223. export class LatheBuilder {
  57224. /**
  57225. * Creates lathe mesh.
  57226. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57227. * * 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
  57228. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57229. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57230. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57231. * * 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
  57232. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57233. * * 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
  57234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57238. * @param name defines the name of the mesh
  57239. * @param options defines the options used to create the mesh
  57240. * @param scene defines the hosting scene
  57241. * @returns the lathe mesh
  57242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57243. */
  57244. static CreateLathe(name: string, options: {
  57245. shape: Vector3[];
  57246. radius?: number;
  57247. tessellation?: number;
  57248. clip?: number;
  57249. arc?: number;
  57250. closed?: boolean;
  57251. updatable?: boolean;
  57252. sideOrientation?: number;
  57253. frontUVs?: Vector4;
  57254. backUVs?: Vector4;
  57255. cap?: number;
  57256. invertUV?: boolean;
  57257. }, scene?: Nullable<Scene>): Mesh;
  57258. }
  57259. }
  57260. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57261. import { Nullable } from "babylonjs/types";
  57262. import { Scene } from "babylonjs/scene";
  57263. import { Vector4 } from "babylonjs/Maths/math.vector";
  57264. import { Mesh } from "babylonjs/Meshes/mesh";
  57265. /**
  57266. * Class containing static functions to help procedurally build meshes
  57267. */
  57268. export class TiledPlaneBuilder {
  57269. /**
  57270. * Creates a tiled plane mesh
  57271. * * The parameter `pattern` will, depending on value, do nothing or
  57272. * * * flip (reflect about central vertical) alternate tiles across and up
  57273. * * * flip every tile on alternate rows
  57274. * * * rotate (180 degs) alternate tiles across and up
  57275. * * * rotate every tile on alternate rows
  57276. * * * flip and rotate alternate tiles across and up
  57277. * * * flip and rotate every tile on alternate rows
  57278. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57279. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57281. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57282. * * 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)
  57283. * * 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)
  57284. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57285. * @param name defines the name of the mesh
  57286. * @param options defines the options used to create the mesh
  57287. * @param scene defines the hosting scene
  57288. * @returns the box mesh
  57289. */
  57290. static CreateTiledPlane(name: string, options: {
  57291. pattern?: number;
  57292. tileSize?: number;
  57293. tileWidth?: number;
  57294. tileHeight?: number;
  57295. size?: number;
  57296. width?: number;
  57297. height?: number;
  57298. alignHorizontal?: number;
  57299. alignVertical?: number;
  57300. sideOrientation?: number;
  57301. frontUVs?: Vector4;
  57302. backUVs?: Vector4;
  57303. updatable?: boolean;
  57304. }, scene?: Nullable<Scene>): Mesh;
  57305. }
  57306. }
  57307. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57308. import { Nullable } from "babylonjs/types";
  57309. import { Scene } from "babylonjs/scene";
  57310. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57311. import { Mesh } from "babylonjs/Meshes/mesh";
  57312. /**
  57313. * Class containing static functions to help procedurally build meshes
  57314. */
  57315. export class TubeBuilder {
  57316. /**
  57317. * Creates a tube mesh.
  57318. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57319. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57320. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57321. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57322. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57323. * * 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)
  57324. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57325. * * 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
  57326. * * 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
  57327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57331. * @param name defines the name of the mesh
  57332. * @param options defines the options used to create the mesh
  57333. * @param scene defines the hosting scene
  57334. * @returns the tube mesh
  57335. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57336. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57337. */
  57338. static CreateTube(name: string, options: {
  57339. path: Vector3[];
  57340. radius?: number;
  57341. tessellation?: number;
  57342. radiusFunction?: {
  57343. (i: number, distance: number): number;
  57344. };
  57345. cap?: number;
  57346. arc?: number;
  57347. updatable?: boolean;
  57348. sideOrientation?: number;
  57349. frontUVs?: Vector4;
  57350. backUVs?: Vector4;
  57351. instance?: Mesh;
  57352. invertUV?: boolean;
  57353. }, scene?: Nullable<Scene>): Mesh;
  57354. }
  57355. }
  57356. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57357. import { Scene } from "babylonjs/scene";
  57358. import { Vector4 } from "babylonjs/Maths/math.vector";
  57359. import { Mesh } from "babylonjs/Meshes/mesh";
  57360. import { Nullable } from "babylonjs/types";
  57361. /**
  57362. * Class containing static functions to help procedurally build meshes
  57363. */
  57364. export class IcoSphereBuilder {
  57365. /**
  57366. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57367. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57368. * * 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`)
  57369. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57370. * * 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
  57371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57374. * @param name defines the name of the mesh
  57375. * @param options defines the options used to create the mesh
  57376. * @param scene defines the hosting scene
  57377. * @returns the icosahedron mesh
  57378. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57379. */
  57380. static CreateIcoSphere(name: string, options: {
  57381. radius?: number;
  57382. radiusX?: number;
  57383. radiusY?: number;
  57384. radiusZ?: number;
  57385. flat?: boolean;
  57386. subdivisions?: number;
  57387. sideOrientation?: number;
  57388. frontUVs?: Vector4;
  57389. backUVs?: Vector4;
  57390. updatable?: boolean;
  57391. }, scene?: Nullable<Scene>): Mesh;
  57392. }
  57393. }
  57394. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57395. import { Vector3 } from "babylonjs/Maths/math.vector";
  57396. import { Mesh } from "babylonjs/Meshes/mesh";
  57397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57398. /**
  57399. * Class containing static functions to help procedurally build meshes
  57400. */
  57401. export class DecalBuilder {
  57402. /**
  57403. * Creates a decal mesh.
  57404. * 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
  57405. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57406. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57407. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57408. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57409. * @param name defines the name of the mesh
  57410. * @param sourceMesh defines the mesh where the decal must be applied
  57411. * @param options defines the options used to create the mesh
  57412. * @param scene defines the hosting scene
  57413. * @returns the decal mesh
  57414. * @see https://doc.babylonjs.com/how_to/decals
  57415. */
  57416. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57417. position?: Vector3;
  57418. normal?: Vector3;
  57419. size?: Vector3;
  57420. angle?: number;
  57421. }): Mesh;
  57422. }
  57423. }
  57424. declare module "babylonjs/Meshes/meshBuilder" {
  57425. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57426. import { Nullable } from "babylonjs/types";
  57427. import { Scene } from "babylonjs/scene";
  57428. import { Mesh } from "babylonjs/Meshes/mesh";
  57429. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57430. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57432. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57433. import { Plane } from "babylonjs/Maths/math.plane";
  57434. /**
  57435. * Class containing static functions to help procedurally build meshes
  57436. */
  57437. export class MeshBuilder {
  57438. /**
  57439. * Creates a box mesh
  57440. * * The parameter `size` sets the size (float) of each box side (default 1)
  57441. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57442. * * 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)
  57443. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57447. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57448. * @param name defines the name of the mesh
  57449. * @param options defines the options used to create the mesh
  57450. * @param scene defines the hosting scene
  57451. * @returns the box mesh
  57452. */
  57453. static CreateBox(name: string, options: {
  57454. size?: number;
  57455. width?: number;
  57456. height?: number;
  57457. depth?: number;
  57458. faceUV?: Vector4[];
  57459. faceColors?: Color4[];
  57460. sideOrientation?: number;
  57461. frontUVs?: Vector4;
  57462. backUVs?: Vector4;
  57463. updatable?: boolean;
  57464. }, scene?: Nullable<Scene>): Mesh;
  57465. /**
  57466. * Creates a tiled box mesh
  57467. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57469. * @param name defines the name of the mesh
  57470. * @param options defines the options used to create the mesh
  57471. * @param scene defines the hosting scene
  57472. * @returns the tiled box mesh
  57473. */
  57474. static CreateTiledBox(name: string, options: {
  57475. pattern?: number;
  57476. size?: number;
  57477. width?: number;
  57478. height?: number;
  57479. depth: number;
  57480. tileSize?: number;
  57481. tileWidth?: number;
  57482. tileHeight?: number;
  57483. faceUV?: Vector4[];
  57484. faceColors?: Color4[];
  57485. alignHorizontal?: number;
  57486. alignVertical?: number;
  57487. sideOrientation?: number;
  57488. updatable?: boolean;
  57489. }, scene?: Nullable<Scene>): Mesh;
  57490. /**
  57491. * Creates a sphere mesh
  57492. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57493. * * 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`)
  57494. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57495. * * 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
  57496. * * 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)
  57497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57500. * @param name defines the name of the mesh
  57501. * @param options defines the options used to create the mesh
  57502. * @param scene defines the hosting scene
  57503. * @returns the sphere mesh
  57504. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57505. */
  57506. static CreateSphere(name: string, options: {
  57507. segments?: number;
  57508. diameter?: number;
  57509. diameterX?: number;
  57510. diameterY?: number;
  57511. diameterZ?: number;
  57512. arc?: number;
  57513. slice?: number;
  57514. sideOrientation?: number;
  57515. frontUVs?: Vector4;
  57516. backUVs?: Vector4;
  57517. updatable?: boolean;
  57518. }, scene?: Nullable<Scene>): Mesh;
  57519. /**
  57520. * Creates a plane polygonal mesh. By default, this is a disc
  57521. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57522. * * 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
  57523. * * 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
  57524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57527. * @param name defines the name of the mesh
  57528. * @param options defines the options used to create the mesh
  57529. * @param scene defines the hosting scene
  57530. * @returns the plane polygonal mesh
  57531. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57532. */
  57533. static CreateDisc(name: string, options: {
  57534. radius?: number;
  57535. tessellation?: number;
  57536. arc?: number;
  57537. updatable?: boolean;
  57538. sideOrientation?: number;
  57539. frontUVs?: Vector4;
  57540. backUVs?: Vector4;
  57541. }, scene?: Nullable<Scene>): Mesh;
  57542. /**
  57543. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57544. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57545. * * 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`)
  57546. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57547. * * 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
  57548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57551. * @param name defines the name of the mesh
  57552. * @param options defines the options used to create the mesh
  57553. * @param scene defines the hosting scene
  57554. * @returns the icosahedron mesh
  57555. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57556. */
  57557. static CreateIcoSphere(name: string, options: {
  57558. radius?: number;
  57559. radiusX?: number;
  57560. radiusY?: number;
  57561. radiusZ?: number;
  57562. flat?: boolean;
  57563. subdivisions?: number;
  57564. sideOrientation?: number;
  57565. frontUVs?: Vector4;
  57566. backUVs?: Vector4;
  57567. updatable?: boolean;
  57568. }, scene?: Nullable<Scene>): Mesh;
  57569. /**
  57570. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57571. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57572. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57573. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57574. * * 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
  57575. * * 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
  57576. * * 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
  57577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57580. * * 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
  57581. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57582. * * 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
  57583. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57585. * @param name defines the name of the mesh
  57586. * @param options defines the options used to create the mesh
  57587. * @param scene defines the hosting scene
  57588. * @returns the ribbon mesh
  57589. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57591. */
  57592. static CreateRibbon(name: string, options: {
  57593. pathArray: Vector3[][];
  57594. closeArray?: boolean;
  57595. closePath?: boolean;
  57596. offset?: number;
  57597. updatable?: boolean;
  57598. sideOrientation?: number;
  57599. frontUVs?: Vector4;
  57600. backUVs?: Vector4;
  57601. instance?: Mesh;
  57602. invertUV?: boolean;
  57603. uvs?: Vector2[];
  57604. colors?: Color4[];
  57605. }, scene?: Nullable<Scene>): Mesh;
  57606. /**
  57607. * Creates a cylinder or a cone mesh
  57608. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57609. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57610. * * 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.
  57611. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57612. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57613. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57614. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57615. * * 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).
  57616. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57617. * * 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).
  57618. * * 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
  57619. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57620. * * 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
  57621. * * 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.
  57622. * * If `enclose` is false, a ring surface is one element.
  57623. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57624. * * 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
  57625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57628. * @param name defines the name of the mesh
  57629. * @param options defines the options used to create the mesh
  57630. * @param scene defines the hosting scene
  57631. * @returns the cylinder mesh
  57632. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57633. */
  57634. static CreateCylinder(name: string, options: {
  57635. height?: number;
  57636. diameterTop?: number;
  57637. diameterBottom?: number;
  57638. diameter?: number;
  57639. tessellation?: number;
  57640. subdivisions?: number;
  57641. arc?: number;
  57642. faceColors?: Color4[];
  57643. faceUV?: Vector4[];
  57644. updatable?: boolean;
  57645. hasRings?: boolean;
  57646. enclose?: boolean;
  57647. cap?: number;
  57648. sideOrientation?: number;
  57649. frontUVs?: Vector4;
  57650. backUVs?: Vector4;
  57651. }, scene?: Nullable<Scene>): Mesh;
  57652. /**
  57653. * Creates a torus mesh
  57654. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57655. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57656. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57660. * @param name defines the name of the mesh
  57661. * @param options defines the options used to create the mesh
  57662. * @param scene defines the hosting scene
  57663. * @returns the torus mesh
  57664. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57665. */
  57666. static CreateTorus(name: string, options: {
  57667. diameter?: number;
  57668. thickness?: number;
  57669. tessellation?: number;
  57670. updatable?: boolean;
  57671. sideOrientation?: number;
  57672. frontUVs?: Vector4;
  57673. backUVs?: Vector4;
  57674. }, scene?: Nullable<Scene>): Mesh;
  57675. /**
  57676. * Creates a torus knot mesh
  57677. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57678. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57679. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57680. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57684. * @param name defines the name of the mesh
  57685. * @param options defines the options used to create the mesh
  57686. * @param scene defines the hosting scene
  57687. * @returns the torus knot mesh
  57688. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57689. */
  57690. static CreateTorusKnot(name: string, options: {
  57691. radius?: number;
  57692. tube?: number;
  57693. radialSegments?: number;
  57694. tubularSegments?: number;
  57695. p?: number;
  57696. q?: number;
  57697. updatable?: boolean;
  57698. sideOrientation?: number;
  57699. frontUVs?: Vector4;
  57700. backUVs?: Vector4;
  57701. }, scene?: Nullable<Scene>): Mesh;
  57702. /**
  57703. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57704. * * 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
  57705. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57706. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57707. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57708. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57709. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57710. * * 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
  57711. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57714. * @param name defines the name of the new line system
  57715. * @param options defines the options used to create the line system
  57716. * @param scene defines the hosting scene
  57717. * @returns a new line system mesh
  57718. */
  57719. static CreateLineSystem(name: string, options: {
  57720. lines: Vector3[][];
  57721. updatable?: boolean;
  57722. instance?: Nullable<LinesMesh>;
  57723. colors?: Nullable<Color4[][]>;
  57724. useVertexAlpha?: boolean;
  57725. }, scene: Nullable<Scene>): LinesMesh;
  57726. /**
  57727. * Creates a line mesh
  57728. * 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
  57729. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57730. * * The parameter `points` is an array successive Vector3
  57731. * * 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
  57732. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57733. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57734. * * When updating an instance, remember that only point positions can change, not the number of points
  57735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57737. * @param name defines the name of the new line system
  57738. * @param options defines the options used to create the line system
  57739. * @param scene defines the hosting scene
  57740. * @returns a new line mesh
  57741. */
  57742. static CreateLines(name: string, options: {
  57743. points: Vector3[];
  57744. updatable?: boolean;
  57745. instance?: Nullable<LinesMesh>;
  57746. colors?: Color4[];
  57747. useVertexAlpha?: boolean;
  57748. }, scene?: Nullable<Scene>): LinesMesh;
  57749. /**
  57750. * Creates a dashed line mesh
  57751. * * 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
  57752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57753. * * The parameter `points` is an array successive Vector3
  57754. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57755. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57756. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57757. * * 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
  57758. * * When updating an instance, remember that only point positions can change, not the number of points
  57759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57760. * @param name defines the name of the mesh
  57761. * @param options defines the options used to create the mesh
  57762. * @param scene defines the hosting scene
  57763. * @returns the dashed line mesh
  57764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57765. */
  57766. static CreateDashedLines(name: string, options: {
  57767. points: Vector3[];
  57768. dashSize?: number;
  57769. gapSize?: number;
  57770. dashNb?: number;
  57771. updatable?: boolean;
  57772. instance?: LinesMesh;
  57773. }, scene?: Nullable<Scene>): LinesMesh;
  57774. /**
  57775. * 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.
  57776. * * 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.
  57777. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57778. * * 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.
  57779. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57780. * * 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
  57781. * * 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
  57782. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57787. * @param name defines the name of the mesh
  57788. * @param options defines the options used to create the mesh
  57789. * @param scene defines the hosting scene
  57790. * @returns the extruded shape mesh
  57791. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57793. */
  57794. static ExtrudeShape(name: string, options: {
  57795. shape: Vector3[];
  57796. path: Vector3[];
  57797. scale?: number;
  57798. rotation?: number;
  57799. cap?: number;
  57800. updatable?: boolean;
  57801. sideOrientation?: number;
  57802. frontUVs?: Vector4;
  57803. backUVs?: Vector4;
  57804. instance?: Mesh;
  57805. invertUV?: boolean;
  57806. }, scene?: Nullable<Scene>): Mesh;
  57807. /**
  57808. * Creates an custom extruded shape mesh.
  57809. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57810. * * 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.
  57811. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57812. * * 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
  57813. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57814. * * 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
  57815. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57816. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57817. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57818. * * 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
  57819. * * 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
  57820. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57825. * @param name defines the name of the mesh
  57826. * @param options defines the options used to create the mesh
  57827. * @param scene defines the hosting scene
  57828. * @returns the custom extruded shape mesh
  57829. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57830. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57832. */
  57833. static ExtrudeShapeCustom(name: string, options: {
  57834. shape: Vector3[];
  57835. path: Vector3[];
  57836. scaleFunction?: any;
  57837. rotationFunction?: any;
  57838. ribbonCloseArray?: boolean;
  57839. ribbonClosePath?: boolean;
  57840. cap?: number;
  57841. updatable?: boolean;
  57842. sideOrientation?: number;
  57843. frontUVs?: Vector4;
  57844. backUVs?: Vector4;
  57845. instance?: Mesh;
  57846. invertUV?: boolean;
  57847. }, scene?: Nullable<Scene>): Mesh;
  57848. /**
  57849. * Creates lathe mesh.
  57850. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57851. * * 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
  57852. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57853. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57854. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57855. * * 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
  57856. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57857. * * 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
  57858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57860. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57862. * @param name defines the name of the mesh
  57863. * @param options defines the options used to create the mesh
  57864. * @param scene defines the hosting scene
  57865. * @returns the lathe mesh
  57866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57867. */
  57868. static CreateLathe(name: string, options: {
  57869. shape: Vector3[];
  57870. radius?: number;
  57871. tessellation?: number;
  57872. clip?: number;
  57873. arc?: number;
  57874. closed?: boolean;
  57875. updatable?: boolean;
  57876. sideOrientation?: number;
  57877. frontUVs?: Vector4;
  57878. backUVs?: Vector4;
  57879. cap?: number;
  57880. invertUV?: boolean;
  57881. }, scene?: Nullable<Scene>): Mesh;
  57882. /**
  57883. * Creates a tiled plane mesh
  57884. * * You can set a limited pattern arrangement with the tiles
  57885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57888. * @param name defines the name of the mesh
  57889. * @param options defines the options used to create the mesh
  57890. * @param scene defines the hosting scene
  57891. * @returns the plane mesh
  57892. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57893. */
  57894. static CreateTiledPlane(name: string, options: {
  57895. pattern?: number;
  57896. tileSize?: number;
  57897. tileWidth?: number;
  57898. tileHeight?: number;
  57899. size?: number;
  57900. width?: number;
  57901. height?: number;
  57902. alignHorizontal?: number;
  57903. alignVertical?: number;
  57904. sideOrientation?: number;
  57905. frontUVs?: Vector4;
  57906. backUVs?: Vector4;
  57907. updatable?: boolean;
  57908. }, scene?: Nullable<Scene>): Mesh;
  57909. /**
  57910. * Creates a plane mesh
  57911. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57912. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57913. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57917. * @param name defines the name of the mesh
  57918. * @param options defines the options used to create the mesh
  57919. * @param scene defines the hosting scene
  57920. * @returns the plane mesh
  57921. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57922. */
  57923. static CreatePlane(name: string, options: {
  57924. size?: number;
  57925. width?: number;
  57926. height?: number;
  57927. sideOrientation?: number;
  57928. frontUVs?: Vector4;
  57929. backUVs?: Vector4;
  57930. updatable?: boolean;
  57931. sourcePlane?: Plane;
  57932. }, scene?: Nullable<Scene>): Mesh;
  57933. /**
  57934. * Creates a ground mesh
  57935. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57936. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57938. * @param name defines the name of the mesh
  57939. * @param options defines the options used to create the mesh
  57940. * @param scene defines the hosting scene
  57941. * @returns the ground mesh
  57942. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57943. */
  57944. static CreateGround(name: string, options: {
  57945. width?: number;
  57946. height?: number;
  57947. subdivisions?: number;
  57948. subdivisionsX?: number;
  57949. subdivisionsY?: number;
  57950. updatable?: boolean;
  57951. }, scene?: Nullable<Scene>): Mesh;
  57952. /**
  57953. * Creates a tiled ground mesh
  57954. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57955. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57956. * * 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
  57957. * * 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
  57958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57959. * @param name defines the name of the mesh
  57960. * @param options defines the options used to create the mesh
  57961. * @param scene defines the hosting scene
  57962. * @returns the tiled ground mesh
  57963. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57964. */
  57965. static CreateTiledGround(name: string, options: {
  57966. xmin: number;
  57967. zmin: number;
  57968. xmax: number;
  57969. zmax: number;
  57970. subdivisions?: {
  57971. w: number;
  57972. h: number;
  57973. };
  57974. precision?: {
  57975. w: number;
  57976. h: number;
  57977. };
  57978. updatable?: boolean;
  57979. }, scene?: Nullable<Scene>): Mesh;
  57980. /**
  57981. * Creates a ground mesh from a height map
  57982. * * The parameter `url` sets the URL of the height map image resource.
  57983. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57984. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57985. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57986. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57987. * * 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.
  57988. * * 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).
  57989. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57991. * @param name defines the name of the mesh
  57992. * @param url defines the url to the height map
  57993. * @param options defines the options used to create the mesh
  57994. * @param scene defines the hosting scene
  57995. * @returns the ground mesh
  57996. * @see https://doc.babylonjs.com/babylon101/height_map
  57997. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57998. */
  57999. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58000. width?: number;
  58001. height?: number;
  58002. subdivisions?: number;
  58003. minHeight?: number;
  58004. maxHeight?: number;
  58005. colorFilter?: Color3;
  58006. alphaFilter?: number;
  58007. updatable?: boolean;
  58008. onReady?: (mesh: GroundMesh) => void;
  58009. }, scene?: Nullable<Scene>): GroundMesh;
  58010. /**
  58011. * Creates a polygon mesh
  58012. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58013. * * 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
  58014. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58017. * * Remember you can only change the shape positions, not their number when updating a polygon
  58018. * @param name defines the name of the mesh
  58019. * @param options defines the options used to create the mesh
  58020. * @param scene defines the hosting scene
  58021. * @param earcutInjection can be used to inject your own earcut reference
  58022. * @returns the polygon mesh
  58023. */
  58024. static CreatePolygon(name: string, options: {
  58025. shape: Vector3[];
  58026. holes?: Vector3[][];
  58027. depth?: number;
  58028. faceUV?: Vector4[];
  58029. faceColors?: Color4[];
  58030. updatable?: boolean;
  58031. sideOrientation?: number;
  58032. frontUVs?: Vector4;
  58033. backUVs?: Vector4;
  58034. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58035. /**
  58036. * Creates an extruded polygon mesh, with depth in the Y direction.
  58037. * * 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)
  58038. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58039. * @param name defines the name of the mesh
  58040. * @param options defines the options used to create the mesh
  58041. * @param scene defines the hosting scene
  58042. * @param earcutInjection can be used to inject your own earcut reference
  58043. * @returns the polygon mesh
  58044. */
  58045. static ExtrudePolygon(name: string, options: {
  58046. shape: Vector3[];
  58047. holes?: Vector3[][];
  58048. depth?: number;
  58049. faceUV?: Vector4[];
  58050. faceColors?: Color4[];
  58051. updatable?: boolean;
  58052. sideOrientation?: number;
  58053. frontUVs?: Vector4;
  58054. backUVs?: Vector4;
  58055. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58056. /**
  58057. * Creates a tube mesh.
  58058. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58059. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58060. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58061. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58062. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58063. * * 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)
  58064. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58065. * * 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
  58066. * * 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
  58067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58069. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58071. * @param name defines the name of the mesh
  58072. * @param options defines the options used to create the mesh
  58073. * @param scene defines the hosting scene
  58074. * @returns the tube mesh
  58075. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58076. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58077. */
  58078. static CreateTube(name: string, options: {
  58079. path: Vector3[];
  58080. radius?: number;
  58081. tessellation?: number;
  58082. radiusFunction?: {
  58083. (i: number, distance: number): number;
  58084. };
  58085. cap?: number;
  58086. arc?: number;
  58087. updatable?: boolean;
  58088. sideOrientation?: number;
  58089. frontUVs?: Vector4;
  58090. backUVs?: Vector4;
  58091. instance?: Mesh;
  58092. invertUV?: boolean;
  58093. }, scene?: Nullable<Scene>): Mesh;
  58094. /**
  58095. * Creates a polyhedron mesh
  58096. * * 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
  58097. * * The parameter `size` (positive float, default 1) sets the polygon size
  58098. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58099. * * 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`
  58100. * * 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
  58101. * * 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)`)
  58102. * * 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
  58103. * * 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
  58104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58107. * @param name defines the name of the mesh
  58108. * @param options defines the options used to create the mesh
  58109. * @param scene defines the hosting scene
  58110. * @returns the polyhedron mesh
  58111. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58112. */
  58113. static CreatePolyhedron(name: string, options: {
  58114. type?: number;
  58115. size?: number;
  58116. sizeX?: number;
  58117. sizeY?: number;
  58118. sizeZ?: number;
  58119. custom?: any;
  58120. faceUV?: Vector4[];
  58121. faceColors?: Color4[];
  58122. flat?: boolean;
  58123. updatable?: boolean;
  58124. sideOrientation?: number;
  58125. frontUVs?: Vector4;
  58126. backUVs?: Vector4;
  58127. }, scene?: Nullable<Scene>): Mesh;
  58128. /**
  58129. * Creates a decal mesh.
  58130. * 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
  58131. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58132. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58133. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58134. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58135. * @param name defines the name of the mesh
  58136. * @param sourceMesh defines the mesh where the decal must be applied
  58137. * @param options defines the options used to create the mesh
  58138. * @param scene defines the hosting scene
  58139. * @returns the decal mesh
  58140. * @see https://doc.babylonjs.com/how_to/decals
  58141. */
  58142. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58143. position?: Vector3;
  58144. normal?: Vector3;
  58145. size?: Vector3;
  58146. angle?: number;
  58147. }): Mesh;
  58148. }
  58149. }
  58150. declare module "babylonjs/Meshes/meshSimplification" {
  58151. import { Mesh } from "babylonjs/Meshes/mesh";
  58152. /**
  58153. * A simplifier interface for future simplification implementations
  58154. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58155. */
  58156. export interface ISimplifier {
  58157. /**
  58158. * Simplification of a given mesh according to the given settings.
  58159. * Since this requires computation, it is assumed that the function runs async.
  58160. * @param settings The settings of the simplification, including quality and distance
  58161. * @param successCallback A callback that will be called after the mesh was simplified.
  58162. * @param errorCallback in case of an error, this callback will be called. optional.
  58163. */
  58164. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58165. }
  58166. /**
  58167. * Expected simplification settings.
  58168. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58169. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58170. */
  58171. export interface ISimplificationSettings {
  58172. /**
  58173. * Gets or sets the expected quality
  58174. */
  58175. quality: number;
  58176. /**
  58177. * Gets or sets the distance when this optimized version should be used
  58178. */
  58179. distance: number;
  58180. /**
  58181. * Gets an already optimized mesh
  58182. */
  58183. optimizeMesh?: boolean;
  58184. }
  58185. /**
  58186. * Class used to specify simplification options
  58187. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58188. */
  58189. export class SimplificationSettings implements ISimplificationSettings {
  58190. /** expected quality */
  58191. quality: number;
  58192. /** distance when this optimized version should be used */
  58193. distance: number;
  58194. /** already optimized mesh */
  58195. optimizeMesh?: boolean | undefined;
  58196. /**
  58197. * Creates a SimplificationSettings
  58198. * @param quality expected quality
  58199. * @param distance distance when this optimized version should be used
  58200. * @param optimizeMesh already optimized mesh
  58201. */
  58202. constructor(
  58203. /** expected quality */
  58204. quality: number,
  58205. /** distance when this optimized version should be used */
  58206. distance: number,
  58207. /** already optimized mesh */
  58208. optimizeMesh?: boolean | undefined);
  58209. }
  58210. /**
  58211. * Interface used to define a simplification task
  58212. */
  58213. export interface ISimplificationTask {
  58214. /**
  58215. * Array of settings
  58216. */
  58217. settings: Array<ISimplificationSettings>;
  58218. /**
  58219. * Simplification type
  58220. */
  58221. simplificationType: SimplificationType;
  58222. /**
  58223. * Mesh to simplify
  58224. */
  58225. mesh: Mesh;
  58226. /**
  58227. * Callback called on success
  58228. */
  58229. successCallback?: () => void;
  58230. /**
  58231. * Defines if parallel processing can be used
  58232. */
  58233. parallelProcessing: boolean;
  58234. }
  58235. /**
  58236. * Queue used to order the simplification tasks
  58237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58238. */
  58239. export class SimplificationQueue {
  58240. private _simplificationArray;
  58241. /**
  58242. * Gets a boolean indicating that the process is still running
  58243. */
  58244. running: boolean;
  58245. /**
  58246. * Creates a new queue
  58247. */
  58248. constructor();
  58249. /**
  58250. * Adds a new simplification task
  58251. * @param task defines a task to add
  58252. */
  58253. addTask(task: ISimplificationTask): void;
  58254. /**
  58255. * Execute next task
  58256. */
  58257. executeNext(): void;
  58258. /**
  58259. * Execute a simplification task
  58260. * @param task defines the task to run
  58261. */
  58262. runSimplification(task: ISimplificationTask): void;
  58263. private getSimplifier;
  58264. }
  58265. /**
  58266. * The implemented types of simplification
  58267. * At the moment only Quadratic Error Decimation is implemented
  58268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58269. */
  58270. export enum SimplificationType {
  58271. /** Quadratic error decimation */
  58272. QUADRATIC = 0
  58273. }
  58274. }
  58275. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58276. import { Scene } from "babylonjs/scene";
  58277. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58278. import { ISceneComponent } from "babylonjs/sceneComponent";
  58279. module "babylonjs/scene" {
  58280. interface Scene {
  58281. /** @hidden (Backing field) */
  58282. _simplificationQueue: SimplificationQueue;
  58283. /**
  58284. * Gets or sets the simplification queue attached to the scene
  58285. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58286. */
  58287. simplificationQueue: SimplificationQueue;
  58288. }
  58289. }
  58290. module "babylonjs/Meshes/mesh" {
  58291. interface Mesh {
  58292. /**
  58293. * Simplify the mesh according to the given array of settings.
  58294. * Function will return immediately and will simplify async
  58295. * @param settings a collection of simplification settings
  58296. * @param parallelProcessing should all levels calculate parallel or one after the other
  58297. * @param simplificationType the type of simplification to run
  58298. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58299. * @returns the current mesh
  58300. */
  58301. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58302. }
  58303. }
  58304. /**
  58305. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58306. * created in a scene
  58307. */
  58308. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58309. /**
  58310. * The component name helpfull to identify the component in the list of scene components.
  58311. */
  58312. readonly name: string;
  58313. /**
  58314. * The scene the component belongs to.
  58315. */
  58316. scene: Scene;
  58317. /**
  58318. * Creates a new instance of the component for the given scene
  58319. * @param scene Defines the scene to register the component in
  58320. */
  58321. constructor(scene: Scene);
  58322. /**
  58323. * Registers the component in a given scene
  58324. */
  58325. register(): void;
  58326. /**
  58327. * Rebuilds the elements related to this component in case of
  58328. * context lost for instance.
  58329. */
  58330. rebuild(): void;
  58331. /**
  58332. * Disposes the component and the associated ressources
  58333. */
  58334. dispose(): void;
  58335. private _beforeCameraUpdate;
  58336. }
  58337. }
  58338. declare module "babylonjs/Meshes/Builders/index" {
  58339. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58340. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58341. export * from "babylonjs/Meshes/Builders/discBuilder";
  58342. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58343. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58344. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58345. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58346. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58347. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58348. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58349. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58350. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58351. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58352. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58353. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58354. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58355. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58356. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58357. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58358. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58359. }
  58360. declare module "babylonjs/Meshes/index" {
  58361. export * from "babylonjs/Meshes/abstractMesh";
  58362. export * from "babylonjs/Meshes/buffer";
  58363. export * from "babylonjs/Meshes/Compression/index";
  58364. export * from "babylonjs/Meshes/csg";
  58365. export * from "babylonjs/Meshes/geometry";
  58366. export * from "babylonjs/Meshes/groundMesh";
  58367. export * from "babylonjs/Meshes/trailMesh";
  58368. export * from "babylonjs/Meshes/instancedMesh";
  58369. export * from "babylonjs/Meshes/linesMesh";
  58370. export * from "babylonjs/Meshes/mesh";
  58371. export * from "babylonjs/Meshes/mesh.vertexData";
  58372. export * from "babylonjs/Meshes/meshBuilder";
  58373. export * from "babylonjs/Meshes/meshSimplification";
  58374. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58375. export * from "babylonjs/Meshes/polygonMesh";
  58376. export * from "babylonjs/Meshes/subMesh";
  58377. export * from "babylonjs/Meshes/meshLODLevel";
  58378. export * from "babylonjs/Meshes/transformNode";
  58379. export * from "babylonjs/Meshes/Builders/index";
  58380. export * from "babylonjs/Meshes/dataBuffer";
  58381. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58382. }
  58383. declare module "babylonjs/Morph/index" {
  58384. export * from "babylonjs/Morph/morphTarget";
  58385. export * from "babylonjs/Morph/morphTargetManager";
  58386. }
  58387. declare module "babylonjs/Navigation/INavigationEngine" {
  58388. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58389. import { Vector3 } from "babylonjs/Maths/math";
  58390. import { Mesh } from "babylonjs/Meshes/mesh";
  58391. import { Scene } from "babylonjs/scene";
  58392. /**
  58393. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58394. */
  58395. export interface INavigationEnginePlugin {
  58396. /**
  58397. * plugin name
  58398. */
  58399. name: string;
  58400. /**
  58401. * Creates a navigation mesh
  58402. * @param meshes array of all the geometry used to compute the navigatio mesh
  58403. * @param parameters bunch of parameters used to filter geometry
  58404. */
  58405. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58406. /**
  58407. * Create a navigation mesh debug mesh
  58408. * @param scene is where the mesh will be added
  58409. * @returns debug display mesh
  58410. */
  58411. createDebugNavMesh(scene: Scene): Mesh;
  58412. /**
  58413. * Get a navigation mesh constrained position, closest to the parameter position
  58414. * @param position world position
  58415. * @returns the closest point to position constrained by the navigation mesh
  58416. */
  58417. getClosestPoint(position: Vector3): Vector3;
  58418. /**
  58419. * Get a navigation mesh constrained position, within a particular radius
  58420. * @param position world position
  58421. * @param maxRadius the maximum distance to the constrained world position
  58422. * @returns the closest point to position constrained by the navigation mesh
  58423. */
  58424. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58425. /**
  58426. * Compute the final position from a segment made of destination-position
  58427. * @param position world position
  58428. * @param destination world position
  58429. * @returns the resulting point along the navmesh
  58430. */
  58431. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58432. /**
  58433. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58434. * @param start world position
  58435. * @param end world position
  58436. * @returns array containing world position composing the path
  58437. */
  58438. computePath(start: Vector3, end: Vector3): Vector3[];
  58439. /**
  58440. * If this plugin is supported
  58441. * @returns true if plugin is supported
  58442. */
  58443. isSupported(): boolean;
  58444. /**
  58445. * Create a new Crowd so you can add agents
  58446. * @param maxAgents the maximum agent count in the crowd
  58447. * @param maxAgentRadius the maximum radius an agent can have
  58448. * @param scene to attach the crowd to
  58449. * @returns the crowd you can add agents to
  58450. */
  58451. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58452. /**
  58453. * Release all resources
  58454. */
  58455. dispose(): void;
  58456. }
  58457. /**
  58458. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58459. */
  58460. export interface ICrowd {
  58461. /**
  58462. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58463. * You can attach anything to that node. The node position is updated in the scene update tick.
  58464. * @param pos world position that will be constrained by the navigation mesh
  58465. * @param parameters agent parameters
  58466. * @param transform hooked to the agent that will be update by the scene
  58467. * @returns agent index
  58468. */
  58469. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58470. /**
  58471. * Returns the agent position in world space
  58472. * @param index agent index returned by addAgent
  58473. * @returns world space position
  58474. */
  58475. getAgentPosition(index: number): Vector3;
  58476. /**
  58477. * Gets the agent velocity in world space
  58478. * @param index agent index returned by addAgent
  58479. * @returns world space velocity
  58480. */
  58481. getAgentVelocity(index: number): Vector3;
  58482. /**
  58483. * remove a particular agent previously created
  58484. * @param index agent index returned by addAgent
  58485. */
  58486. removeAgent(index: number): void;
  58487. /**
  58488. * get the list of all agents attached to this crowd
  58489. * @returns list of agent indices
  58490. */
  58491. getAgents(): number[];
  58492. /**
  58493. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58494. * @param deltaTime in seconds
  58495. */
  58496. update(deltaTime: number): void;
  58497. /**
  58498. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58499. * @param index agent index returned by addAgent
  58500. * @param destination targeted world position
  58501. */
  58502. agentGoto(index: number, destination: Vector3): void;
  58503. /**
  58504. * Release all resources
  58505. */
  58506. dispose(): void;
  58507. }
  58508. /**
  58509. * Configures an agent
  58510. */
  58511. export interface IAgentParameters {
  58512. /**
  58513. * Agent radius. [Limit: >= 0]
  58514. */
  58515. radius: number;
  58516. /**
  58517. * Agent height. [Limit: > 0]
  58518. */
  58519. height: number;
  58520. /**
  58521. * Maximum allowed acceleration. [Limit: >= 0]
  58522. */
  58523. maxAcceleration: number;
  58524. /**
  58525. * Maximum allowed speed. [Limit: >= 0]
  58526. */
  58527. maxSpeed: number;
  58528. /**
  58529. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58530. */
  58531. collisionQueryRange: number;
  58532. /**
  58533. * The path visibility optimization range. [Limit: > 0]
  58534. */
  58535. pathOptimizationRange: number;
  58536. /**
  58537. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58538. */
  58539. separationWeight: number;
  58540. }
  58541. /**
  58542. * Configures the navigation mesh creation
  58543. */
  58544. export interface INavMeshParameters {
  58545. /**
  58546. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58547. */
  58548. cs: number;
  58549. /**
  58550. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58551. */
  58552. ch: number;
  58553. /**
  58554. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58555. */
  58556. walkableSlopeAngle: number;
  58557. /**
  58558. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58559. * be considered walkable. [Limit: >= 3] [Units: vx]
  58560. */
  58561. walkableHeight: number;
  58562. /**
  58563. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58564. */
  58565. walkableClimb: number;
  58566. /**
  58567. * The distance to erode/shrink the walkable area of the heightfield away from
  58568. * obstructions. [Limit: >=0] [Units: vx]
  58569. */
  58570. walkableRadius: number;
  58571. /**
  58572. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58573. */
  58574. maxEdgeLen: number;
  58575. /**
  58576. * The maximum distance a simplfied contour's border edges should deviate
  58577. * the original raw contour. [Limit: >=0] [Units: vx]
  58578. */
  58579. maxSimplificationError: number;
  58580. /**
  58581. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58582. */
  58583. minRegionArea: number;
  58584. /**
  58585. * Any regions with a span count smaller than this value will, if possible,
  58586. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58587. */
  58588. mergeRegionArea: number;
  58589. /**
  58590. * The maximum number of vertices allowed for polygons generated during the
  58591. * contour to polygon conversion process. [Limit: >= 3]
  58592. */
  58593. maxVertsPerPoly: number;
  58594. /**
  58595. * Sets the sampling distance to use when generating the detail mesh.
  58596. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58597. */
  58598. detailSampleDist: number;
  58599. /**
  58600. * The maximum distance the detail mesh surface should deviate from heightfield
  58601. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58602. */
  58603. detailSampleMaxError: number;
  58604. }
  58605. }
  58606. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58607. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58608. import { Mesh } from "babylonjs/Meshes/mesh";
  58609. import { Scene } from "babylonjs/scene";
  58610. import { Vector3 } from "babylonjs/Maths/math";
  58611. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58612. /**
  58613. * RecastJS navigation plugin
  58614. */
  58615. export class RecastJSPlugin implements INavigationEnginePlugin {
  58616. /**
  58617. * Reference to the Recast library
  58618. */
  58619. bjsRECAST: any;
  58620. /**
  58621. * plugin name
  58622. */
  58623. name: string;
  58624. /**
  58625. * the first navmesh created. We might extend this to support multiple navmeshes
  58626. */
  58627. navMesh: any;
  58628. /**
  58629. * Initializes the recastJS plugin
  58630. * @param recastInjection can be used to inject your own recast reference
  58631. */
  58632. constructor(recastInjection?: any);
  58633. /**
  58634. * Creates a navigation mesh
  58635. * @param meshes array of all the geometry used to compute the navigatio mesh
  58636. * @param parameters bunch of parameters used to filter geometry
  58637. */
  58638. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58639. /**
  58640. * Create a navigation mesh debug mesh
  58641. * @param scene is where the mesh will be added
  58642. * @returns debug display mesh
  58643. */
  58644. createDebugNavMesh(scene: Scene): Mesh;
  58645. /**
  58646. * Get a navigation mesh constrained position, closest to the parameter position
  58647. * @param position world position
  58648. * @returns the closest point to position constrained by the navigation mesh
  58649. */
  58650. getClosestPoint(position: Vector3): Vector3;
  58651. /**
  58652. * Get a navigation mesh constrained position, within a particular radius
  58653. * @param position world position
  58654. * @param maxRadius the maximum distance to the constrained world position
  58655. * @returns the closest point to position constrained by the navigation mesh
  58656. */
  58657. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58658. /**
  58659. * Compute the final position from a segment made of destination-position
  58660. * @param position world position
  58661. * @param destination world position
  58662. * @returns the resulting point along the navmesh
  58663. */
  58664. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58665. /**
  58666. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58667. * @param start world position
  58668. * @param end world position
  58669. * @returns array containing world position composing the path
  58670. */
  58671. computePath(start: Vector3, end: Vector3): Vector3[];
  58672. /**
  58673. * Create a new Crowd so you can add agents
  58674. * @param maxAgents the maximum agent count in the crowd
  58675. * @param maxAgentRadius the maximum radius an agent can have
  58676. * @param scene to attach the crowd to
  58677. * @returns the crowd you can add agents to
  58678. */
  58679. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58680. /**
  58681. * Disposes
  58682. */
  58683. dispose(): void;
  58684. /**
  58685. * If this plugin is supported
  58686. * @returns true if plugin is supported
  58687. */
  58688. isSupported(): boolean;
  58689. }
  58690. /**
  58691. * Recast detour crowd implementation
  58692. */
  58693. export class RecastJSCrowd implements ICrowd {
  58694. /**
  58695. * Recast/detour plugin
  58696. */
  58697. bjsRECASTPlugin: RecastJSPlugin;
  58698. /**
  58699. * Link to the detour crowd
  58700. */
  58701. recastCrowd: any;
  58702. /**
  58703. * One transform per agent
  58704. */
  58705. transforms: TransformNode[];
  58706. /**
  58707. * All agents created
  58708. */
  58709. agents: number[];
  58710. /**
  58711. * Link to the scene is kept to unregister the crowd from the scene
  58712. */
  58713. private _scene;
  58714. /**
  58715. * Observer for crowd updates
  58716. */
  58717. private _onBeforeAnimationsObserver;
  58718. /**
  58719. * Constructor
  58720. * @param plugin recastJS plugin
  58721. * @param maxAgents the maximum agent count in the crowd
  58722. * @param maxAgentRadius the maximum radius an agent can have
  58723. * @param scene to attach the crowd to
  58724. * @returns the crowd you can add agents to
  58725. */
  58726. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58727. /**
  58728. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58729. * You can attach anything to that node. The node position is updated in the scene update tick.
  58730. * @param pos world position that will be constrained by the navigation mesh
  58731. * @param parameters agent parameters
  58732. * @param transform hooked to the agent that will be update by the scene
  58733. * @returns agent index
  58734. */
  58735. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58736. /**
  58737. * Returns the agent position in world space
  58738. * @param index agent index returned by addAgent
  58739. * @returns world space position
  58740. */
  58741. getAgentPosition(index: number): Vector3;
  58742. /**
  58743. * Returns the agent velocity in world space
  58744. * @param index agent index returned by addAgent
  58745. * @returns world space velocity
  58746. */
  58747. getAgentVelocity(index: number): Vector3;
  58748. /**
  58749. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58750. * @param index agent index returned by addAgent
  58751. * @param destination targeted world position
  58752. */
  58753. agentGoto(index: number, destination: Vector3): void;
  58754. /**
  58755. * remove a particular agent previously created
  58756. * @param index agent index returned by addAgent
  58757. */
  58758. removeAgent(index: number): void;
  58759. /**
  58760. * get the list of all agents attached to this crowd
  58761. * @returns list of agent indices
  58762. */
  58763. getAgents(): number[];
  58764. /**
  58765. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58766. * @param deltaTime in seconds
  58767. */
  58768. update(deltaTime: number): void;
  58769. /**
  58770. * Release all resources
  58771. */
  58772. dispose(): void;
  58773. }
  58774. }
  58775. declare module "babylonjs/Navigation/Plugins/index" {
  58776. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58777. }
  58778. declare module "babylonjs/Navigation/index" {
  58779. export * from "babylonjs/Navigation/INavigationEngine";
  58780. export * from "babylonjs/Navigation/Plugins/index";
  58781. }
  58782. declare module "babylonjs/Offline/database" {
  58783. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58784. /**
  58785. * Class used to enable access to IndexedDB
  58786. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58787. */
  58788. export class Database implements IOfflineProvider {
  58789. private _callbackManifestChecked;
  58790. private _currentSceneUrl;
  58791. private _db;
  58792. private _enableSceneOffline;
  58793. private _enableTexturesOffline;
  58794. private _manifestVersionFound;
  58795. private _mustUpdateRessources;
  58796. private _hasReachedQuota;
  58797. private _isSupported;
  58798. private _idbFactory;
  58799. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58800. private static IsUASupportingBlobStorage;
  58801. /**
  58802. * Gets a boolean indicating if Database storate is enabled (off by default)
  58803. */
  58804. static IDBStorageEnabled: boolean;
  58805. /**
  58806. * Gets a boolean indicating if scene must be saved in the database
  58807. */
  58808. readonly enableSceneOffline: boolean;
  58809. /**
  58810. * Gets a boolean indicating if textures must be saved in the database
  58811. */
  58812. readonly enableTexturesOffline: boolean;
  58813. /**
  58814. * Creates a new Database
  58815. * @param urlToScene defines the url to load the scene
  58816. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58817. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58818. */
  58819. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58820. private static _ParseURL;
  58821. private static _ReturnFullUrlLocation;
  58822. private _checkManifestFile;
  58823. /**
  58824. * Open the database and make it available
  58825. * @param successCallback defines the callback to call on success
  58826. * @param errorCallback defines the callback to call on error
  58827. */
  58828. open(successCallback: () => void, errorCallback: () => void): void;
  58829. /**
  58830. * Loads an image from the database
  58831. * @param url defines the url to load from
  58832. * @param image defines the target DOM image
  58833. */
  58834. loadImage(url: string, image: HTMLImageElement): void;
  58835. private _loadImageFromDBAsync;
  58836. private _saveImageIntoDBAsync;
  58837. private _checkVersionFromDB;
  58838. private _loadVersionFromDBAsync;
  58839. private _saveVersionIntoDBAsync;
  58840. /**
  58841. * Loads a file from database
  58842. * @param url defines the URL to load from
  58843. * @param sceneLoaded defines a callback to call on success
  58844. * @param progressCallBack defines a callback to call when progress changed
  58845. * @param errorCallback defines a callback to call on error
  58846. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58847. */
  58848. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58849. private _loadFileAsync;
  58850. private _saveFileAsync;
  58851. /**
  58852. * Validates if xhr data is correct
  58853. * @param xhr defines the request to validate
  58854. * @param dataType defines the expected data type
  58855. * @returns true if data is correct
  58856. */
  58857. private static _ValidateXHRData;
  58858. }
  58859. }
  58860. declare module "babylonjs/Offline/index" {
  58861. export * from "babylonjs/Offline/database";
  58862. export * from "babylonjs/Offline/IOfflineProvider";
  58863. }
  58864. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58865. /** @hidden */
  58866. export var gpuUpdateParticlesPixelShader: {
  58867. name: string;
  58868. shader: string;
  58869. };
  58870. }
  58871. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58872. /** @hidden */
  58873. export var gpuUpdateParticlesVertexShader: {
  58874. name: string;
  58875. shader: string;
  58876. };
  58877. }
  58878. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58879. /** @hidden */
  58880. export var clipPlaneFragmentDeclaration2: {
  58881. name: string;
  58882. shader: string;
  58883. };
  58884. }
  58885. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58886. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58887. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58889. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58890. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58891. /** @hidden */
  58892. export var gpuRenderParticlesPixelShader: {
  58893. name: string;
  58894. shader: string;
  58895. };
  58896. }
  58897. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58898. /** @hidden */
  58899. export var clipPlaneVertexDeclaration2: {
  58900. name: string;
  58901. shader: string;
  58902. };
  58903. }
  58904. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58905. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58906. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58907. /** @hidden */
  58908. export var gpuRenderParticlesVertexShader: {
  58909. name: string;
  58910. shader: string;
  58911. };
  58912. }
  58913. declare module "babylonjs/Particles/gpuParticleSystem" {
  58914. import { Nullable } from "babylonjs/types";
  58915. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58916. import { Observable } from "babylonjs/Misc/observable";
  58917. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58918. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58919. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58920. import { Scene, IDisposable } from "babylonjs/scene";
  58921. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58922. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58923. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58924. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58925. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58926. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58927. /**
  58928. * This represents a GPU particle system in Babylon
  58929. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58930. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58931. */
  58932. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58933. /**
  58934. * The layer mask we are rendering the particles through.
  58935. */
  58936. layerMask: number;
  58937. private _capacity;
  58938. private _activeCount;
  58939. private _currentActiveCount;
  58940. private _accumulatedCount;
  58941. private _renderEffect;
  58942. private _updateEffect;
  58943. private _buffer0;
  58944. private _buffer1;
  58945. private _spriteBuffer;
  58946. private _updateVAO;
  58947. private _renderVAO;
  58948. private _targetIndex;
  58949. private _sourceBuffer;
  58950. private _targetBuffer;
  58951. private _engine;
  58952. private _currentRenderId;
  58953. private _started;
  58954. private _stopped;
  58955. private _timeDelta;
  58956. private _randomTexture;
  58957. private _randomTexture2;
  58958. private _attributesStrideSize;
  58959. private _updateEffectOptions;
  58960. private _randomTextureSize;
  58961. private _actualFrame;
  58962. private readonly _rawTextureWidth;
  58963. /**
  58964. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58965. */
  58966. static readonly IsSupported: boolean;
  58967. /**
  58968. * An event triggered when the system is disposed.
  58969. */
  58970. onDisposeObservable: Observable<GPUParticleSystem>;
  58971. /**
  58972. * Gets the maximum number of particles active at the same time.
  58973. * @returns The max number of active particles.
  58974. */
  58975. getCapacity(): number;
  58976. /**
  58977. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58978. * to override the particles.
  58979. */
  58980. forceDepthWrite: boolean;
  58981. /**
  58982. * Gets or set the number of active particles
  58983. */
  58984. activeParticleCount: number;
  58985. private _preWarmDone;
  58986. /**
  58987. * Is this system ready to be used/rendered
  58988. * @return true if the system is ready
  58989. */
  58990. isReady(): boolean;
  58991. /**
  58992. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58993. * @returns True if it has been started, otherwise false.
  58994. */
  58995. isStarted(): boolean;
  58996. /**
  58997. * Starts the particle system and begins to emit
  58998. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58999. */
  59000. start(delay?: number): void;
  59001. /**
  59002. * Stops the particle system.
  59003. */
  59004. stop(): void;
  59005. /**
  59006. * Remove all active particles
  59007. */
  59008. reset(): void;
  59009. /**
  59010. * Returns the string "GPUParticleSystem"
  59011. * @returns a string containing the class name
  59012. */
  59013. getClassName(): string;
  59014. private _colorGradientsTexture;
  59015. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59016. /**
  59017. * Adds a new color gradient
  59018. * @param gradient defines the gradient to use (between 0 and 1)
  59019. * @param color1 defines the color to affect to the specified gradient
  59020. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59021. * @returns the current particle system
  59022. */
  59023. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59024. /**
  59025. * Remove a specific color gradient
  59026. * @param gradient defines the gradient to remove
  59027. * @returns the current particle system
  59028. */
  59029. removeColorGradient(gradient: number): GPUParticleSystem;
  59030. private _angularSpeedGradientsTexture;
  59031. private _sizeGradientsTexture;
  59032. private _velocityGradientsTexture;
  59033. private _limitVelocityGradientsTexture;
  59034. private _dragGradientsTexture;
  59035. private _addFactorGradient;
  59036. /**
  59037. * Adds a new size gradient
  59038. * @param gradient defines the gradient to use (between 0 and 1)
  59039. * @param factor defines the size factor to affect to the specified gradient
  59040. * @returns the current particle system
  59041. */
  59042. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59043. /**
  59044. * Remove a specific size gradient
  59045. * @param gradient defines the gradient to remove
  59046. * @returns the current particle system
  59047. */
  59048. removeSizeGradient(gradient: number): GPUParticleSystem;
  59049. /**
  59050. * Adds a new angular speed gradient
  59051. * @param gradient defines the gradient to use (between 0 and 1)
  59052. * @param factor defines the angular speed to affect to the specified gradient
  59053. * @returns the current particle system
  59054. */
  59055. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59056. /**
  59057. * Remove a specific angular speed gradient
  59058. * @param gradient defines the gradient to remove
  59059. * @returns the current particle system
  59060. */
  59061. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59062. /**
  59063. * Adds a new velocity gradient
  59064. * @param gradient defines the gradient to use (between 0 and 1)
  59065. * @param factor defines the velocity to affect to the specified gradient
  59066. * @returns the current particle system
  59067. */
  59068. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59069. /**
  59070. * Remove a specific velocity gradient
  59071. * @param gradient defines the gradient to remove
  59072. * @returns the current particle system
  59073. */
  59074. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59075. /**
  59076. * Adds a new limit velocity gradient
  59077. * @param gradient defines the gradient to use (between 0 and 1)
  59078. * @param factor defines the limit velocity value to affect to the specified gradient
  59079. * @returns the current particle system
  59080. */
  59081. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59082. /**
  59083. * Remove a specific limit velocity gradient
  59084. * @param gradient defines the gradient to remove
  59085. * @returns the current particle system
  59086. */
  59087. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59088. /**
  59089. * Adds a new drag gradient
  59090. * @param gradient defines the gradient to use (between 0 and 1)
  59091. * @param factor defines the drag value to affect to the specified gradient
  59092. * @returns the current particle system
  59093. */
  59094. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59095. /**
  59096. * Remove a specific drag gradient
  59097. * @param gradient defines the gradient to remove
  59098. * @returns the current particle system
  59099. */
  59100. removeDragGradient(gradient: number): GPUParticleSystem;
  59101. /**
  59102. * Not supported by GPUParticleSystem
  59103. * @param gradient defines the gradient to use (between 0 and 1)
  59104. * @param factor defines the emit rate value to affect to the specified gradient
  59105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59106. * @returns the current particle system
  59107. */
  59108. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59109. /**
  59110. * Not supported by GPUParticleSystem
  59111. * @param gradient defines the gradient to remove
  59112. * @returns the current particle system
  59113. */
  59114. removeEmitRateGradient(gradient: number): IParticleSystem;
  59115. /**
  59116. * Not supported by GPUParticleSystem
  59117. * @param gradient defines the gradient to use (between 0 and 1)
  59118. * @param factor defines the start size value to affect to the specified gradient
  59119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59120. * @returns the current particle system
  59121. */
  59122. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59123. /**
  59124. * Not supported by GPUParticleSystem
  59125. * @param gradient defines the gradient to remove
  59126. * @returns the current particle system
  59127. */
  59128. removeStartSizeGradient(gradient: number): IParticleSystem;
  59129. /**
  59130. * Not supported by GPUParticleSystem
  59131. * @param gradient defines the gradient to use (between 0 and 1)
  59132. * @param min defines the color remap minimal range
  59133. * @param max defines the color remap maximal range
  59134. * @returns the current particle system
  59135. */
  59136. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59137. /**
  59138. * Not supported by GPUParticleSystem
  59139. * @param gradient defines the gradient to remove
  59140. * @returns the current particle system
  59141. */
  59142. removeColorRemapGradient(): IParticleSystem;
  59143. /**
  59144. * Not supported by GPUParticleSystem
  59145. * @param gradient defines the gradient to use (between 0 and 1)
  59146. * @param min defines the alpha remap minimal range
  59147. * @param max defines the alpha remap maximal range
  59148. * @returns the current particle system
  59149. */
  59150. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59151. /**
  59152. * Not supported by GPUParticleSystem
  59153. * @param gradient defines the gradient to remove
  59154. * @returns the current particle system
  59155. */
  59156. removeAlphaRemapGradient(): IParticleSystem;
  59157. /**
  59158. * Not supported by GPUParticleSystem
  59159. * @param gradient defines the gradient to use (between 0 and 1)
  59160. * @param color defines the color to affect to the specified gradient
  59161. * @returns the current particle system
  59162. */
  59163. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59164. /**
  59165. * Not supported by GPUParticleSystem
  59166. * @param gradient defines the gradient to remove
  59167. * @returns the current particle system
  59168. */
  59169. removeRampGradient(): IParticleSystem;
  59170. /**
  59171. * Not supported by GPUParticleSystem
  59172. * @returns the list of ramp gradients
  59173. */
  59174. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59175. /**
  59176. * Not supported by GPUParticleSystem
  59177. * Gets or sets a boolean indicating that ramp gradients must be used
  59178. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59179. */
  59180. useRampGradients: boolean;
  59181. /**
  59182. * Not supported by GPUParticleSystem
  59183. * @param gradient defines the gradient to use (between 0 and 1)
  59184. * @param factor defines the life time factor to affect to the specified gradient
  59185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59186. * @returns the current particle system
  59187. */
  59188. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59189. /**
  59190. * Not supported by GPUParticleSystem
  59191. * @param gradient defines the gradient to remove
  59192. * @returns the current particle system
  59193. */
  59194. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59195. /**
  59196. * Instantiates a GPU particle system.
  59197. * 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.
  59198. * @param name The name of the particle system
  59199. * @param options The options used to create the system
  59200. * @param scene The scene the particle system belongs to
  59201. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59202. */
  59203. constructor(name: string, options: Partial<{
  59204. capacity: number;
  59205. randomTextureSize: number;
  59206. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59207. protected _reset(): void;
  59208. private _createUpdateVAO;
  59209. private _createRenderVAO;
  59210. private _initialize;
  59211. /** @hidden */
  59212. _recreateUpdateEffect(): void;
  59213. /** @hidden */
  59214. _recreateRenderEffect(): void;
  59215. /**
  59216. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59217. * @param preWarm defines if we are in the pre-warmimg phase
  59218. */
  59219. animate(preWarm?: boolean): void;
  59220. private _createFactorGradientTexture;
  59221. private _createSizeGradientTexture;
  59222. private _createAngularSpeedGradientTexture;
  59223. private _createVelocityGradientTexture;
  59224. private _createLimitVelocityGradientTexture;
  59225. private _createDragGradientTexture;
  59226. private _createColorGradientTexture;
  59227. /**
  59228. * Renders the particle system in its current state
  59229. * @param preWarm defines if the system should only update the particles but not render them
  59230. * @returns the current number of particles
  59231. */
  59232. render(preWarm?: boolean): number;
  59233. /**
  59234. * Rebuilds the particle system
  59235. */
  59236. rebuild(): void;
  59237. private _releaseBuffers;
  59238. private _releaseVAOs;
  59239. /**
  59240. * Disposes the particle system and free the associated resources
  59241. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59242. */
  59243. dispose(disposeTexture?: boolean): void;
  59244. /**
  59245. * Clones the particle system.
  59246. * @param name The name of the cloned object
  59247. * @param newEmitter The new emitter to use
  59248. * @returns the cloned particle system
  59249. */
  59250. clone(name: string, newEmitter: any): GPUParticleSystem;
  59251. /**
  59252. * Serializes the particle system to a JSON object.
  59253. * @returns the JSON object
  59254. */
  59255. serialize(): any;
  59256. /**
  59257. * Parses a JSON object to create a GPU particle system.
  59258. * @param parsedParticleSystem The JSON object to parse
  59259. * @param scene The scene to create the particle system in
  59260. * @param rootUrl The root url to use to load external dependencies like texture
  59261. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59262. * @returns the parsed GPU particle system
  59263. */
  59264. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59265. }
  59266. }
  59267. declare module "babylonjs/Particles/particleSystemSet" {
  59268. import { Nullable } from "babylonjs/types";
  59269. import { Color3 } from "babylonjs/Maths/math.color";
  59270. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59272. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59273. import { Scene, IDisposable } from "babylonjs/scene";
  59274. /**
  59275. * Represents a set of particle systems working together to create a specific effect
  59276. */
  59277. export class ParticleSystemSet implements IDisposable {
  59278. private _emitterCreationOptions;
  59279. private _emitterNode;
  59280. /**
  59281. * Gets the particle system list
  59282. */
  59283. systems: IParticleSystem[];
  59284. /**
  59285. * Gets the emitter node used with this set
  59286. */
  59287. readonly emitterNode: Nullable<TransformNode>;
  59288. /**
  59289. * Creates a new emitter mesh as a sphere
  59290. * @param options defines the options used to create the sphere
  59291. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59292. * @param scene defines the hosting scene
  59293. */
  59294. setEmitterAsSphere(options: {
  59295. diameter: number;
  59296. segments: number;
  59297. color: Color3;
  59298. }, renderingGroupId: number, scene: Scene): void;
  59299. /**
  59300. * Starts all particle systems of the set
  59301. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59302. */
  59303. start(emitter?: AbstractMesh): void;
  59304. /**
  59305. * Release all associated resources
  59306. */
  59307. dispose(): void;
  59308. /**
  59309. * Serialize the set into a JSON compatible object
  59310. * @returns a JSON compatible representation of the set
  59311. */
  59312. serialize(): any;
  59313. /**
  59314. * Parse a new ParticleSystemSet from a serialized source
  59315. * @param data defines a JSON compatible representation of the set
  59316. * @param scene defines the hosting scene
  59317. * @param gpu defines if we want GPU particles or CPU particles
  59318. * @returns a new ParticleSystemSet
  59319. */
  59320. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59321. }
  59322. }
  59323. declare module "babylonjs/Particles/particleHelper" {
  59324. import { Nullable } from "babylonjs/types";
  59325. import { Scene } from "babylonjs/scene";
  59326. import { Vector3 } from "babylonjs/Maths/math.vector";
  59327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59328. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59329. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59330. /**
  59331. * This class is made for on one-liner static method to help creating particle system set.
  59332. */
  59333. export class ParticleHelper {
  59334. /**
  59335. * Gets or sets base Assets URL
  59336. */
  59337. static BaseAssetsUrl: string;
  59338. /**
  59339. * Create a default particle system that you can tweak
  59340. * @param emitter defines the emitter to use
  59341. * @param capacity defines the system capacity (default is 500 particles)
  59342. * @param scene defines the hosting scene
  59343. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59344. * @returns the new Particle system
  59345. */
  59346. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59347. /**
  59348. * This is the main static method (one-liner) of this helper to create different particle systems
  59349. * @param type This string represents the type to the particle system to create
  59350. * @param scene The scene where the particle system should live
  59351. * @param gpu If the system will use gpu
  59352. * @returns the ParticleSystemSet created
  59353. */
  59354. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59355. /**
  59356. * Static function used to export a particle system to a ParticleSystemSet variable.
  59357. * Please note that the emitter shape is not exported
  59358. * @param systems defines the particle systems to export
  59359. * @returns the created particle system set
  59360. */
  59361. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59362. }
  59363. }
  59364. declare module "babylonjs/Particles/particleSystemComponent" {
  59365. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59366. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59367. import "babylonjs/Shaders/particles.vertex";
  59368. module "babylonjs/Engines/engine" {
  59369. interface Engine {
  59370. /**
  59371. * Create an effect to use with particle systems.
  59372. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59373. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59374. * @param uniformsNames defines a list of attribute names
  59375. * @param samplers defines an array of string used to represent textures
  59376. * @param defines defines the string containing the defines to use to compile the shaders
  59377. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59378. * @param onCompiled defines a function to call when the effect creation is successful
  59379. * @param onError defines a function to call when the effect creation has failed
  59380. * @returns the new Effect
  59381. */
  59382. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59383. }
  59384. }
  59385. module "babylonjs/Meshes/mesh" {
  59386. interface Mesh {
  59387. /**
  59388. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59389. * @returns an array of IParticleSystem
  59390. */
  59391. getEmittedParticleSystems(): IParticleSystem[];
  59392. /**
  59393. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59394. * @returns an array of IParticleSystem
  59395. */
  59396. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59397. }
  59398. }
  59399. /**
  59400. * @hidden
  59401. */
  59402. export var _IDoNeedToBeInTheBuild: number;
  59403. }
  59404. declare module "babylonjs/Particles/index" {
  59405. export * from "babylonjs/Particles/baseParticleSystem";
  59406. export * from "babylonjs/Particles/EmitterTypes/index";
  59407. export * from "babylonjs/Particles/gpuParticleSystem";
  59408. export * from "babylonjs/Particles/IParticleSystem";
  59409. export * from "babylonjs/Particles/particle";
  59410. export * from "babylonjs/Particles/particleHelper";
  59411. export * from "babylonjs/Particles/particleSystem";
  59412. export * from "babylonjs/Particles/particleSystemComponent";
  59413. export * from "babylonjs/Particles/particleSystemSet";
  59414. export * from "babylonjs/Particles/solidParticle";
  59415. export * from "babylonjs/Particles/solidParticleSystem";
  59416. export * from "babylonjs/Particles/subEmitter";
  59417. }
  59418. declare module "babylonjs/Physics/physicsEngineComponent" {
  59419. import { Nullable } from "babylonjs/types";
  59420. import { Observable, Observer } from "babylonjs/Misc/observable";
  59421. import { Vector3 } from "babylonjs/Maths/math.vector";
  59422. import { Mesh } from "babylonjs/Meshes/mesh";
  59423. import { ISceneComponent } from "babylonjs/sceneComponent";
  59424. import { Scene } from "babylonjs/scene";
  59425. import { Node } from "babylonjs/node";
  59426. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59427. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59428. module "babylonjs/scene" {
  59429. interface Scene {
  59430. /** @hidden (Backing field) */
  59431. _physicsEngine: Nullable<IPhysicsEngine>;
  59432. /**
  59433. * Gets the current physics engine
  59434. * @returns a IPhysicsEngine or null if none attached
  59435. */
  59436. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59437. /**
  59438. * Enables physics to the current scene
  59439. * @param gravity defines the scene's gravity for the physics engine
  59440. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59441. * @return a boolean indicating if the physics engine was initialized
  59442. */
  59443. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59444. /**
  59445. * Disables and disposes the physics engine associated with the scene
  59446. */
  59447. disablePhysicsEngine(): void;
  59448. /**
  59449. * Gets a boolean indicating if there is an active physics engine
  59450. * @returns a boolean indicating if there is an active physics engine
  59451. */
  59452. isPhysicsEnabled(): boolean;
  59453. /**
  59454. * Deletes a physics compound impostor
  59455. * @param compound defines the compound to delete
  59456. */
  59457. deleteCompoundImpostor(compound: any): void;
  59458. /**
  59459. * An event triggered when physic simulation is about to be run
  59460. */
  59461. onBeforePhysicsObservable: Observable<Scene>;
  59462. /**
  59463. * An event triggered when physic simulation has been done
  59464. */
  59465. onAfterPhysicsObservable: Observable<Scene>;
  59466. }
  59467. }
  59468. module "babylonjs/Meshes/abstractMesh" {
  59469. interface AbstractMesh {
  59470. /** @hidden */
  59471. _physicsImpostor: Nullable<PhysicsImpostor>;
  59472. /**
  59473. * Gets or sets impostor used for physic simulation
  59474. * @see http://doc.babylonjs.com/features/physics_engine
  59475. */
  59476. physicsImpostor: Nullable<PhysicsImpostor>;
  59477. /**
  59478. * Gets the current physics impostor
  59479. * @see http://doc.babylonjs.com/features/physics_engine
  59480. * @returns a physics impostor or null
  59481. */
  59482. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59483. /** Apply a physic impulse to the mesh
  59484. * @param force defines the force to apply
  59485. * @param contactPoint defines where to apply the force
  59486. * @returns the current mesh
  59487. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59488. */
  59489. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59490. /**
  59491. * Creates a physic joint between two meshes
  59492. * @param otherMesh defines the other mesh to use
  59493. * @param pivot1 defines the pivot to use on this mesh
  59494. * @param pivot2 defines the pivot to use on the other mesh
  59495. * @param options defines additional options (can be plugin dependent)
  59496. * @returns the current mesh
  59497. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59498. */
  59499. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59500. /** @hidden */
  59501. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59502. }
  59503. }
  59504. /**
  59505. * Defines the physics engine scene component responsible to manage a physics engine
  59506. */
  59507. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59508. /**
  59509. * The component name helpful to identify the component in the list of scene components.
  59510. */
  59511. readonly name: string;
  59512. /**
  59513. * The scene the component belongs to.
  59514. */
  59515. scene: Scene;
  59516. /**
  59517. * Creates a new instance of the component for the given scene
  59518. * @param scene Defines the scene to register the component in
  59519. */
  59520. constructor(scene: Scene);
  59521. /**
  59522. * Registers the component in a given scene
  59523. */
  59524. register(): void;
  59525. /**
  59526. * Rebuilds the elements related to this component in case of
  59527. * context lost for instance.
  59528. */
  59529. rebuild(): void;
  59530. /**
  59531. * Disposes the component and the associated ressources
  59532. */
  59533. dispose(): void;
  59534. }
  59535. }
  59536. declare module "babylonjs/Physics/physicsHelper" {
  59537. import { Nullable } from "babylonjs/types";
  59538. import { Vector3 } from "babylonjs/Maths/math.vector";
  59539. import { Mesh } from "babylonjs/Meshes/mesh";
  59540. import { Scene } from "babylonjs/scene";
  59541. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59542. /**
  59543. * A helper for physics simulations
  59544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59545. */
  59546. export class PhysicsHelper {
  59547. private _scene;
  59548. private _physicsEngine;
  59549. /**
  59550. * Initializes the Physics helper
  59551. * @param scene Babylon.js scene
  59552. */
  59553. constructor(scene: Scene);
  59554. /**
  59555. * Applies a radial explosion impulse
  59556. * @param origin the origin of the explosion
  59557. * @param radiusOrEventOptions the radius or the options of radial explosion
  59558. * @param strength the explosion strength
  59559. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59560. * @returns A physics radial explosion event, or null
  59561. */
  59562. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59563. /**
  59564. * Applies a radial explosion force
  59565. * @param origin the origin of the explosion
  59566. * @param radiusOrEventOptions the radius or the options of radial explosion
  59567. * @param strength the explosion strength
  59568. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59569. * @returns A physics radial explosion event, or null
  59570. */
  59571. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59572. /**
  59573. * Creates a gravitational field
  59574. * @param origin the origin of the explosion
  59575. * @param radiusOrEventOptions the radius or the options of radial explosion
  59576. * @param strength the explosion strength
  59577. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59578. * @returns A physics gravitational field event, or null
  59579. */
  59580. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59581. /**
  59582. * Creates a physics updraft event
  59583. * @param origin the origin of the updraft
  59584. * @param radiusOrEventOptions the radius or the options of the updraft
  59585. * @param strength the strength of the updraft
  59586. * @param height the height of the updraft
  59587. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59588. * @returns A physics updraft event, or null
  59589. */
  59590. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59591. /**
  59592. * Creates a physics vortex event
  59593. * @param origin the of the vortex
  59594. * @param radiusOrEventOptions the radius or the options of the vortex
  59595. * @param strength the strength of the vortex
  59596. * @param height the height of the vortex
  59597. * @returns a Physics vortex event, or null
  59598. * A physics vortex event or null
  59599. */
  59600. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59601. }
  59602. /**
  59603. * Represents a physics radial explosion event
  59604. */
  59605. class PhysicsRadialExplosionEvent {
  59606. private _scene;
  59607. private _options;
  59608. private _sphere;
  59609. private _dataFetched;
  59610. /**
  59611. * Initializes a radial explosioin event
  59612. * @param _scene BabylonJS scene
  59613. * @param _options The options for the vortex event
  59614. */
  59615. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59616. /**
  59617. * Returns the data related to the radial explosion event (sphere).
  59618. * @returns The radial explosion event data
  59619. */
  59620. getData(): PhysicsRadialExplosionEventData;
  59621. /**
  59622. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59623. * @param impostor A physics imposter
  59624. * @param origin the origin of the explosion
  59625. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59626. */
  59627. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59628. /**
  59629. * Triggers affecterd impostors callbacks
  59630. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59631. */
  59632. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59633. /**
  59634. * Disposes the sphere.
  59635. * @param force Specifies if the sphere should be disposed by force
  59636. */
  59637. dispose(force?: boolean): void;
  59638. /*** Helpers ***/
  59639. private _prepareSphere;
  59640. private _intersectsWithSphere;
  59641. }
  59642. /**
  59643. * Represents a gravitational field event
  59644. */
  59645. class PhysicsGravitationalFieldEvent {
  59646. private _physicsHelper;
  59647. private _scene;
  59648. private _origin;
  59649. private _options;
  59650. private _tickCallback;
  59651. private _sphere;
  59652. private _dataFetched;
  59653. /**
  59654. * Initializes the physics gravitational field event
  59655. * @param _physicsHelper A physics helper
  59656. * @param _scene BabylonJS scene
  59657. * @param _origin The origin position of the gravitational field event
  59658. * @param _options The options for the vortex event
  59659. */
  59660. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59661. /**
  59662. * Returns the data related to the gravitational field event (sphere).
  59663. * @returns A gravitational field event
  59664. */
  59665. getData(): PhysicsGravitationalFieldEventData;
  59666. /**
  59667. * Enables the gravitational field.
  59668. */
  59669. enable(): void;
  59670. /**
  59671. * Disables the gravitational field.
  59672. */
  59673. disable(): void;
  59674. /**
  59675. * Disposes the sphere.
  59676. * @param force The force to dispose from the gravitational field event
  59677. */
  59678. dispose(force?: boolean): void;
  59679. private _tick;
  59680. }
  59681. /**
  59682. * Represents a physics updraft event
  59683. */
  59684. class PhysicsUpdraftEvent {
  59685. private _scene;
  59686. private _origin;
  59687. private _options;
  59688. private _physicsEngine;
  59689. private _originTop;
  59690. private _originDirection;
  59691. private _tickCallback;
  59692. private _cylinder;
  59693. private _cylinderPosition;
  59694. private _dataFetched;
  59695. /**
  59696. * Initializes the physics updraft event
  59697. * @param _scene BabylonJS scene
  59698. * @param _origin The origin position of the updraft
  59699. * @param _options The options for the updraft event
  59700. */
  59701. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59702. /**
  59703. * Returns the data related to the updraft event (cylinder).
  59704. * @returns A physics updraft event
  59705. */
  59706. getData(): PhysicsUpdraftEventData;
  59707. /**
  59708. * Enables the updraft.
  59709. */
  59710. enable(): void;
  59711. /**
  59712. * Disables the updraft.
  59713. */
  59714. disable(): void;
  59715. /**
  59716. * Disposes the cylinder.
  59717. * @param force Specifies if the updraft should be disposed by force
  59718. */
  59719. dispose(force?: boolean): void;
  59720. private getImpostorHitData;
  59721. private _tick;
  59722. /*** Helpers ***/
  59723. private _prepareCylinder;
  59724. private _intersectsWithCylinder;
  59725. }
  59726. /**
  59727. * Represents a physics vortex event
  59728. */
  59729. class PhysicsVortexEvent {
  59730. private _scene;
  59731. private _origin;
  59732. private _options;
  59733. private _physicsEngine;
  59734. private _originTop;
  59735. private _tickCallback;
  59736. private _cylinder;
  59737. private _cylinderPosition;
  59738. private _dataFetched;
  59739. /**
  59740. * Initializes the physics vortex event
  59741. * @param _scene The BabylonJS scene
  59742. * @param _origin The origin position of the vortex
  59743. * @param _options The options for the vortex event
  59744. */
  59745. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59746. /**
  59747. * Returns the data related to the vortex event (cylinder).
  59748. * @returns The physics vortex event data
  59749. */
  59750. getData(): PhysicsVortexEventData;
  59751. /**
  59752. * Enables the vortex.
  59753. */
  59754. enable(): void;
  59755. /**
  59756. * Disables the cortex.
  59757. */
  59758. disable(): void;
  59759. /**
  59760. * Disposes the sphere.
  59761. * @param force
  59762. */
  59763. dispose(force?: boolean): void;
  59764. private getImpostorHitData;
  59765. private _tick;
  59766. /*** Helpers ***/
  59767. private _prepareCylinder;
  59768. private _intersectsWithCylinder;
  59769. }
  59770. /**
  59771. * Options fot the radial explosion event
  59772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59773. */
  59774. export class PhysicsRadialExplosionEventOptions {
  59775. /**
  59776. * The radius of the sphere for the radial explosion.
  59777. */
  59778. radius: number;
  59779. /**
  59780. * The strenth of the explosion.
  59781. */
  59782. strength: number;
  59783. /**
  59784. * The strenght of the force in correspondence to the distance of the affected object
  59785. */
  59786. falloff: PhysicsRadialImpulseFalloff;
  59787. /**
  59788. * Sphere options for the radial explosion.
  59789. */
  59790. sphere: {
  59791. segments: number;
  59792. diameter: number;
  59793. };
  59794. /**
  59795. * Sphere options for the radial explosion.
  59796. */
  59797. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59798. }
  59799. /**
  59800. * Options fot the updraft event
  59801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59802. */
  59803. export class PhysicsUpdraftEventOptions {
  59804. /**
  59805. * The radius of the cylinder for the vortex
  59806. */
  59807. radius: number;
  59808. /**
  59809. * The strenth of the updraft.
  59810. */
  59811. strength: number;
  59812. /**
  59813. * The height of the cylinder for the updraft.
  59814. */
  59815. height: number;
  59816. /**
  59817. * The mode for the the updraft.
  59818. */
  59819. updraftMode: PhysicsUpdraftMode;
  59820. }
  59821. /**
  59822. * Options fot the vortex event
  59823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59824. */
  59825. export class PhysicsVortexEventOptions {
  59826. /**
  59827. * The radius of the cylinder for the vortex
  59828. */
  59829. radius: number;
  59830. /**
  59831. * The strenth of the vortex.
  59832. */
  59833. strength: number;
  59834. /**
  59835. * The height of the cylinder for the vortex.
  59836. */
  59837. height: number;
  59838. /**
  59839. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59840. */
  59841. centripetalForceThreshold: number;
  59842. /**
  59843. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59844. */
  59845. centripetalForceMultiplier: number;
  59846. /**
  59847. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59848. */
  59849. centrifugalForceMultiplier: number;
  59850. /**
  59851. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59852. */
  59853. updraftForceMultiplier: number;
  59854. }
  59855. /**
  59856. * The strenght of the force in correspondence to the distance of the affected object
  59857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59858. */
  59859. export enum PhysicsRadialImpulseFalloff {
  59860. /** Defines that impulse is constant in strength across it's whole radius */
  59861. Constant = 0,
  59862. /** Defines that impulse gets weaker if it's further from the origin */
  59863. Linear = 1
  59864. }
  59865. /**
  59866. * The strength of the force in correspondence to the distance of the affected object
  59867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59868. */
  59869. export enum PhysicsUpdraftMode {
  59870. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59871. Center = 0,
  59872. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59873. Perpendicular = 1
  59874. }
  59875. /**
  59876. * Interface for a physics hit data
  59877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59878. */
  59879. export interface PhysicsHitData {
  59880. /**
  59881. * The force applied at the contact point
  59882. */
  59883. force: Vector3;
  59884. /**
  59885. * The contact point
  59886. */
  59887. contactPoint: Vector3;
  59888. /**
  59889. * The distance from the origin to the contact point
  59890. */
  59891. distanceFromOrigin: number;
  59892. }
  59893. /**
  59894. * Interface for radial explosion event data
  59895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59896. */
  59897. export interface PhysicsRadialExplosionEventData {
  59898. /**
  59899. * A sphere used for the radial explosion event
  59900. */
  59901. sphere: Mesh;
  59902. }
  59903. /**
  59904. * Interface for gravitational field event data
  59905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59906. */
  59907. export interface PhysicsGravitationalFieldEventData {
  59908. /**
  59909. * A sphere mesh used for the gravitational field event
  59910. */
  59911. sphere: Mesh;
  59912. }
  59913. /**
  59914. * Interface for updraft event data
  59915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59916. */
  59917. export interface PhysicsUpdraftEventData {
  59918. /**
  59919. * A cylinder used for the updraft event
  59920. */
  59921. cylinder: Mesh;
  59922. }
  59923. /**
  59924. * Interface for vortex event data
  59925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59926. */
  59927. export interface PhysicsVortexEventData {
  59928. /**
  59929. * A cylinder used for the vortex event
  59930. */
  59931. cylinder: Mesh;
  59932. }
  59933. /**
  59934. * Interface for an affected physics impostor
  59935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59936. */
  59937. export interface PhysicsAffectedImpostorWithData {
  59938. /**
  59939. * The impostor affected by the effect
  59940. */
  59941. impostor: PhysicsImpostor;
  59942. /**
  59943. * The data about the hit/horce from the explosion
  59944. */
  59945. hitData: PhysicsHitData;
  59946. }
  59947. }
  59948. declare module "babylonjs/Physics/Plugins/index" {
  59949. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59950. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59951. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59952. }
  59953. declare module "babylonjs/Physics/index" {
  59954. export * from "babylonjs/Physics/IPhysicsEngine";
  59955. export * from "babylonjs/Physics/physicsEngine";
  59956. export * from "babylonjs/Physics/physicsEngineComponent";
  59957. export * from "babylonjs/Physics/physicsHelper";
  59958. export * from "babylonjs/Physics/physicsImpostor";
  59959. export * from "babylonjs/Physics/physicsJoint";
  59960. export * from "babylonjs/Physics/Plugins/index";
  59961. }
  59962. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59963. /** @hidden */
  59964. export var blackAndWhitePixelShader: {
  59965. name: string;
  59966. shader: string;
  59967. };
  59968. }
  59969. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59971. import { Camera } from "babylonjs/Cameras/camera";
  59972. import { Engine } from "babylonjs/Engines/engine";
  59973. import "babylonjs/Shaders/blackAndWhite.fragment";
  59974. /**
  59975. * Post process used to render in black and white
  59976. */
  59977. export class BlackAndWhitePostProcess extends PostProcess {
  59978. /**
  59979. * Linear about to convert he result to black and white (default: 1)
  59980. */
  59981. degree: number;
  59982. /**
  59983. * Creates a black and white post process
  59984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59985. * @param name The name of the effect.
  59986. * @param options The required width/height ratio to downsize to before computing the render pass.
  59987. * @param camera The camera to apply the render pass to.
  59988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59989. * @param engine The engine which the post process will be applied. (default: current engine)
  59990. * @param reusable If the post process can be reused on the same frame. (default: false)
  59991. */
  59992. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59993. }
  59994. }
  59995. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59996. import { Nullable } from "babylonjs/types";
  59997. import { Camera } from "babylonjs/Cameras/camera";
  59998. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59999. import { Engine } from "babylonjs/Engines/engine";
  60000. /**
  60001. * This represents a set of one or more post processes in Babylon.
  60002. * A post process can be used to apply a shader to a texture after it is rendered.
  60003. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60004. */
  60005. export class PostProcessRenderEffect {
  60006. private _postProcesses;
  60007. private _getPostProcesses;
  60008. private _singleInstance;
  60009. private _cameras;
  60010. private _indicesForCamera;
  60011. /**
  60012. * Name of the effect
  60013. * @hidden
  60014. */
  60015. _name: string;
  60016. /**
  60017. * Instantiates a post process render effect.
  60018. * A post process can be used to apply a shader to a texture after it is rendered.
  60019. * @param engine The engine the effect is tied to
  60020. * @param name The name of the effect
  60021. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60022. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60023. */
  60024. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60025. /**
  60026. * Checks if all the post processes in the effect are supported.
  60027. */
  60028. readonly isSupported: boolean;
  60029. /**
  60030. * Updates the current state of the effect
  60031. * @hidden
  60032. */
  60033. _update(): void;
  60034. /**
  60035. * Attaches the effect on cameras
  60036. * @param cameras The camera to attach to.
  60037. * @hidden
  60038. */
  60039. _attachCameras(cameras: Camera): void;
  60040. /**
  60041. * Attaches the effect on cameras
  60042. * @param cameras The camera to attach to.
  60043. * @hidden
  60044. */
  60045. _attachCameras(cameras: Camera[]): void;
  60046. /**
  60047. * Detaches the effect on cameras
  60048. * @param cameras The camera to detatch from.
  60049. * @hidden
  60050. */
  60051. _detachCameras(cameras: Camera): void;
  60052. /**
  60053. * Detatches the effect on cameras
  60054. * @param cameras The camera to detatch from.
  60055. * @hidden
  60056. */
  60057. _detachCameras(cameras: Camera[]): void;
  60058. /**
  60059. * Enables the effect on given cameras
  60060. * @param cameras The camera to enable.
  60061. * @hidden
  60062. */
  60063. _enable(cameras: Camera): void;
  60064. /**
  60065. * Enables the effect on given cameras
  60066. * @param cameras The camera to enable.
  60067. * @hidden
  60068. */
  60069. _enable(cameras: Nullable<Camera[]>): void;
  60070. /**
  60071. * Disables the effect on the given cameras
  60072. * @param cameras The camera to disable.
  60073. * @hidden
  60074. */
  60075. _disable(cameras: Camera): void;
  60076. /**
  60077. * Disables the effect on the given cameras
  60078. * @param cameras The camera to disable.
  60079. * @hidden
  60080. */
  60081. _disable(cameras: Nullable<Camera[]>): void;
  60082. /**
  60083. * Gets a list of the post processes contained in the effect.
  60084. * @param camera The camera to get the post processes on.
  60085. * @returns The list of the post processes in the effect.
  60086. */
  60087. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60088. }
  60089. }
  60090. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60091. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60092. /** @hidden */
  60093. export var extractHighlightsPixelShader: {
  60094. name: string;
  60095. shader: string;
  60096. };
  60097. }
  60098. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60099. import { Nullable } from "babylonjs/types";
  60100. import { Camera } from "babylonjs/Cameras/camera";
  60101. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60102. import { Engine } from "babylonjs/Engines/engine";
  60103. import "babylonjs/Shaders/extractHighlights.fragment";
  60104. /**
  60105. * 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.
  60106. */
  60107. export class ExtractHighlightsPostProcess extends PostProcess {
  60108. /**
  60109. * The luminance threshold, pixels below this value will be set to black.
  60110. */
  60111. threshold: number;
  60112. /** @hidden */
  60113. _exposure: number;
  60114. /**
  60115. * Post process which has the input texture to be used when performing highlight extraction
  60116. * @hidden
  60117. */
  60118. _inputPostProcess: Nullable<PostProcess>;
  60119. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60120. }
  60121. }
  60122. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60123. /** @hidden */
  60124. export var bloomMergePixelShader: {
  60125. name: string;
  60126. shader: string;
  60127. };
  60128. }
  60129. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60130. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60131. import { Nullable } from "babylonjs/types";
  60132. import { Engine } from "babylonjs/Engines/engine";
  60133. import { Camera } from "babylonjs/Cameras/camera";
  60134. import "babylonjs/Shaders/bloomMerge.fragment";
  60135. /**
  60136. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60137. */
  60138. export class BloomMergePostProcess extends PostProcess {
  60139. /** Weight of the bloom to be added to the original input. */
  60140. weight: number;
  60141. /**
  60142. * Creates a new instance of @see BloomMergePostProcess
  60143. * @param name The name of the effect.
  60144. * @param originalFromInput Post process which's input will be used for the merge.
  60145. * @param blurred Blurred highlights post process which's output will be used.
  60146. * @param weight Weight of the bloom to be added to the original input.
  60147. * @param options The required width/height ratio to downsize to before computing the render pass.
  60148. * @param camera The camera to apply the render pass to.
  60149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60150. * @param engine The engine which the post process will be applied. (default: current engine)
  60151. * @param reusable If the post process can be reused on the same frame. (default: false)
  60152. * @param textureType Type of textures used when performing the post process. (default: 0)
  60153. * @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)
  60154. */
  60155. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60156. /** Weight of the bloom to be added to the original input. */
  60157. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60158. }
  60159. }
  60160. declare module "babylonjs/PostProcesses/bloomEffect" {
  60161. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60163. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60164. import { Camera } from "babylonjs/Cameras/camera";
  60165. import { Scene } from "babylonjs/scene";
  60166. /**
  60167. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60168. */
  60169. export class BloomEffect extends PostProcessRenderEffect {
  60170. private bloomScale;
  60171. /**
  60172. * @hidden Internal
  60173. */
  60174. _effects: Array<PostProcess>;
  60175. /**
  60176. * @hidden Internal
  60177. */
  60178. _downscale: ExtractHighlightsPostProcess;
  60179. private _blurX;
  60180. private _blurY;
  60181. private _merge;
  60182. /**
  60183. * The luminance threshold to find bright areas of the image to bloom.
  60184. */
  60185. threshold: number;
  60186. /**
  60187. * The strength of the bloom.
  60188. */
  60189. weight: number;
  60190. /**
  60191. * Specifies the size of the bloom blur kernel, relative to the final output size
  60192. */
  60193. kernel: number;
  60194. /**
  60195. * Creates a new instance of @see BloomEffect
  60196. * @param scene The scene the effect belongs to.
  60197. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60198. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60199. * @param bloomWeight The the strength of bloom.
  60200. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60201. * @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)
  60202. */
  60203. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60204. /**
  60205. * Disposes each of the internal effects for a given camera.
  60206. * @param camera The camera to dispose the effect on.
  60207. */
  60208. disposeEffects(camera: Camera): void;
  60209. /**
  60210. * @hidden Internal
  60211. */
  60212. _updateEffects(): void;
  60213. /**
  60214. * Internal
  60215. * @returns if all the contained post processes are ready.
  60216. * @hidden
  60217. */
  60218. _isReady(): boolean;
  60219. }
  60220. }
  60221. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60222. /** @hidden */
  60223. export var chromaticAberrationPixelShader: {
  60224. name: string;
  60225. shader: string;
  60226. };
  60227. }
  60228. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60229. import { Vector2 } from "babylonjs/Maths/math.vector";
  60230. import { Nullable } from "babylonjs/types";
  60231. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60232. import { Camera } from "babylonjs/Cameras/camera";
  60233. import { Engine } from "babylonjs/Engines/engine";
  60234. import "babylonjs/Shaders/chromaticAberration.fragment";
  60235. /**
  60236. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60237. */
  60238. export class ChromaticAberrationPostProcess extends PostProcess {
  60239. /**
  60240. * The amount of seperation of rgb channels (default: 30)
  60241. */
  60242. aberrationAmount: number;
  60243. /**
  60244. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60245. */
  60246. radialIntensity: number;
  60247. /**
  60248. * 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))
  60249. */
  60250. direction: Vector2;
  60251. /**
  60252. * 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))
  60253. */
  60254. centerPosition: Vector2;
  60255. /**
  60256. * Creates a new instance ChromaticAberrationPostProcess
  60257. * @param name The name of the effect.
  60258. * @param screenWidth The width of the screen to apply the effect on.
  60259. * @param screenHeight The height of the screen to apply the effect on.
  60260. * @param options The required width/height ratio to downsize to before computing the render pass.
  60261. * @param camera The camera to apply the render pass to.
  60262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60263. * @param engine The engine which the post process will be applied. (default: current engine)
  60264. * @param reusable If the post process can be reused on the same frame. (default: false)
  60265. * @param textureType Type of textures used when performing the post process. (default: 0)
  60266. * @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)
  60267. */
  60268. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60269. }
  60270. }
  60271. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60272. /** @hidden */
  60273. export var circleOfConfusionPixelShader: {
  60274. name: string;
  60275. shader: string;
  60276. };
  60277. }
  60278. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60279. import { Nullable } from "babylonjs/types";
  60280. import { Engine } from "babylonjs/Engines/engine";
  60281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60282. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60283. import { Camera } from "babylonjs/Cameras/camera";
  60284. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60285. /**
  60286. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60287. */
  60288. export class CircleOfConfusionPostProcess extends PostProcess {
  60289. /**
  60290. * 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.
  60291. */
  60292. lensSize: number;
  60293. /**
  60294. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60295. */
  60296. fStop: number;
  60297. /**
  60298. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60299. */
  60300. focusDistance: number;
  60301. /**
  60302. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60303. */
  60304. focalLength: number;
  60305. private _depthTexture;
  60306. /**
  60307. * Creates a new instance CircleOfConfusionPostProcess
  60308. * @param name The name of the effect.
  60309. * @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.
  60310. * @param options The required width/height ratio to downsize to before computing the render pass.
  60311. * @param camera The camera to apply the render pass to.
  60312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60313. * @param engine The engine which the post process will be applied. (default: current engine)
  60314. * @param reusable If the post process can be reused on the same frame. (default: false)
  60315. * @param textureType Type of textures used when performing the post process. (default: 0)
  60316. * @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)
  60317. */
  60318. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60319. /**
  60320. * 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.
  60321. */
  60322. depthTexture: RenderTargetTexture;
  60323. }
  60324. }
  60325. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60326. /** @hidden */
  60327. export var colorCorrectionPixelShader: {
  60328. name: string;
  60329. shader: string;
  60330. };
  60331. }
  60332. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60334. import { Engine } from "babylonjs/Engines/engine";
  60335. import { Camera } from "babylonjs/Cameras/camera";
  60336. import "babylonjs/Shaders/colorCorrection.fragment";
  60337. /**
  60338. *
  60339. * This post-process allows the modification of rendered colors by using
  60340. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60341. *
  60342. * The object needs to be provided an url to a texture containing the color
  60343. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60344. * Use an image editing software to tweak the LUT to match your needs.
  60345. *
  60346. * For an example of a color LUT, see here:
  60347. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60348. * For explanations on color grading, see here:
  60349. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60350. *
  60351. */
  60352. export class ColorCorrectionPostProcess extends PostProcess {
  60353. private _colorTableTexture;
  60354. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60355. }
  60356. }
  60357. declare module "babylonjs/Shaders/convolution.fragment" {
  60358. /** @hidden */
  60359. export var convolutionPixelShader: {
  60360. name: string;
  60361. shader: string;
  60362. };
  60363. }
  60364. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60365. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60366. import { Nullable } from "babylonjs/types";
  60367. import { Camera } from "babylonjs/Cameras/camera";
  60368. import { Engine } from "babylonjs/Engines/engine";
  60369. import "babylonjs/Shaders/convolution.fragment";
  60370. /**
  60371. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60372. * input texture to perform effects such as edge detection or sharpening
  60373. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60374. */
  60375. export class ConvolutionPostProcess extends PostProcess {
  60376. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60377. kernel: number[];
  60378. /**
  60379. * Creates a new instance ConvolutionPostProcess
  60380. * @param name The name of the effect.
  60381. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60382. * @param options The required width/height ratio to downsize to before computing the render pass.
  60383. * @param camera The camera to apply the render pass to.
  60384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60385. * @param engine The engine which the post process will be applied. (default: current engine)
  60386. * @param reusable If the post process can be reused on the same frame. (default: false)
  60387. * @param textureType Type of textures used when performing the post process. (default: 0)
  60388. */
  60389. constructor(name: string,
  60390. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60391. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60392. /**
  60393. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60394. */
  60395. static EdgeDetect0Kernel: number[];
  60396. /**
  60397. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60398. */
  60399. static EdgeDetect1Kernel: number[];
  60400. /**
  60401. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60402. */
  60403. static EdgeDetect2Kernel: number[];
  60404. /**
  60405. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60406. */
  60407. static SharpenKernel: number[];
  60408. /**
  60409. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60410. */
  60411. static EmbossKernel: number[];
  60412. /**
  60413. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60414. */
  60415. static GaussianKernel: number[];
  60416. }
  60417. }
  60418. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60419. import { Nullable } from "babylonjs/types";
  60420. import { Vector2 } from "babylonjs/Maths/math.vector";
  60421. import { Camera } from "babylonjs/Cameras/camera";
  60422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60423. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60424. import { Engine } from "babylonjs/Engines/engine";
  60425. import { Scene } from "babylonjs/scene";
  60426. /**
  60427. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60428. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60429. * based on samples that have a large difference in distance than the center pixel.
  60430. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60431. */
  60432. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60433. direction: Vector2;
  60434. /**
  60435. * Creates a new instance CircleOfConfusionPostProcess
  60436. * @param name The name of the effect.
  60437. * @param scene The scene the effect belongs to.
  60438. * @param direction The direction the blur should be applied.
  60439. * @param kernel The size of the kernel used to blur.
  60440. * @param options The required width/height ratio to downsize to before computing the render pass.
  60441. * @param camera The camera to apply the render pass to.
  60442. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60443. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60445. * @param engine The engine which the post process will be applied. (default: current engine)
  60446. * @param reusable If the post process can be reused on the same frame. (default: false)
  60447. * @param textureType Type of textures used when performing the post process. (default: 0)
  60448. * @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)
  60449. */
  60450. 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);
  60451. }
  60452. }
  60453. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60454. /** @hidden */
  60455. export var depthOfFieldMergePixelShader: {
  60456. name: string;
  60457. shader: string;
  60458. };
  60459. }
  60460. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60461. import { Nullable } from "babylonjs/types";
  60462. import { Camera } from "babylonjs/Cameras/camera";
  60463. import { Effect } from "babylonjs/Materials/effect";
  60464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60465. import { Engine } from "babylonjs/Engines/engine";
  60466. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60467. /**
  60468. * Options to be set when merging outputs from the default pipeline.
  60469. */
  60470. export class DepthOfFieldMergePostProcessOptions {
  60471. /**
  60472. * The original image to merge on top of
  60473. */
  60474. originalFromInput: PostProcess;
  60475. /**
  60476. * Parameters to perform the merge of the depth of field effect
  60477. */
  60478. depthOfField?: {
  60479. circleOfConfusion: PostProcess;
  60480. blurSteps: Array<PostProcess>;
  60481. };
  60482. /**
  60483. * Parameters to perform the merge of bloom effect
  60484. */
  60485. bloom?: {
  60486. blurred: PostProcess;
  60487. weight: number;
  60488. };
  60489. }
  60490. /**
  60491. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60492. */
  60493. export class DepthOfFieldMergePostProcess extends PostProcess {
  60494. private blurSteps;
  60495. /**
  60496. * Creates a new instance of DepthOfFieldMergePostProcess
  60497. * @param name The name of the effect.
  60498. * @param originalFromInput Post process which's input will be used for the merge.
  60499. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60500. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60501. * @param options The required width/height ratio to downsize to before computing the render pass.
  60502. * @param camera The camera to apply the render pass to.
  60503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60504. * @param engine The engine which the post process will be applied. (default: current engine)
  60505. * @param reusable If the post process can be reused on the same frame. (default: false)
  60506. * @param textureType Type of textures used when performing the post process. (default: 0)
  60507. * @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)
  60508. */
  60509. 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);
  60510. /**
  60511. * Updates the effect with the current post process compile time values and recompiles the shader.
  60512. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60513. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60514. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60515. * @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
  60516. * @param onCompiled Called when the shader has been compiled.
  60517. * @param onError Called if there is an error when compiling a shader.
  60518. */
  60519. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60520. }
  60521. }
  60522. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60523. import { Nullable } from "babylonjs/types";
  60524. import { Camera } from "babylonjs/Cameras/camera";
  60525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60526. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60527. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60528. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60529. import { Scene } from "babylonjs/scene";
  60530. /**
  60531. * Specifies the level of max blur that should be applied when using the depth of field effect
  60532. */
  60533. export enum DepthOfFieldEffectBlurLevel {
  60534. /**
  60535. * Subtle blur
  60536. */
  60537. Low = 0,
  60538. /**
  60539. * Medium blur
  60540. */
  60541. Medium = 1,
  60542. /**
  60543. * Large blur
  60544. */
  60545. High = 2
  60546. }
  60547. /**
  60548. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60549. */
  60550. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60551. private _circleOfConfusion;
  60552. /**
  60553. * @hidden Internal, blurs from high to low
  60554. */
  60555. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60556. private _depthOfFieldBlurY;
  60557. private _dofMerge;
  60558. /**
  60559. * @hidden Internal post processes in depth of field effect
  60560. */
  60561. _effects: Array<PostProcess>;
  60562. /**
  60563. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60564. */
  60565. focalLength: number;
  60566. /**
  60567. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60568. */
  60569. fStop: number;
  60570. /**
  60571. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60572. */
  60573. focusDistance: number;
  60574. /**
  60575. * 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.
  60576. */
  60577. lensSize: number;
  60578. /**
  60579. * Creates a new instance DepthOfFieldEffect
  60580. * @param scene The scene the effect belongs to.
  60581. * @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.
  60582. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60583. * @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)
  60584. */
  60585. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60586. /**
  60587. * Get the current class name of the current effet
  60588. * @returns "DepthOfFieldEffect"
  60589. */
  60590. getClassName(): string;
  60591. /**
  60592. * 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.
  60593. */
  60594. depthTexture: RenderTargetTexture;
  60595. /**
  60596. * Disposes each of the internal effects for a given camera.
  60597. * @param camera The camera to dispose the effect on.
  60598. */
  60599. disposeEffects(camera: Camera): void;
  60600. /**
  60601. * @hidden Internal
  60602. */
  60603. _updateEffects(): void;
  60604. /**
  60605. * Internal
  60606. * @returns if all the contained post processes are ready.
  60607. * @hidden
  60608. */
  60609. _isReady(): boolean;
  60610. }
  60611. }
  60612. declare module "babylonjs/Shaders/displayPass.fragment" {
  60613. /** @hidden */
  60614. export var displayPassPixelShader: {
  60615. name: string;
  60616. shader: string;
  60617. };
  60618. }
  60619. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60620. import { Nullable } from "babylonjs/types";
  60621. import { Camera } from "babylonjs/Cameras/camera";
  60622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60623. import { Engine } from "babylonjs/Engines/engine";
  60624. import "babylonjs/Shaders/displayPass.fragment";
  60625. /**
  60626. * DisplayPassPostProcess which produces an output the same as it's input
  60627. */
  60628. export class DisplayPassPostProcess extends PostProcess {
  60629. /**
  60630. * Creates the DisplayPassPostProcess
  60631. * @param name The name of the effect.
  60632. * @param options The required width/height ratio to downsize to before computing the render pass.
  60633. * @param camera The camera to apply the render pass to.
  60634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60635. * @param engine The engine which the post process will be applied. (default: current engine)
  60636. * @param reusable If the post process can be reused on the same frame. (default: false)
  60637. */
  60638. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60639. }
  60640. }
  60641. declare module "babylonjs/Shaders/filter.fragment" {
  60642. /** @hidden */
  60643. export var filterPixelShader: {
  60644. name: string;
  60645. shader: string;
  60646. };
  60647. }
  60648. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60649. import { Nullable } from "babylonjs/types";
  60650. import { Matrix } from "babylonjs/Maths/math.vector";
  60651. import { Camera } from "babylonjs/Cameras/camera";
  60652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60653. import { Engine } from "babylonjs/Engines/engine";
  60654. import "babylonjs/Shaders/filter.fragment";
  60655. /**
  60656. * Applies a kernel filter to the image
  60657. */
  60658. export class FilterPostProcess extends PostProcess {
  60659. /** The matrix to be applied to the image */
  60660. kernelMatrix: Matrix;
  60661. /**
  60662. *
  60663. * @param name The name of the effect.
  60664. * @param kernelMatrix The matrix to be applied to the image
  60665. * @param options The required width/height ratio to downsize to before computing the render pass.
  60666. * @param camera The camera to apply the render pass to.
  60667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60668. * @param engine The engine which the post process will be applied. (default: current engine)
  60669. * @param reusable If the post process can be reused on the same frame. (default: false)
  60670. */
  60671. constructor(name: string,
  60672. /** The matrix to be applied to the image */
  60673. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60674. }
  60675. }
  60676. declare module "babylonjs/Shaders/fxaa.fragment" {
  60677. /** @hidden */
  60678. export var fxaaPixelShader: {
  60679. name: string;
  60680. shader: string;
  60681. };
  60682. }
  60683. declare module "babylonjs/Shaders/fxaa.vertex" {
  60684. /** @hidden */
  60685. export var fxaaVertexShader: {
  60686. name: string;
  60687. shader: string;
  60688. };
  60689. }
  60690. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60691. import { Nullable } from "babylonjs/types";
  60692. import { Camera } from "babylonjs/Cameras/camera";
  60693. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60694. import { Engine } from "babylonjs/Engines/engine";
  60695. import "babylonjs/Shaders/fxaa.fragment";
  60696. import "babylonjs/Shaders/fxaa.vertex";
  60697. /**
  60698. * Fxaa post process
  60699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60700. */
  60701. export class FxaaPostProcess extends PostProcess {
  60702. /** @hidden */
  60703. texelWidth: number;
  60704. /** @hidden */
  60705. texelHeight: number;
  60706. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60707. private _getDefines;
  60708. }
  60709. }
  60710. declare module "babylonjs/Shaders/grain.fragment" {
  60711. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60712. /** @hidden */
  60713. export var grainPixelShader: {
  60714. name: string;
  60715. shader: string;
  60716. };
  60717. }
  60718. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60719. import { Nullable } from "babylonjs/types";
  60720. import { Camera } from "babylonjs/Cameras/camera";
  60721. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60722. import { Engine } from "babylonjs/Engines/engine";
  60723. import "babylonjs/Shaders/grain.fragment";
  60724. /**
  60725. * The GrainPostProcess adds noise to the image at mid luminance levels
  60726. */
  60727. export class GrainPostProcess extends PostProcess {
  60728. /**
  60729. * The intensity of the grain added (default: 30)
  60730. */
  60731. intensity: number;
  60732. /**
  60733. * If the grain should be randomized on every frame
  60734. */
  60735. animated: boolean;
  60736. /**
  60737. * Creates a new instance of @see GrainPostProcess
  60738. * @param name The name of the effect.
  60739. * @param options The required width/height ratio to downsize to before computing the render pass.
  60740. * @param camera The camera to apply the render pass to.
  60741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60742. * @param engine The engine which the post process will be applied. (default: current engine)
  60743. * @param reusable If the post process can be reused on the same frame. (default: false)
  60744. * @param textureType Type of textures used when performing the post process. (default: 0)
  60745. * @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)
  60746. */
  60747. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60748. }
  60749. }
  60750. declare module "babylonjs/Shaders/highlights.fragment" {
  60751. /** @hidden */
  60752. export var highlightsPixelShader: {
  60753. name: string;
  60754. shader: string;
  60755. };
  60756. }
  60757. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60758. import { Nullable } from "babylonjs/types";
  60759. import { Camera } from "babylonjs/Cameras/camera";
  60760. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60761. import { Engine } from "babylonjs/Engines/engine";
  60762. import "babylonjs/Shaders/highlights.fragment";
  60763. /**
  60764. * Extracts highlights from the image
  60765. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60766. */
  60767. export class HighlightsPostProcess extends PostProcess {
  60768. /**
  60769. * Extracts highlights from the image
  60770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60771. * @param name The name of the effect.
  60772. * @param options The required width/height ratio to downsize to before computing the render pass.
  60773. * @param camera The camera to apply the render pass to.
  60774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60775. * @param engine The engine which the post process will be applied. (default: current engine)
  60776. * @param reusable If the post process can be reused on the same frame. (default: false)
  60777. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60778. */
  60779. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60780. }
  60781. }
  60782. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60783. /** @hidden */
  60784. export var mrtFragmentDeclaration: {
  60785. name: string;
  60786. shader: string;
  60787. };
  60788. }
  60789. declare module "babylonjs/Shaders/geometry.fragment" {
  60790. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60791. /** @hidden */
  60792. export var geometryPixelShader: {
  60793. name: string;
  60794. shader: string;
  60795. };
  60796. }
  60797. declare module "babylonjs/Shaders/geometry.vertex" {
  60798. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60799. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60800. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60801. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60802. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60803. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60804. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60805. /** @hidden */
  60806. export var geometryVertexShader: {
  60807. name: string;
  60808. shader: string;
  60809. };
  60810. }
  60811. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60812. import { Matrix } from "babylonjs/Maths/math.vector";
  60813. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60814. import { Mesh } from "babylonjs/Meshes/mesh";
  60815. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60816. import { Effect } from "babylonjs/Materials/effect";
  60817. import { Scene } from "babylonjs/scene";
  60818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60819. import "babylonjs/Shaders/geometry.fragment";
  60820. import "babylonjs/Shaders/geometry.vertex";
  60821. /** @hidden */
  60822. interface ISavedTransformationMatrix {
  60823. world: Matrix;
  60824. viewProjection: Matrix;
  60825. }
  60826. /**
  60827. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60828. */
  60829. export class GeometryBufferRenderer {
  60830. /**
  60831. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60832. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60833. */
  60834. static readonly POSITION_TEXTURE_TYPE: number;
  60835. /**
  60836. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60837. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60838. */
  60839. static readonly VELOCITY_TEXTURE_TYPE: number;
  60840. /**
  60841. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60842. * in order to compute objects velocities when enableVelocity is set to "true"
  60843. * @hidden
  60844. */
  60845. _previousTransformationMatrices: {
  60846. [index: number]: ISavedTransformationMatrix;
  60847. };
  60848. /**
  60849. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60850. * in order to compute objects velocities when enableVelocity is set to "true"
  60851. * @hidden
  60852. */
  60853. _previousBonesTransformationMatrices: {
  60854. [index: number]: Float32Array;
  60855. };
  60856. /**
  60857. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60858. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60859. */
  60860. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60861. private _scene;
  60862. private _multiRenderTarget;
  60863. private _ratio;
  60864. private _enablePosition;
  60865. private _enableVelocity;
  60866. private _positionIndex;
  60867. private _velocityIndex;
  60868. protected _effect: Effect;
  60869. protected _cachedDefines: string;
  60870. /**
  60871. * Set the render list (meshes to be rendered) used in the G buffer.
  60872. */
  60873. renderList: Mesh[];
  60874. /**
  60875. * Gets wether or not G buffer are supported by the running hardware.
  60876. * This requires draw buffer supports
  60877. */
  60878. readonly isSupported: boolean;
  60879. /**
  60880. * Returns the index of the given texture type in the G-Buffer textures array
  60881. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60882. * @returns the index of the given texture type in the G-Buffer textures array
  60883. */
  60884. getTextureIndex(textureType: number): number;
  60885. /**
  60886. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60887. */
  60888. /**
  60889. * Sets whether or not objects positions are enabled for the G buffer.
  60890. */
  60891. enablePosition: boolean;
  60892. /**
  60893. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60894. */
  60895. /**
  60896. * Sets wether or not objects velocities are enabled for the G buffer.
  60897. */
  60898. enableVelocity: boolean;
  60899. /**
  60900. * Gets the scene associated with the buffer.
  60901. */
  60902. readonly scene: Scene;
  60903. /**
  60904. * Gets the ratio used by the buffer during its creation.
  60905. * How big is the buffer related to the main canvas.
  60906. */
  60907. readonly ratio: number;
  60908. /** @hidden */
  60909. static _SceneComponentInitialization: (scene: Scene) => void;
  60910. /**
  60911. * Creates a new G Buffer for the scene
  60912. * @param scene The scene the buffer belongs to
  60913. * @param ratio How big is the buffer related to the main canvas.
  60914. */
  60915. constructor(scene: Scene, ratio?: number);
  60916. /**
  60917. * Checks wether everything is ready to render a submesh to the G buffer.
  60918. * @param subMesh the submesh to check readiness for
  60919. * @param useInstances is the mesh drawn using instance or not
  60920. * @returns true if ready otherwise false
  60921. */
  60922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60923. /**
  60924. * Gets the current underlying G Buffer.
  60925. * @returns the buffer
  60926. */
  60927. getGBuffer(): MultiRenderTarget;
  60928. /**
  60929. * Gets the number of samples used to render the buffer (anti aliasing).
  60930. */
  60931. /**
  60932. * Sets the number of samples used to render the buffer (anti aliasing).
  60933. */
  60934. samples: number;
  60935. /**
  60936. * Disposes the renderer and frees up associated resources.
  60937. */
  60938. dispose(): void;
  60939. protected _createRenderTargets(): void;
  60940. private _copyBonesTransformationMatrices;
  60941. }
  60942. }
  60943. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60944. import { Nullable } from "babylonjs/types";
  60945. import { Scene } from "babylonjs/scene";
  60946. import { ISceneComponent } from "babylonjs/sceneComponent";
  60947. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60948. module "babylonjs/scene" {
  60949. interface Scene {
  60950. /** @hidden (Backing field) */
  60951. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60952. /**
  60953. * Gets or Sets the current geometry buffer associated to the scene.
  60954. */
  60955. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60956. /**
  60957. * Enables a GeometryBufferRender and associates it with the scene
  60958. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60959. * @returns the GeometryBufferRenderer
  60960. */
  60961. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60962. /**
  60963. * Disables the GeometryBufferRender associated with the scene
  60964. */
  60965. disableGeometryBufferRenderer(): void;
  60966. }
  60967. }
  60968. /**
  60969. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60970. * in several rendering techniques.
  60971. */
  60972. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60973. /**
  60974. * The component name helpful to identify the component in the list of scene components.
  60975. */
  60976. readonly name: string;
  60977. /**
  60978. * The scene the component belongs to.
  60979. */
  60980. scene: Scene;
  60981. /**
  60982. * Creates a new instance of the component for the given scene
  60983. * @param scene Defines the scene to register the component in
  60984. */
  60985. constructor(scene: Scene);
  60986. /**
  60987. * Registers the component in a given scene
  60988. */
  60989. register(): void;
  60990. /**
  60991. * Rebuilds the elements related to this component in case of
  60992. * context lost for instance.
  60993. */
  60994. rebuild(): void;
  60995. /**
  60996. * Disposes the component and the associated ressources
  60997. */
  60998. dispose(): void;
  60999. private _gatherRenderTargets;
  61000. }
  61001. }
  61002. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61003. /** @hidden */
  61004. export var motionBlurPixelShader: {
  61005. name: string;
  61006. shader: string;
  61007. };
  61008. }
  61009. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61010. import { Nullable } from "babylonjs/types";
  61011. import { Camera } from "babylonjs/Cameras/camera";
  61012. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61013. import { Scene } from "babylonjs/scene";
  61014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61015. import "babylonjs/Animations/animatable";
  61016. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61017. import "babylonjs/Shaders/motionBlur.fragment";
  61018. import { Engine } from "babylonjs/Engines/engine";
  61019. /**
  61020. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61021. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61022. * As an example, all you have to do is to create the post-process:
  61023. * var mb = new BABYLON.MotionBlurPostProcess(
  61024. * 'mb', // The name of the effect.
  61025. * scene, // The scene containing the objects to blur according to their velocity.
  61026. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61027. * camera // The camera to apply the render pass to.
  61028. * );
  61029. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61030. */
  61031. export class MotionBlurPostProcess extends PostProcess {
  61032. /**
  61033. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61034. */
  61035. motionStrength: number;
  61036. /**
  61037. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61038. */
  61039. /**
  61040. * Sets the number of iterations to be used for motion blur quality
  61041. */
  61042. motionBlurSamples: number;
  61043. private _motionBlurSamples;
  61044. private _geometryBufferRenderer;
  61045. /**
  61046. * Creates a new instance MotionBlurPostProcess
  61047. * @param name The name of the effect.
  61048. * @param scene The scene containing the objects to blur according to their velocity.
  61049. * @param options The required width/height ratio to downsize to before computing the render pass.
  61050. * @param camera The camera to apply the render pass to.
  61051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61052. * @param engine The engine which the post process will be applied. (default: current engine)
  61053. * @param reusable If the post process can be reused on the same frame. (default: false)
  61054. * @param textureType Type of textures used when performing the post process. (default: 0)
  61055. * @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)
  61056. */
  61057. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61058. /**
  61059. * Excludes the given skinned mesh from computing bones velocities.
  61060. * 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.
  61061. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61062. */
  61063. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61064. /**
  61065. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61066. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61067. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61068. */
  61069. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61070. /**
  61071. * Disposes the post process.
  61072. * @param camera The camera to dispose the post process on.
  61073. */
  61074. dispose(camera?: Camera): void;
  61075. }
  61076. }
  61077. declare module "babylonjs/Shaders/refraction.fragment" {
  61078. /** @hidden */
  61079. export var refractionPixelShader: {
  61080. name: string;
  61081. shader: string;
  61082. };
  61083. }
  61084. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61085. import { Color3 } from "babylonjs/Maths/math.color";
  61086. import { Camera } from "babylonjs/Cameras/camera";
  61087. import { Texture } from "babylonjs/Materials/Textures/texture";
  61088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61089. import { Engine } from "babylonjs/Engines/engine";
  61090. import "babylonjs/Shaders/refraction.fragment";
  61091. /**
  61092. * Post process which applies a refractin texture
  61093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61094. */
  61095. export class RefractionPostProcess extends PostProcess {
  61096. /** the base color of the refraction (used to taint the rendering) */
  61097. color: Color3;
  61098. /** simulated refraction depth */
  61099. depth: number;
  61100. /** the coefficient of the base color (0 to remove base color tainting) */
  61101. colorLevel: number;
  61102. private _refTexture;
  61103. private _ownRefractionTexture;
  61104. /**
  61105. * Gets or sets the refraction texture
  61106. * Please note that you are responsible for disposing the texture if you set it manually
  61107. */
  61108. refractionTexture: Texture;
  61109. /**
  61110. * Initializes the RefractionPostProcess
  61111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61112. * @param name The name of the effect.
  61113. * @param refractionTextureUrl Url of the refraction texture to use
  61114. * @param color the base color of the refraction (used to taint the rendering)
  61115. * @param depth simulated refraction depth
  61116. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61117. * @param camera The camera to apply the render pass to.
  61118. * @param options The required width/height ratio to downsize to before computing the render pass.
  61119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61120. * @param engine The engine which the post process will be applied. (default: current engine)
  61121. * @param reusable If the post process can be reused on the same frame. (default: false)
  61122. */
  61123. constructor(name: string, refractionTextureUrl: string,
  61124. /** the base color of the refraction (used to taint the rendering) */
  61125. color: Color3,
  61126. /** simulated refraction depth */
  61127. depth: number,
  61128. /** the coefficient of the base color (0 to remove base color tainting) */
  61129. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61130. /**
  61131. * Disposes of the post process
  61132. * @param camera Camera to dispose post process on
  61133. */
  61134. dispose(camera: Camera): void;
  61135. }
  61136. }
  61137. declare module "babylonjs/Shaders/sharpen.fragment" {
  61138. /** @hidden */
  61139. export var sharpenPixelShader: {
  61140. name: string;
  61141. shader: string;
  61142. };
  61143. }
  61144. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61145. import { Nullable } from "babylonjs/types";
  61146. import { Camera } from "babylonjs/Cameras/camera";
  61147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61148. import "babylonjs/Shaders/sharpen.fragment";
  61149. import { Engine } from "babylonjs/Engines/engine";
  61150. /**
  61151. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61152. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61153. */
  61154. export class SharpenPostProcess extends PostProcess {
  61155. /**
  61156. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61157. */
  61158. colorAmount: number;
  61159. /**
  61160. * How much sharpness should be applied (default: 0.3)
  61161. */
  61162. edgeAmount: number;
  61163. /**
  61164. * Creates a new instance ConvolutionPostProcess
  61165. * @param name The name of the effect.
  61166. * @param options The required width/height ratio to downsize to before computing the render pass.
  61167. * @param camera The camera to apply the render pass to.
  61168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61169. * @param engine The engine which the post process will be applied. (default: current engine)
  61170. * @param reusable If the post process can be reused on the same frame. (default: false)
  61171. * @param textureType Type of textures used when performing the post process. (default: 0)
  61172. * @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)
  61173. */
  61174. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61175. }
  61176. }
  61177. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61178. import { Nullable } from "babylonjs/types";
  61179. import { Camera } from "babylonjs/Cameras/camera";
  61180. import { Engine } from "babylonjs/Engines/engine";
  61181. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61182. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61183. /**
  61184. * PostProcessRenderPipeline
  61185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61186. */
  61187. export class PostProcessRenderPipeline {
  61188. private engine;
  61189. private _renderEffects;
  61190. private _renderEffectsForIsolatedPass;
  61191. /**
  61192. * List of inspectable custom properties (used by the Inspector)
  61193. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61194. */
  61195. inspectableCustomProperties: IInspectable[];
  61196. /**
  61197. * @hidden
  61198. */
  61199. protected _cameras: Camera[];
  61200. /** @hidden */
  61201. _name: string;
  61202. /**
  61203. * Gets pipeline name
  61204. */
  61205. readonly name: string;
  61206. /**
  61207. * Initializes a PostProcessRenderPipeline
  61208. * @param engine engine to add the pipeline to
  61209. * @param name name of the pipeline
  61210. */
  61211. constructor(engine: Engine, name: string);
  61212. /**
  61213. * Gets the class name
  61214. * @returns "PostProcessRenderPipeline"
  61215. */
  61216. getClassName(): string;
  61217. /**
  61218. * If all the render effects in the pipeline are supported
  61219. */
  61220. readonly isSupported: boolean;
  61221. /**
  61222. * Adds an effect to the pipeline
  61223. * @param renderEffect the effect to add
  61224. */
  61225. addEffect(renderEffect: PostProcessRenderEffect): void;
  61226. /** @hidden */
  61227. _rebuild(): void;
  61228. /** @hidden */
  61229. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61230. /** @hidden */
  61231. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61232. /** @hidden */
  61233. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61234. /** @hidden */
  61235. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61236. /** @hidden */
  61237. _attachCameras(cameras: Camera, unique: boolean): void;
  61238. /** @hidden */
  61239. _attachCameras(cameras: Camera[], unique: boolean): void;
  61240. /** @hidden */
  61241. _detachCameras(cameras: Camera): void;
  61242. /** @hidden */
  61243. _detachCameras(cameras: Nullable<Camera[]>): void;
  61244. /** @hidden */
  61245. _update(): void;
  61246. /** @hidden */
  61247. _reset(): void;
  61248. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61249. /**
  61250. * Disposes of the pipeline
  61251. */
  61252. dispose(): void;
  61253. }
  61254. }
  61255. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61256. import { Camera } from "babylonjs/Cameras/camera";
  61257. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61258. /**
  61259. * PostProcessRenderPipelineManager class
  61260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61261. */
  61262. export class PostProcessRenderPipelineManager {
  61263. private _renderPipelines;
  61264. /**
  61265. * Initializes a PostProcessRenderPipelineManager
  61266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61267. */
  61268. constructor();
  61269. /**
  61270. * Gets the list of supported render pipelines
  61271. */
  61272. readonly supportedPipelines: PostProcessRenderPipeline[];
  61273. /**
  61274. * Adds a pipeline to the manager
  61275. * @param renderPipeline The pipeline to add
  61276. */
  61277. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61278. /**
  61279. * Attaches a camera to the pipeline
  61280. * @param renderPipelineName The name of the pipeline to attach to
  61281. * @param cameras the camera to attach
  61282. * @param unique if the camera can be attached multiple times to the pipeline
  61283. */
  61284. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61285. /**
  61286. * Detaches a camera from the pipeline
  61287. * @param renderPipelineName The name of the pipeline to detach from
  61288. * @param cameras the camera to detach
  61289. */
  61290. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61291. /**
  61292. * Enables an effect by name on a pipeline
  61293. * @param renderPipelineName the name of the pipeline to enable the effect in
  61294. * @param renderEffectName the name of the effect to enable
  61295. * @param cameras the cameras that the effect should be enabled on
  61296. */
  61297. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61298. /**
  61299. * Disables an effect by name on a pipeline
  61300. * @param renderPipelineName the name of the pipeline to disable the effect in
  61301. * @param renderEffectName the name of the effect to disable
  61302. * @param cameras the cameras that the effect should be disabled on
  61303. */
  61304. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61305. /**
  61306. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61307. */
  61308. update(): void;
  61309. /** @hidden */
  61310. _rebuild(): void;
  61311. /**
  61312. * Disposes of the manager and pipelines
  61313. */
  61314. dispose(): void;
  61315. }
  61316. }
  61317. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61318. import { ISceneComponent } from "babylonjs/sceneComponent";
  61319. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61320. import { Scene } from "babylonjs/scene";
  61321. module "babylonjs/scene" {
  61322. interface Scene {
  61323. /** @hidden (Backing field) */
  61324. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61325. /**
  61326. * Gets the postprocess render pipeline manager
  61327. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61328. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61329. */
  61330. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61331. }
  61332. }
  61333. /**
  61334. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61335. */
  61336. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61337. /**
  61338. * The component name helpfull to identify the component in the list of scene components.
  61339. */
  61340. readonly name: string;
  61341. /**
  61342. * The scene the component belongs to.
  61343. */
  61344. scene: Scene;
  61345. /**
  61346. * Creates a new instance of the component for the given scene
  61347. * @param scene Defines the scene to register the component in
  61348. */
  61349. constructor(scene: Scene);
  61350. /**
  61351. * Registers the component in a given scene
  61352. */
  61353. register(): void;
  61354. /**
  61355. * Rebuilds the elements related to this component in case of
  61356. * context lost for instance.
  61357. */
  61358. rebuild(): void;
  61359. /**
  61360. * Disposes the component and the associated ressources
  61361. */
  61362. dispose(): void;
  61363. private _gatherRenderTargets;
  61364. }
  61365. }
  61366. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61367. import { Nullable } from "babylonjs/types";
  61368. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61369. import { Camera } from "babylonjs/Cameras/camera";
  61370. import { IDisposable } from "babylonjs/scene";
  61371. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61372. import { Scene } from "babylonjs/scene";
  61373. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61374. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61375. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61376. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61377. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61378. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61379. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61380. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61381. import { Animation } from "babylonjs/Animations/animation";
  61382. /**
  61383. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61384. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61385. */
  61386. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61387. private _scene;
  61388. private _camerasToBeAttached;
  61389. /**
  61390. * ID of the sharpen post process,
  61391. */
  61392. private readonly SharpenPostProcessId;
  61393. /**
  61394. * @ignore
  61395. * ID of the image processing post process;
  61396. */
  61397. readonly ImageProcessingPostProcessId: string;
  61398. /**
  61399. * @ignore
  61400. * ID of the Fast Approximate Anti-Aliasing post process;
  61401. */
  61402. readonly FxaaPostProcessId: string;
  61403. /**
  61404. * ID of the chromatic aberration post process,
  61405. */
  61406. private readonly ChromaticAberrationPostProcessId;
  61407. /**
  61408. * ID of the grain post process
  61409. */
  61410. private readonly GrainPostProcessId;
  61411. /**
  61412. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61413. */
  61414. sharpen: SharpenPostProcess;
  61415. private _sharpenEffect;
  61416. private bloom;
  61417. /**
  61418. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61419. */
  61420. depthOfField: DepthOfFieldEffect;
  61421. /**
  61422. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61423. */
  61424. fxaa: FxaaPostProcess;
  61425. /**
  61426. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61427. */
  61428. imageProcessing: ImageProcessingPostProcess;
  61429. /**
  61430. * Chromatic aberration post process which will shift rgb colors in the image
  61431. */
  61432. chromaticAberration: ChromaticAberrationPostProcess;
  61433. private _chromaticAberrationEffect;
  61434. /**
  61435. * Grain post process which add noise to the image
  61436. */
  61437. grain: GrainPostProcess;
  61438. private _grainEffect;
  61439. /**
  61440. * Glow post process which adds a glow to emissive areas of the image
  61441. */
  61442. private _glowLayer;
  61443. /**
  61444. * Animations which can be used to tweak settings over a period of time
  61445. */
  61446. animations: Animation[];
  61447. private _imageProcessingConfigurationObserver;
  61448. private _sharpenEnabled;
  61449. private _bloomEnabled;
  61450. private _depthOfFieldEnabled;
  61451. private _depthOfFieldBlurLevel;
  61452. private _fxaaEnabled;
  61453. private _imageProcessingEnabled;
  61454. private _defaultPipelineTextureType;
  61455. private _bloomScale;
  61456. private _chromaticAberrationEnabled;
  61457. private _grainEnabled;
  61458. private _buildAllowed;
  61459. /**
  61460. * Gets active scene
  61461. */
  61462. readonly scene: Scene;
  61463. /**
  61464. * Enable or disable the sharpen process from the pipeline
  61465. */
  61466. sharpenEnabled: boolean;
  61467. private _resizeObserver;
  61468. private _hardwareScaleLevel;
  61469. private _bloomKernel;
  61470. /**
  61471. * Specifies the size of the bloom blur kernel, relative to the final output size
  61472. */
  61473. bloomKernel: number;
  61474. /**
  61475. * Specifies the weight of the bloom in the final rendering
  61476. */
  61477. private _bloomWeight;
  61478. /**
  61479. * Specifies the luma threshold for the area that will be blurred by the bloom
  61480. */
  61481. private _bloomThreshold;
  61482. private _hdr;
  61483. /**
  61484. * The strength of the bloom.
  61485. */
  61486. bloomWeight: number;
  61487. /**
  61488. * The strength of the bloom.
  61489. */
  61490. bloomThreshold: number;
  61491. /**
  61492. * The scale of the bloom, lower value will provide better performance.
  61493. */
  61494. bloomScale: number;
  61495. /**
  61496. * Enable or disable the bloom from the pipeline
  61497. */
  61498. bloomEnabled: boolean;
  61499. private _rebuildBloom;
  61500. /**
  61501. * If the depth of field is enabled.
  61502. */
  61503. depthOfFieldEnabled: boolean;
  61504. /**
  61505. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61506. */
  61507. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61508. /**
  61509. * If the anti aliasing is enabled.
  61510. */
  61511. fxaaEnabled: boolean;
  61512. private _samples;
  61513. /**
  61514. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61515. */
  61516. samples: number;
  61517. /**
  61518. * If image processing is enabled.
  61519. */
  61520. imageProcessingEnabled: boolean;
  61521. /**
  61522. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61523. */
  61524. glowLayerEnabled: boolean;
  61525. /**
  61526. * Gets the glow layer (or null if not defined)
  61527. */
  61528. readonly glowLayer: Nullable<GlowLayer>;
  61529. /**
  61530. * Enable or disable the chromaticAberration process from the pipeline
  61531. */
  61532. chromaticAberrationEnabled: boolean;
  61533. /**
  61534. * Enable or disable the grain process from the pipeline
  61535. */
  61536. grainEnabled: boolean;
  61537. /**
  61538. * @constructor
  61539. * @param name - The rendering pipeline name (default: "")
  61540. * @param hdr - If high dynamic range textures should be used (default: true)
  61541. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61542. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61543. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61544. */
  61545. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61546. /**
  61547. * Get the class name
  61548. * @returns "DefaultRenderingPipeline"
  61549. */
  61550. getClassName(): string;
  61551. /**
  61552. * Force the compilation of the entire pipeline.
  61553. */
  61554. prepare(): void;
  61555. private _hasCleared;
  61556. private _prevPostProcess;
  61557. private _prevPrevPostProcess;
  61558. private _setAutoClearAndTextureSharing;
  61559. private _depthOfFieldSceneObserver;
  61560. private _buildPipeline;
  61561. private _disposePostProcesses;
  61562. /**
  61563. * Adds a camera to the pipeline
  61564. * @param camera the camera to be added
  61565. */
  61566. addCamera(camera: Camera): void;
  61567. /**
  61568. * Removes a camera from the pipeline
  61569. * @param camera the camera to remove
  61570. */
  61571. removeCamera(camera: Camera): void;
  61572. /**
  61573. * Dispose of the pipeline and stop all post processes
  61574. */
  61575. dispose(): void;
  61576. /**
  61577. * Serialize the rendering pipeline (Used when exporting)
  61578. * @returns the serialized object
  61579. */
  61580. serialize(): any;
  61581. /**
  61582. * Parse the serialized pipeline
  61583. * @param source Source pipeline.
  61584. * @param scene The scene to load the pipeline to.
  61585. * @param rootUrl The URL of the serialized pipeline.
  61586. * @returns An instantiated pipeline from the serialized object.
  61587. */
  61588. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61589. }
  61590. }
  61591. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61592. /** @hidden */
  61593. export var lensHighlightsPixelShader: {
  61594. name: string;
  61595. shader: string;
  61596. };
  61597. }
  61598. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61599. /** @hidden */
  61600. export var depthOfFieldPixelShader: {
  61601. name: string;
  61602. shader: string;
  61603. };
  61604. }
  61605. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61606. import { Camera } from "babylonjs/Cameras/camera";
  61607. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61608. import { Scene } from "babylonjs/scene";
  61609. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61610. import "babylonjs/Shaders/chromaticAberration.fragment";
  61611. import "babylonjs/Shaders/lensHighlights.fragment";
  61612. import "babylonjs/Shaders/depthOfField.fragment";
  61613. /**
  61614. * BABYLON.JS Chromatic Aberration GLSL Shader
  61615. * Author: Olivier Guyot
  61616. * Separates very slightly R, G and B colors on the edges of the screen
  61617. * Inspired by Francois Tarlier & Martins Upitis
  61618. */
  61619. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61620. /**
  61621. * @ignore
  61622. * The chromatic aberration PostProcess id in the pipeline
  61623. */
  61624. LensChromaticAberrationEffect: string;
  61625. /**
  61626. * @ignore
  61627. * The highlights enhancing PostProcess id in the pipeline
  61628. */
  61629. HighlightsEnhancingEffect: string;
  61630. /**
  61631. * @ignore
  61632. * The depth-of-field PostProcess id in the pipeline
  61633. */
  61634. LensDepthOfFieldEffect: string;
  61635. private _scene;
  61636. private _depthTexture;
  61637. private _grainTexture;
  61638. private _chromaticAberrationPostProcess;
  61639. private _highlightsPostProcess;
  61640. private _depthOfFieldPostProcess;
  61641. private _edgeBlur;
  61642. private _grainAmount;
  61643. private _chromaticAberration;
  61644. private _distortion;
  61645. private _highlightsGain;
  61646. private _highlightsThreshold;
  61647. private _dofDistance;
  61648. private _dofAperture;
  61649. private _dofDarken;
  61650. private _dofPentagon;
  61651. private _blurNoise;
  61652. /**
  61653. * @constructor
  61654. *
  61655. * Effect parameters are as follow:
  61656. * {
  61657. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61658. * edge_blur: number; // from 0 to x (1 for realism)
  61659. * distortion: number; // from 0 to x (1 for realism)
  61660. * grain_amount: number; // from 0 to 1
  61661. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61662. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61663. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61664. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61665. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61666. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61667. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61668. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61669. * }
  61670. * Note: if an effect parameter is unset, effect is disabled
  61671. *
  61672. * @param name The rendering pipeline name
  61673. * @param parameters - An object containing all parameters (see above)
  61674. * @param scene The scene linked to this pipeline
  61675. * @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)
  61676. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61677. */
  61678. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61679. /**
  61680. * Get the class name
  61681. * @returns "LensRenderingPipeline"
  61682. */
  61683. getClassName(): string;
  61684. /**
  61685. * Gets associated scene
  61686. */
  61687. readonly scene: Scene;
  61688. /**
  61689. * Gets or sets the edge blur
  61690. */
  61691. edgeBlur: number;
  61692. /**
  61693. * Gets or sets the grain amount
  61694. */
  61695. grainAmount: number;
  61696. /**
  61697. * Gets or sets the chromatic aberration amount
  61698. */
  61699. chromaticAberration: number;
  61700. /**
  61701. * Gets or sets the depth of field aperture
  61702. */
  61703. dofAperture: number;
  61704. /**
  61705. * Gets or sets the edge distortion
  61706. */
  61707. edgeDistortion: number;
  61708. /**
  61709. * Gets or sets the depth of field distortion
  61710. */
  61711. dofDistortion: number;
  61712. /**
  61713. * Gets or sets the darken out of focus amount
  61714. */
  61715. darkenOutOfFocus: number;
  61716. /**
  61717. * Gets or sets a boolean indicating if blur noise is enabled
  61718. */
  61719. blurNoise: boolean;
  61720. /**
  61721. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61722. */
  61723. pentagonBokeh: boolean;
  61724. /**
  61725. * Gets or sets the highlight grain amount
  61726. */
  61727. highlightsGain: number;
  61728. /**
  61729. * Gets or sets the highlight threshold
  61730. */
  61731. highlightsThreshold: number;
  61732. /**
  61733. * Sets the amount of blur at the edges
  61734. * @param amount blur amount
  61735. */
  61736. setEdgeBlur(amount: number): void;
  61737. /**
  61738. * Sets edge blur to 0
  61739. */
  61740. disableEdgeBlur(): void;
  61741. /**
  61742. * Sets the amout of grain
  61743. * @param amount Amount of grain
  61744. */
  61745. setGrainAmount(amount: number): void;
  61746. /**
  61747. * Set grain amount to 0
  61748. */
  61749. disableGrain(): void;
  61750. /**
  61751. * Sets the chromatic aberration amount
  61752. * @param amount amount of chromatic aberration
  61753. */
  61754. setChromaticAberration(amount: number): void;
  61755. /**
  61756. * Sets chromatic aberration amount to 0
  61757. */
  61758. disableChromaticAberration(): void;
  61759. /**
  61760. * Sets the EdgeDistortion amount
  61761. * @param amount amount of EdgeDistortion
  61762. */
  61763. setEdgeDistortion(amount: number): void;
  61764. /**
  61765. * Sets edge distortion to 0
  61766. */
  61767. disableEdgeDistortion(): void;
  61768. /**
  61769. * Sets the FocusDistance amount
  61770. * @param amount amount of FocusDistance
  61771. */
  61772. setFocusDistance(amount: number): void;
  61773. /**
  61774. * Disables depth of field
  61775. */
  61776. disableDepthOfField(): void;
  61777. /**
  61778. * Sets the Aperture amount
  61779. * @param amount amount of Aperture
  61780. */
  61781. setAperture(amount: number): void;
  61782. /**
  61783. * Sets the DarkenOutOfFocus amount
  61784. * @param amount amount of DarkenOutOfFocus
  61785. */
  61786. setDarkenOutOfFocus(amount: number): void;
  61787. private _pentagonBokehIsEnabled;
  61788. /**
  61789. * Creates a pentagon bokeh effect
  61790. */
  61791. enablePentagonBokeh(): void;
  61792. /**
  61793. * Disables the pentagon bokeh effect
  61794. */
  61795. disablePentagonBokeh(): void;
  61796. /**
  61797. * Enables noise blur
  61798. */
  61799. enableNoiseBlur(): void;
  61800. /**
  61801. * Disables noise blur
  61802. */
  61803. disableNoiseBlur(): void;
  61804. /**
  61805. * Sets the HighlightsGain amount
  61806. * @param amount amount of HighlightsGain
  61807. */
  61808. setHighlightsGain(amount: number): void;
  61809. /**
  61810. * Sets the HighlightsThreshold amount
  61811. * @param amount amount of HighlightsThreshold
  61812. */
  61813. setHighlightsThreshold(amount: number): void;
  61814. /**
  61815. * Disables highlights
  61816. */
  61817. disableHighlights(): void;
  61818. /**
  61819. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61820. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61821. */
  61822. dispose(disableDepthRender?: boolean): void;
  61823. private _createChromaticAberrationPostProcess;
  61824. private _createHighlightsPostProcess;
  61825. private _createDepthOfFieldPostProcess;
  61826. private _createGrainTexture;
  61827. }
  61828. }
  61829. declare module "babylonjs/Shaders/ssao2.fragment" {
  61830. /** @hidden */
  61831. export var ssao2PixelShader: {
  61832. name: string;
  61833. shader: string;
  61834. };
  61835. }
  61836. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61837. /** @hidden */
  61838. export var ssaoCombinePixelShader: {
  61839. name: string;
  61840. shader: string;
  61841. };
  61842. }
  61843. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61844. import { Camera } from "babylonjs/Cameras/camera";
  61845. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61846. import { Scene } from "babylonjs/scene";
  61847. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61848. import "babylonjs/Shaders/ssao2.fragment";
  61849. import "babylonjs/Shaders/ssaoCombine.fragment";
  61850. /**
  61851. * Render pipeline to produce ssao effect
  61852. */
  61853. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61854. /**
  61855. * @ignore
  61856. * The PassPostProcess id in the pipeline that contains the original scene color
  61857. */
  61858. SSAOOriginalSceneColorEffect: string;
  61859. /**
  61860. * @ignore
  61861. * The SSAO PostProcess id in the pipeline
  61862. */
  61863. SSAORenderEffect: string;
  61864. /**
  61865. * @ignore
  61866. * The horizontal blur PostProcess id in the pipeline
  61867. */
  61868. SSAOBlurHRenderEffect: string;
  61869. /**
  61870. * @ignore
  61871. * The vertical blur PostProcess id in the pipeline
  61872. */
  61873. SSAOBlurVRenderEffect: string;
  61874. /**
  61875. * @ignore
  61876. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61877. */
  61878. SSAOCombineRenderEffect: string;
  61879. /**
  61880. * The output strength of the SSAO post-process. Default value is 1.0.
  61881. */
  61882. totalStrength: number;
  61883. /**
  61884. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61885. */
  61886. maxZ: number;
  61887. /**
  61888. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61889. */
  61890. minZAspect: number;
  61891. private _samples;
  61892. /**
  61893. * Number of samples used for the SSAO calculations. Default value is 8
  61894. */
  61895. samples: number;
  61896. private _textureSamples;
  61897. /**
  61898. * Number of samples to use for antialiasing
  61899. */
  61900. textureSamples: number;
  61901. /**
  61902. * Ratio object used for SSAO ratio and blur ratio
  61903. */
  61904. private _ratio;
  61905. /**
  61906. * Dynamically generated sphere sampler.
  61907. */
  61908. private _sampleSphere;
  61909. /**
  61910. * Blur filter offsets
  61911. */
  61912. private _samplerOffsets;
  61913. private _expensiveBlur;
  61914. /**
  61915. * If bilateral blur should be used
  61916. */
  61917. expensiveBlur: boolean;
  61918. /**
  61919. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61920. */
  61921. radius: number;
  61922. /**
  61923. * The base color of the SSAO post-process
  61924. * The final result is "base + ssao" between [0, 1]
  61925. */
  61926. base: number;
  61927. /**
  61928. * Support test.
  61929. */
  61930. static readonly IsSupported: boolean;
  61931. private _scene;
  61932. private _depthTexture;
  61933. private _normalTexture;
  61934. private _randomTexture;
  61935. private _originalColorPostProcess;
  61936. private _ssaoPostProcess;
  61937. private _blurHPostProcess;
  61938. private _blurVPostProcess;
  61939. private _ssaoCombinePostProcess;
  61940. private _firstUpdate;
  61941. /**
  61942. * Gets active scene
  61943. */
  61944. readonly scene: Scene;
  61945. /**
  61946. * @constructor
  61947. * @param name The rendering pipeline name
  61948. * @param scene The scene linked to this pipeline
  61949. * @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 }
  61950. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61951. */
  61952. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61953. /**
  61954. * Get the class name
  61955. * @returns "SSAO2RenderingPipeline"
  61956. */
  61957. getClassName(): string;
  61958. /**
  61959. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61960. */
  61961. dispose(disableGeometryBufferRenderer?: boolean): void;
  61962. private _createBlurPostProcess;
  61963. /** @hidden */
  61964. _rebuild(): void;
  61965. private _bits;
  61966. private _radicalInverse_VdC;
  61967. private _hammersley;
  61968. private _hemisphereSample_uniform;
  61969. private _generateHemisphere;
  61970. private _createSSAOPostProcess;
  61971. private _createSSAOCombinePostProcess;
  61972. private _createRandomTexture;
  61973. /**
  61974. * Serialize the rendering pipeline (Used when exporting)
  61975. * @returns the serialized object
  61976. */
  61977. serialize(): any;
  61978. /**
  61979. * Parse the serialized pipeline
  61980. * @param source Source pipeline.
  61981. * @param scene The scene to load the pipeline to.
  61982. * @param rootUrl The URL of the serialized pipeline.
  61983. * @returns An instantiated pipeline from the serialized object.
  61984. */
  61985. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61986. }
  61987. }
  61988. declare module "babylonjs/Shaders/ssao.fragment" {
  61989. /** @hidden */
  61990. export var ssaoPixelShader: {
  61991. name: string;
  61992. shader: string;
  61993. };
  61994. }
  61995. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61996. import { Camera } from "babylonjs/Cameras/camera";
  61997. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61998. import { Scene } from "babylonjs/scene";
  61999. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62000. import "babylonjs/Shaders/ssao.fragment";
  62001. import "babylonjs/Shaders/ssaoCombine.fragment";
  62002. /**
  62003. * Render pipeline to produce ssao effect
  62004. */
  62005. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62006. /**
  62007. * @ignore
  62008. * The PassPostProcess id in the pipeline that contains the original scene color
  62009. */
  62010. SSAOOriginalSceneColorEffect: string;
  62011. /**
  62012. * @ignore
  62013. * The SSAO PostProcess id in the pipeline
  62014. */
  62015. SSAORenderEffect: string;
  62016. /**
  62017. * @ignore
  62018. * The horizontal blur PostProcess id in the pipeline
  62019. */
  62020. SSAOBlurHRenderEffect: string;
  62021. /**
  62022. * @ignore
  62023. * The vertical blur PostProcess id in the pipeline
  62024. */
  62025. SSAOBlurVRenderEffect: string;
  62026. /**
  62027. * @ignore
  62028. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62029. */
  62030. SSAOCombineRenderEffect: string;
  62031. /**
  62032. * The output strength of the SSAO post-process. Default value is 1.0.
  62033. */
  62034. totalStrength: number;
  62035. /**
  62036. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62037. */
  62038. radius: number;
  62039. /**
  62040. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62041. * Must not be equal to fallOff and superior to fallOff.
  62042. * Default value is 0.0075
  62043. */
  62044. area: number;
  62045. /**
  62046. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62047. * Must not be equal to area and inferior to area.
  62048. * Default value is 0.000001
  62049. */
  62050. fallOff: number;
  62051. /**
  62052. * The base color of the SSAO post-process
  62053. * The final result is "base + ssao" between [0, 1]
  62054. */
  62055. base: number;
  62056. private _scene;
  62057. private _depthTexture;
  62058. private _randomTexture;
  62059. private _originalColorPostProcess;
  62060. private _ssaoPostProcess;
  62061. private _blurHPostProcess;
  62062. private _blurVPostProcess;
  62063. private _ssaoCombinePostProcess;
  62064. private _firstUpdate;
  62065. /**
  62066. * Gets active scene
  62067. */
  62068. readonly scene: Scene;
  62069. /**
  62070. * @constructor
  62071. * @param name - The rendering pipeline name
  62072. * @param scene - The scene linked to this pipeline
  62073. * @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 }
  62074. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62075. */
  62076. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62077. /**
  62078. * Get the class name
  62079. * @returns "SSAORenderingPipeline"
  62080. */
  62081. getClassName(): string;
  62082. /**
  62083. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62084. */
  62085. dispose(disableDepthRender?: boolean): void;
  62086. private _createBlurPostProcess;
  62087. /** @hidden */
  62088. _rebuild(): void;
  62089. private _createSSAOPostProcess;
  62090. private _createSSAOCombinePostProcess;
  62091. private _createRandomTexture;
  62092. }
  62093. }
  62094. declare module "babylonjs/Shaders/standard.fragment" {
  62095. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62096. /** @hidden */
  62097. export var standardPixelShader: {
  62098. name: string;
  62099. shader: string;
  62100. };
  62101. }
  62102. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62103. import { Nullable } from "babylonjs/types";
  62104. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62105. import { Camera } from "babylonjs/Cameras/camera";
  62106. import { Texture } from "babylonjs/Materials/Textures/texture";
  62107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62108. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62109. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62110. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62111. import { IDisposable } from "babylonjs/scene";
  62112. import { SpotLight } from "babylonjs/Lights/spotLight";
  62113. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62114. import { Scene } from "babylonjs/scene";
  62115. import { Animation } from "babylonjs/Animations/animation";
  62116. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62117. import "babylonjs/Shaders/standard.fragment";
  62118. /**
  62119. * Standard rendering pipeline
  62120. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62121. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62122. */
  62123. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62124. /**
  62125. * Public members
  62126. */
  62127. /**
  62128. * Post-process which contains the original scene color before the pipeline applies all the effects
  62129. */
  62130. originalPostProcess: Nullable<PostProcess>;
  62131. /**
  62132. * Post-process used to down scale an image x4
  62133. */
  62134. downSampleX4PostProcess: Nullable<PostProcess>;
  62135. /**
  62136. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62137. */
  62138. brightPassPostProcess: Nullable<PostProcess>;
  62139. /**
  62140. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62141. */
  62142. blurHPostProcesses: PostProcess[];
  62143. /**
  62144. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62145. */
  62146. blurVPostProcesses: PostProcess[];
  62147. /**
  62148. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62149. */
  62150. textureAdderPostProcess: Nullable<PostProcess>;
  62151. /**
  62152. * Post-process used to create volumetric lighting effect
  62153. */
  62154. volumetricLightPostProcess: Nullable<PostProcess>;
  62155. /**
  62156. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62157. */
  62158. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62159. /**
  62160. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62161. */
  62162. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62163. /**
  62164. * Post-process used to merge the volumetric light effect and the real scene color
  62165. */
  62166. volumetricLightMergePostProces: Nullable<PostProcess>;
  62167. /**
  62168. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62169. */
  62170. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62171. /**
  62172. * Base post-process used to calculate the average luminance of the final image for HDR
  62173. */
  62174. luminancePostProcess: Nullable<PostProcess>;
  62175. /**
  62176. * Post-processes used to create down sample post-processes in order to get
  62177. * the average luminance of the final image for HDR
  62178. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62179. */
  62180. luminanceDownSamplePostProcesses: PostProcess[];
  62181. /**
  62182. * Post-process used to create a HDR effect (light adaptation)
  62183. */
  62184. hdrPostProcess: Nullable<PostProcess>;
  62185. /**
  62186. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62187. */
  62188. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62189. /**
  62190. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62191. */
  62192. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62193. /**
  62194. * Post-process used to merge the final HDR post-process and the real scene color
  62195. */
  62196. hdrFinalPostProcess: Nullable<PostProcess>;
  62197. /**
  62198. * Post-process used to create a lens flare effect
  62199. */
  62200. lensFlarePostProcess: Nullable<PostProcess>;
  62201. /**
  62202. * Post-process that merges the result of the lens flare post-process and the real scene color
  62203. */
  62204. lensFlareComposePostProcess: Nullable<PostProcess>;
  62205. /**
  62206. * Post-process used to create a motion blur effect
  62207. */
  62208. motionBlurPostProcess: Nullable<PostProcess>;
  62209. /**
  62210. * Post-process used to create a depth of field effect
  62211. */
  62212. depthOfFieldPostProcess: Nullable<PostProcess>;
  62213. /**
  62214. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62215. */
  62216. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62217. /**
  62218. * Represents the brightness threshold in order to configure the illuminated surfaces
  62219. */
  62220. brightThreshold: number;
  62221. /**
  62222. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62223. */
  62224. blurWidth: number;
  62225. /**
  62226. * Sets if the blur for highlighted surfaces must be only horizontal
  62227. */
  62228. horizontalBlur: boolean;
  62229. /**
  62230. * Gets the overall exposure used by the pipeline
  62231. */
  62232. /**
  62233. * Sets the overall exposure used by the pipeline
  62234. */
  62235. exposure: number;
  62236. /**
  62237. * Texture used typically to simulate "dirty" on camera lens
  62238. */
  62239. lensTexture: Nullable<Texture>;
  62240. /**
  62241. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62242. */
  62243. volumetricLightCoefficient: number;
  62244. /**
  62245. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62246. */
  62247. volumetricLightPower: number;
  62248. /**
  62249. * Used the set the blur intensity to smooth the volumetric lights
  62250. */
  62251. volumetricLightBlurScale: number;
  62252. /**
  62253. * Light (spot or directional) used to generate the volumetric lights rays
  62254. * The source light must have a shadow generate so the pipeline can get its
  62255. * depth map
  62256. */
  62257. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62258. /**
  62259. * For eye adaptation, represents the minimum luminance the eye can see
  62260. */
  62261. hdrMinimumLuminance: number;
  62262. /**
  62263. * For eye adaptation, represents the decrease luminance speed
  62264. */
  62265. hdrDecreaseRate: number;
  62266. /**
  62267. * For eye adaptation, represents the increase luminance speed
  62268. */
  62269. hdrIncreaseRate: number;
  62270. /**
  62271. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62272. */
  62273. /**
  62274. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62275. */
  62276. hdrAutoExposure: boolean;
  62277. /**
  62278. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62279. */
  62280. lensColorTexture: Nullable<Texture>;
  62281. /**
  62282. * The overall strengh for the lens flare effect
  62283. */
  62284. lensFlareStrength: number;
  62285. /**
  62286. * Dispersion coefficient for lens flare ghosts
  62287. */
  62288. lensFlareGhostDispersal: number;
  62289. /**
  62290. * Main lens flare halo width
  62291. */
  62292. lensFlareHaloWidth: number;
  62293. /**
  62294. * Based on the lens distortion effect, defines how much the lens flare result
  62295. * is distorted
  62296. */
  62297. lensFlareDistortionStrength: number;
  62298. /**
  62299. * Lens star texture must be used to simulate rays on the flares and is available
  62300. * in the documentation
  62301. */
  62302. lensStarTexture: Nullable<Texture>;
  62303. /**
  62304. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62305. * flare effect by taking account of the dirt texture
  62306. */
  62307. lensFlareDirtTexture: Nullable<Texture>;
  62308. /**
  62309. * Represents the focal length for the depth of field effect
  62310. */
  62311. depthOfFieldDistance: number;
  62312. /**
  62313. * Represents the blur intensity for the blurred part of the depth of field effect
  62314. */
  62315. depthOfFieldBlurWidth: number;
  62316. /**
  62317. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62318. */
  62319. /**
  62320. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62321. */
  62322. motionStrength: number;
  62323. /**
  62324. * Gets wether or not the motion blur post-process is object based or screen based.
  62325. */
  62326. /**
  62327. * Sets wether or not the motion blur post-process should be object based or screen based
  62328. */
  62329. objectBasedMotionBlur: boolean;
  62330. /**
  62331. * List of animations for the pipeline (IAnimatable implementation)
  62332. */
  62333. animations: Animation[];
  62334. /**
  62335. * Private members
  62336. */
  62337. private _scene;
  62338. private _currentDepthOfFieldSource;
  62339. private _basePostProcess;
  62340. private _fixedExposure;
  62341. private _currentExposure;
  62342. private _hdrAutoExposure;
  62343. private _hdrCurrentLuminance;
  62344. private _motionStrength;
  62345. private _isObjectBasedMotionBlur;
  62346. private _floatTextureType;
  62347. private _camerasToBeAttached;
  62348. private _ratio;
  62349. private _bloomEnabled;
  62350. private _depthOfFieldEnabled;
  62351. private _vlsEnabled;
  62352. private _lensFlareEnabled;
  62353. private _hdrEnabled;
  62354. private _motionBlurEnabled;
  62355. private _fxaaEnabled;
  62356. private _motionBlurSamples;
  62357. private _volumetricLightStepsCount;
  62358. private _samples;
  62359. /**
  62360. * @ignore
  62361. * Specifies if the bloom pipeline is enabled
  62362. */
  62363. BloomEnabled: boolean;
  62364. /**
  62365. * @ignore
  62366. * Specifies if the depth of field pipeline is enabed
  62367. */
  62368. DepthOfFieldEnabled: boolean;
  62369. /**
  62370. * @ignore
  62371. * Specifies if the lens flare pipeline is enabed
  62372. */
  62373. LensFlareEnabled: boolean;
  62374. /**
  62375. * @ignore
  62376. * Specifies if the HDR pipeline is enabled
  62377. */
  62378. HDREnabled: boolean;
  62379. /**
  62380. * @ignore
  62381. * Specifies if the volumetric lights scattering effect is enabled
  62382. */
  62383. VLSEnabled: boolean;
  62384. /**
  62385. * @ignore
  62386. * Specifies if the motion blur effect is enabled
  62387. */
  62388. MotionBlurEnabled: boolean;
  62389. /**
  62390. * Specifies if anti-aliasing is enabled
  62391. */
  62392. fxaaEnabled: boolean;
  62393. /**
  62394. * Specifies the number of steps used to calculate the volumetric lights
  62395. * Typically in interval [50, 200]
  62396. */
  62397. volumetricLightStepsCount: number;
  62398. /**
  62399. * Specifies the number of samples used for the motion blur effect
  62400. * Typically in interval [16, 64]
  62401. */
  62402. motionBlurSamples: number;
  62403. /**
  62404. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62405. */
  62406. samples: number;
  62407. /**
  62408. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62409. * @constructor
  62410. * @param name The rendering pipeline name
  62411. * @param scene The scene linked to this pipeline
  62412. * @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)
  62413. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62414. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62415. */
  62416. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62417. private _buildPipeline;
  62418. private _createDownSampleX4PostProcess;
  62419. private _createBrightPassPostProcess;
  62420. private _createBlurPostProcesses;
  62421. private _createTextureAdderPostProcess;
  62422. private _createVolumetricLightPostProcess;
  62423. private _createLuminancePostProcesses;
  62424. private _createHdrPostProcess;
  62425. private _createLensFlarePostProcess;
  62426. private _createDepthOfFieldPostProcess;
  62427. private _createMotionBlurPostProcess;
  62428. private _getDepthTexture;
  62429. private _disposePostProcesses;
  62430. /**
  62431. * Dispose of the pipeline and stop all post processes
  62432. */
  62433. dispose(): void;
  62434. /**
  62435. * Serialize the rendering pipeline (Used when exporting)
  62436. * @returns the serialized object
  62437. */
  62438. serialize(): any;
  62439. /**
  62440. * Parse the serialized pipeline
  62441. * @param source Source pipeline.
  62442. * @param scene The scene to load the pipeline to.
  62443. * @param rootUrl The URL of the serialized pipeline.
  62444. * @returns An instantiated pipeline from the serialized object.
  62445. */
  62446. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62447. /**
  62448. * Luminance steps
  62449. */
  62450. static LuminanceSteps: number;
  62451. }
  62452. }
  62453. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62454. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62455. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62456. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62457. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62458. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62459. }
  62460. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62461. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62462. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62463. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62464. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62465. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62466. }
  62467. declare module "babylonjs/Shaders/tonemap.fragment" {
  62468. /** @hidden */
  62469. export var tonemapPixelShader: {
  62470. name: string;
  62471. shader: string;
  62472. };
  62473. }
  62474. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62475. import { Camera } from "babylonjs/Cameras/camera";
  62476. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62477. import "babylonjs/Shaders/tonemap.fragment";
  62478. import { Engine } from "babylonjs/Engines/engine";
  62479. /** Defines operator used for tonemapping */
  62480. export enum TonemappingOperator {
  62481. /** Hable */
  62482. Hable = 0,
  62483. /** Reinhard */
  62484. Reinhard = 1,
  62485. /** HejiDawson */
  62486. HejiDawson = 2,
  62487. /** Photographic */
  62488. Photographic = 3
  62489. }
  62490. /**
  62491. * Defines a post process to apply tone mapping
  62492. */
  62493. export class TonemapPostProcess extends PostProcess {
  62494. private _operator;
  62495. /** Defines the required exposure adjustement */
  62496. exposureAdjustment: number;
  62497. /**
  62498. * Creates a new TonemapPostProcess
  62499. * @param name defines the name of the postprocess
  62500. * @param _operator defines the operator to use
  62501. * @param exposureAdjustment defines the required exposure adjustement
  62502. * @param camera defines the camera to use (can be null)
  62503. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62504. * @param engine defines the hosting engine (can be ignore if camera is set)
  62505. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62506. */
  62507. constructor(name: string, _operator: TonemappingOperator,
  62508. /** Defines the required exposure adjustement */
  62509. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62510. }
  62511. }
  62512. declare module "babylonjs/Shaders/depth.vertex" {
  62513. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62516. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62517. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62518. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62519. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62520. /** @hidden */
  62521. export var depthVertexShader: {
  62522. name: string;
  62523. shader: string;
  62524. };
  62525. }
  62526. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62527. /** @hidden */
  62528. export var volumetricLightScatteringPixelShader: {
  62529. name: string;
  62530. shader: string;
  62531. };
  62532. }
  62533. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62534. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62535. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62536. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62537. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62539. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62540. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62541. /** @hidden */
  62542. export var volumetricLightScatteringPassVertexShader: {
  62543. name: string;
  62544. shader: string;
  62545. };
  62546. }
  62547. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62548. /** @hidden */
  62549. export var volumetricLightScatteringPassPixelShader: {
  62550. name: string;
  62551. shader: string;
  62552. };
  62553. }
  62554. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62555. import { Vector3 } from "babylonjs/Maths/math.vector";
  62556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62557. import { Mesh } from "babylonjs/Meshes/mesh";
  62558. import { Camera } from "babylonjs/Cameras/camera";
  62559. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62561. import { Scene } from "babylonjs/scene";
  62562. import "babylonjs/Meshes/Builders/planeBuilder";
  62563. import "babylonjs/Shaders/depth.vertex";
  62564. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62565. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62566. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62567. import { Engine } from "babylonjs/Engines/engine";
  62568. /**
  62569. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62570. */
  62571. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62572. private _volumetricLightScatteringPass;
  62573. private _volumetricLightScatteringRTT;
  62574. private _viewPort;
  62575. private _screenCoordinates;
  62576. private _cachedDefines;
  62577. /**
  62578. * If not undefined, the mesh position is computed from the attached node position
  62579. */
  62580. attachedNode: {
  62581. position: Vector3;
  62582. };
  62583. /**
  62584. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62585. */
  62586. customMeshPosition: Vector3;
  62587. /**
  62588. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62589. */
  62590. useCustomMeshPosition: boolean;
  62591. /**
  62592. * If the post-process should inverse the light scattering direction
  62593. */
  62594. invert: boolean;
  62595. /**
  62596. * The internal mesh used by the post-process
  62597. */
  62598. mesh: Mesh;
  62599. /**
  62600. * @hidden
  62601. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62602. */
  62603. useDiffuseColor: boolean;
  62604. /**
  62605. * Array containing the excluded meshes not rendered in the internal pass
  62606. */
  62607. excludedMeshes: AbstractMesh[];
  62608. /**
  62609. * Controls the overall intensity of the post-process
  62610. */
  62611. exposure: number;
  62612. /**
  62613. * Dissipates each sample's contribution in range [0, 1]
  62614. */
  62615. decay: number;
  62616. /**
  62617. * Controls the overall intensity of each sample
  62618. */
  62619. weight: number;
  62620. /**
  62621. * Controls the density of each sample
  62622. */
  62623. density: number;
  62624. /**
  62625. * @constructor
  62626. * @param name The post-process name
  62627. * @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)
  62628. * @param camera The camera that the post-process will be attached to
  62629. * @param mesh The mesh used to create the light scattering
  62630. * @param samples The post-process quality, default 100
  62631. * @param samplingModeThe post-process filtering mode
  62632. * @param engine The babylon engine
  62633. * @param reusable If the post-process is reusable
  62634. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62635. */
  62636. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62637. /**
  62638. * Returns the string "VolumetricLightScatteringPostProcess"
  62639. * @returns "VolumetricLightScatteringPostProcess"
  62640. */
  62641. getClassName(): string;
  62642. private _isReady;
  62643. /**
  62644. * Sets the new light position for light scattering effect
  62645. * @param position The new custom light position
  62646. */
  62647. setCustomMeshPosition(position: Vector3): void;
  62648. /**
  62649. * Returns the light position for light scattering effect
  62650. * @return Vector3 The custom light position
  62651. */
  62652. getCustomMeshPosition(): Vector3;
  62653. /**
  62654. * Disposes the internal assets and detaches the post-process from the camera
  62655. */
  62656. dispose(camera: Camera): void;
  62657. /**
  62658. * Returns the render target texture used by the post-process
  62659. * @return the render target texture used by the post-process
  62660. */
  62661. getPass(): RenderTargetTexture;
  62662. private _meshExcluded;
  62663. private _createPass;
  62664. private _updateMeshScreenCoordinates;
  62665. /**
  62666. * Creates a default mesh for the Volumeric Light Scattering post-process
  62667. * @param name The mesh name
  62668. * @param scene The scene where to create the mesh
  62669. * @return the default mesh
  62670. */
  62671. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62672. }
  62673. }
  62674. declare module "babylonjs/PostProcesses/index" {
  62675. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62676. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62677. export * from "babylonjs/PostProcesses/bloomEffect";
  62678. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62679. export * from "babylonjs/PostProcesses/blurPostProcess";
  62680. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62681. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62682. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62683. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62684. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62685. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62686. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62687. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62688. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62689. export * from "babylonjs/PostProcesses/filterPostProcess";
  62690. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62691. export * from "babylonjs/PostProcesses/grainPostProcess";
  62692. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62693. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62694. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62695. export * from "babylonjs/PostProcesses/passPostProcess";
  62696. export * from "babylonjs/PostProcesses/postProcess";
  62697. export * from "babylonjs/PostProcesses/postProcessManager";
  62698. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62699. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62700. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62701. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62702. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62703. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62704. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62705. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62706. }
  62707. declare module "babylonjs/Probes/index" {
  62708. export * from "babylonjs/Probes/reflectionProbe";
  62709. }
  62710. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62711. import { Scene } from "babylonjs/scene";
  62712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62713. import { SmartArray } from "babylonjs/Misc/smartArray";
  62714. import { ISceneComponent } from "babylonjs/sceneComponent";
  62715. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62716. import "babylonjs/Meshes/Builders/boxBuilder";
  62717. import "babylonjs/Shaders/color.fragment";
  62718. import "babylonjs/Shaders/color.vertex";
  62719. import { Color3 } from "babylonjs/Maths/math.color";
  62720. module "babylonjs/scene" {
  62721. interface Scene {
  62722. /** @hidden (Backing field) */
  62723. _boundingBoxRenderer: BoundingBoxRenderer;
  62724. /** @hidden (Backing field) */
  62725. _forceShowBoundingBoxes: boolean;
  62726. /**
  62727. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62728. */
  62729. forceShowBoundingBoxes: boolean;
  62730. /**
  62731. * Gets the bounding box renderer associated with the scene
  62732. * @returns a BoundingBoxRenderer
  62733. */
  62734. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62735. }
  62736. }
  62737. module "babylonjs/Meshes/abstractMesh" {
  62738. interface AbstractMesh {
  62739. /** @hidden (Backing field) */
  62740. _showBoundingBox: boolean;
  62741. /**
  62742. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62743. */
  62744. showBoundingBox: boolean;
  62745. }
  62746. }
  62747. /**
  62748. * Component responsible of rendering the bounding box of the meshes in a scene.
  62749. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62750. */
  62751. export class BoundingBoxRenderer implements ISceneComponent {
  62752. /**
  62753. * The component name helpfull to identify the component in the list of scene components.
  62754. */
  62755. readonly name: string;
  62756. /**
  62757. * The scene the component belongs to.
  62758. */
  62759. scene: Scene;
  62760. /**
  62761. * Color of the bounding box lines placed in front of an object
  62762. */
  62763. frontColor: Color3;
  62764. /**
  62765. * Color of the bounding box lines placed behind an object
  62766. */
  62767. backColor: Color3;
  62768. /**
  62769. * Defines if the renderer should show the back lines or not
  62770. */
  62771. showBackLines: boolean;
  62772. /**
  62773. * @hidden
  62774. */
  62775. renderList: SmartArray<BoundingBox>;
  62776. private _colorShader;
  62777. private _vertexBuffers;
  62778. private _indexBuffer;
  62779. private _fillIndexBuffer;
  62780. private _fillIndexData;
  62781. /**
  62782. * Instantiates a new bounding box renderer in a scene.
  62783. * @param scene the scene the renderer renders in
  62784. */
  62785. constructor(scene: Scene);
  62786. /**
  62787. * Registers the component in a given scene
  62788. */
  62789. register(): void;
  62790. private _evaluateSubMesh;
  62791. private _activeMesh;
  62792. private _prepareRessources;
  62793. private _createIndexBuffer;
  62794. /**
  62795. * Rebuilds the elements related to this component in case of
  62796. * context lost for instance.
  62797. */
  62798. rebuild(): void;
  62799. /**
  62800. * @hidden
  62801. */
  62802. reset(): void;
  62803. /**
  62804. * Render the bounding boxes of a specific rendering group
  62805. * @param renderingGroupId defines the rendering group to render
  62806. */
  62807. render(renderingGroupId: number): void;
  62808. /**
  62809. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62810. * @param mesh Define the mesh to render the occlusion bounding box for
  62811. */
  62812. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62813. /**
  62814. * Dispose and release the resources attached to this renderer.
  62815. */
  62816. dispose(): void;
  62817. }
  62818. }
  62819. declare module "babylonjs/Shaders/depth.fragment" {
  62820. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62821. /** @hidden */
  62822. export var depthPixelShader: {
  62823. name: string;
  62824. shader: string;
  62825. };
  62826. }
  62827. declare module "babylonjs/Rendering/depthRenderer" {
  62828. import { Nullable } from "babylonjs/types";
  62829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62830. import { Scene } from "babylonjs/scene";
  62831. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62832. import { Camera } from "babylonjs/Cameras/camera";
  62833. import "babylonjs/Shaders/depth.fragment";
  62834. import "babylonjs/Shaders/depth.vertex";
  62835. /**
  62836. * This represents a depth renderer in Babylon.
  62837. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62838. */
  62839. export class DepthRenderer {
  62840. private _scene;
  62841. private _depthMap;
  62842. private _effect;
  62843. private readonly _storeNonLinearDepth;
  62844. private readonly _clearColor;
  62845. /** Get if the depth renderer is using packed depth or not */
  62846. readonly isPacked: boolean;
  62847. private _cachedDefines;
  62848. private _camera;
  62849. /**
  62850. * Specifiess that the depth renderer will only be used within
  62851. * the camera it is created for.
  62852. * This can help forcing its rendering during the camera processing.
  62853. */
  62854. useOnlyInActiveCamera: boolean;
  62855. /** @hidden */
  62856. static _SceneComponentInitialization: (scene: Scene) => void;
  62857. /**
  62858. * Instantiates a depth renderer
  62859. * @param scene The scene the renderer belongs to
  62860. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62861. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62862. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62863. */
  62864. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62865. /**
  62866. * Creates the depth rendering effect and checks if the effect is ready.
  62867. * @param subMesh The submesh to be used to render the depth map of
  62868. * @param useInstances If multiple world instances should be used
  62869. * @returns if the depth renderer is ready to render the depth map
  62870. */
  62871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62872. /**
  62873. * Gets the texture which the depth map will be written to.
  62874. * @returns The depth map texture
  62875. */
  62876. getDepthMap(): RenderTargetTexture;
  62877. /**
  62878. * Disposes of the depth renderer.
  62879. */
  62880. dispose(): void;
  62881. }
  62882. }
  62883. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62884. import { Nullable } from "babylonjs/types";
  62885. import { Scene } from "babylonjs/scene";
  62886. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62887. import { Camera } from "babylonjs/Cameras/camera";
  62888. import { ISceneComponent } from "babylonjs/sceneComponent";
  62889. module "babylonjs/scene" {
  62890. interface Scene {
  62891. /** @hidden (Backing field) */
  62892. _depthRenderer: {
  62893. [id: string]: DepthRenderer;
  62894. };
  62895. /**
  62896. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62897. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62898. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62899. * @returns the created depth renderer
  62900. */
  62901. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62902. /**
  62903. * Disables a depth renderer for a given camera
  62904. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62905. */
  62906. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62907. }
  62908. }
  62909. /**
  62910. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62911. * in several rendering techniques.
  62912. */
  62913. export class DepthRendererSceneComponent implements ISceneComponent {
  62914. /**
  62915. * The component name helpfull to identify the component in the list of scene components.
  62916. */
  62917. readonly name: string;
  62918. /**
  62919. * The scene the component belongs to.
  62920. */
  62921. scene: Scene;
  62922. /**
  62923. * Creates a new instance of the component for the given scene
  62924. * @param scene Defines the scene to register the component in
  62925. */
  62926. constructor(scene: Scene);
  62927. /**
  62928. * Registers the component in a given scene
  62929. */
  62930. register(): void;
  62931. /**
  62932. * Rebuilds the elements related to this component in case of
  62933. * context lost for instance.
  62934. */
  62935. rebuild(): void;
  62936. /**
  62937. * Disposes the component and the associated ressources
  62938. */
  62939. dispose(): void;
  62940. private _gatherRenderTargets;
  62941. private _gatherActiveCameraRenderTargets;
  62942. }
  62943. }
  62944. declare module "babylonjs/Shaders/outline.fragment" {
  62945. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62946. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62947. /** @hidden */
  62948. export var outlinePixelShader: {
  62949. name: string;
  62950. shader: string;
  62951. };
  62952. }
  62953. declare module "babylonjs/Shaders/outline.vertex" {
  62954. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62956. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62957. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62958. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62959. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62960. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62961. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62962. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62963. /** @hidden */
  62964. export var outlineVertexShader: {
  62965. name: string;
  62966. shader: string;
  62967. };
  62968. }
  62969. declare module "babylonjs/Rendering/outlineRenderer" {
  62970. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62971. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62972. import { Scene } from "babylonjs/scene";
  62973. import { ISceneComponent } from "babylonjs/sceneComponent";
  62974. import "babylonjs/Shaders/outline.fragment";
  62975. import "babylonjs/Shaders/outline.vertex";
  62976. module "babylonjs/scene" {
  62977. interface Scene {
  62978. /** @hidden */
  62979. _outlineRenderer: OutlineRenderer;
  62980. /**
  62981. * Gets the outline renderer associated with the scene
  62982. * @returns a OutlineRenderer
  62983. */
  62984. getOutlineRenderer(): OutlineRenderer;
  62985. }
  62986. }
  62987. module "babylonjs/Meshes/abstractMesh" {
  62988. interface AbstractMesh {
  62989. /** @hidden (Backing field) */
  62990. _renderOutline: boolean;
  62991. /**
  62992. * Gets or sets a boolean indicating if the outline must be rendered as well
  62993. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62994. */
  62995. renderOutline: boolean;
  62996. /** @hidden (Backing field) */
  62997. _renderOverlay: boolean;
  62998. /**
  62999. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63000. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63001. */
  63002. renderOverlay: boolean;
  63003. }
  63004. }
  63005. /**
  63006. * This class is responsible to draw bothe outline/overlay of meshes.
  63007. * It should not be used directly but through the available method on mesh.
  63008. */
  63009. export class OutlineRenderer implements ISceneComponent {
  63010. /**
  63011. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63012. */
  63013. private static _StencilReference;
  63014. /**
  63015. * The name of the component. Each component must have a unique name.
  63016. */
  63017. name: string;
  63018. /**
  63019. * The scene the component belongs to.
  63020. */
  63021. scene: Scene;
  63022. /**
  63023. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63024. */
  63025. zOffset: number;
  63026. private _engine;
  63027. private _effect;
  63028. private _cachedDefines;
  63029. private _savedDepthWrite;
  63030. /**
  63031. * Instantiates a new outline renderer. (There could be only one per scene).
  63032. * @param scene Defines the scene it belongs to
  63033. */
  63034. constructor(scene: Scene);
  63035. /**
  63036. * Register the component to one instance of a scene.
  63037. */
  63038. register(): void;
  63039. /**
  63040. * Rebuilds the elements related to this component in case of
  63041. * context lost for instance.
  63042. */
  63043. rebuild(): void;
  63044. /**
  63045. * Disposes the component and the associated ressources.
  63046. */
  63047. dispose(): void;
  63048. /**
  63049. * Renders the outline in the canvas.
  63050. * @param subMesh Defines the sumesh to render
  63051. * @param batch Defines the batch of meshes in case of instances
  63052. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63053. */
  63054. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63055. /**
  63056. * Returns whether or not the outline renderer is ready for a given submesh.
  63057. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63058. * @param subMesh Defines the submesh to check readyness for
  63059. * @param useInstances Defines wheter wee are trying to render instances or not
  63060. * @returns true if ready otherwise false
  63061. */
  63062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63063. private _beforeRenderingMesh;
  63064. private _afterRenderingMesh;
  63065. }
  63066. }
  63067. declare module "babylonjs/Rendering/index" {
  63068. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63069. export * from "babylonjs/Rendering/depthRenderer";
  63070. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63071. export * from "babylonjs/Rendering/edgesRenderer";
  63072. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63073. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63074. export * from "babylonjs/Rendering/outlineRenderer";
  63075. export * from "babylonjs/Rendering/renderingGroup";
  63076. export * from "babylonjs/Rendering/renderingManager";
  63077. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63078. }
  63079. declare module "babylonjs/Sprites/spritePackedManager" {
  63080. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63081. import { Scene } from "babylonjs/scene";
  63082. /**
  63083. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63084. * @see http://doc.babylonjs.com/babylon101/sprites
  63085. */
  63086. export class SpritePackedManager extends SpriteManager {
  63087. /** defines the packed manager's name */
  63088. name: string;
  63089. /**
  63090. * Creates a new sprite manager from a packed sprite sheet
  63091. * @param name defines the manager's name
  63092. * @param imgUrl defines the sprite sheet url
  63093. * @param capacity defines the maximum allowed number of sprites
  63094. * @param scene defines the hosting scene
  63095. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63096. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63097. * @param samplingMode defines the smapling mode to use with spritesheet
  63098. * @param fromPacked set to true; do not alter
  63099. */
  63100. constructor(
  63101. /** defines the packed manager's name */
  63102. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63103. }
  63104. }
  63105. declare module "babylonjs/Sprites/index" {
  63106. export * from "babylonjs/Sprites/sprite";
  63107. export * from "babylonjs/Sprites/spriteManager";
  63108. export * from "babylonjs/Sprites/spritePackedManager";
  63109. export * from "babylonjs/Sprites/spriteSceneComponent";
  63110. }
  63111. declare module "babylonjs/Misc/assetsManager" {
  63112. import { Scene } from "babylonjs/scene";
  63113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63114. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63115. import { Skeleton } from "babylonjs/Bones/skeleton";
  63116. import { Observable } from "babylonjs/Misc/observable";
  63117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63118. import { Texture } from "babylonjs/Materials/Textures/texture";
  63119. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63120. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63121. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63122. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63123. /**
  63124. * Defines the list of states available for a task inside a AssetsManager
  63125. */
  63126. export enum AssetTaskState {
  63127. /**
  63128. * Initialization
  63129. */
  63130. INIT = 0,
  63131. /**
  63132. * Running
  63133. */
  63134. RUNNING = 1,
  63135. /**
  63136. * Done
  63137. */
  63138. DONE = 2,
  63139. /**
  63140. * Error
  63141. */
  63142. ERROR = 3
  63143. }
  63144. /**
  63145. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63146. */
  63147. export abstract class AbstractAssetTask {
  63148. /**
  63149. * Task name
  63150. */ name: string;
  63151. /**
  63152. * Callback called when the task is successful
  63153. */
  63154. onSuccess: (task: any) => void;
  63155. /**
  63156. * Callback called when the task is not successful
  63157. */
  63158. onError: (task: any, message?: string, exception?: any) => void;
  63159. /**
  63160. * Creates a new AssetsManager
  63161. * @param name defines the name of the task
  63162. */
  63163. constructor(
  63164. /**
  63165. * Task name
  63166. */ name: string);
  63167. private _isCompleted;
  63168. private _taskState;
  63169. private _errorObject;
  63170. /**
  63171. * Get if the task is completed
  63172. */
  63173. readonly isCompleted: boolean;
  63174. /**
  63175. * Gets the current state of the task
  63176. */
  63177. readonly taskState: AssetTaskState;
  63178. /**
  63179. * Gets the current error object (if task is in error)
  63180. */
  63181. readonly errorObject: {
  63182. message?: string;
  63183. exception?: any;
  63184. };
  63185. /**
  63186. * Internal only
  63187. * @hidden
  63188. */
  63189. _setErrorObject(message?: string, exception?: any): void;
  63190. /**
  63191. * Execute the current task
  63192. * @param scene defines the scene where you want your assets to be loaded
  63193. * @param onSuccess is a callback called when the task is successfully executed
  63194. * @param onError is a callback called if an error occurs
  63195. */
  63196. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63197. /**
  63198. * Execute the current task
  63199. * @param scene defines the scene where you want your assets to be loaded
  63200. * @param onSuccess is a callback called when the task is successfully executed
  63201. * @param onError is a callback called if an error occurs
  63202. */
  63203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63204. /**
  63205. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63206. * This can be used with failed tasks that have the reason for failure fixed.
  63207. */
  63208. reset(): void;
  63209. private onErrorCallback;
  63210. private onDoneCallback;
  63211. }
  63212. /**
  63213. * Define the interface used by progress events raised during assets loading
  63214. */
  63215. export interface IAssetsProgressEvent {
  63216. /**
  63217. * Defines the number of remaining tasks to process
  63218. */
  63219. remainingCount: number;
  63220. /**
  63221. * Defines the total number of tasks
  63222. */
  63223. totalCount: number;
  63224. /**
  63225. * Defines the task that was just processed
  63226. */
  63227. task: AbstractAssetTask;
  63228. }
  63229. /**
  63230. * Class used to share progress information about assets loading
  63231. */
  63232. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63233. /**
  63234. * Defines the number of remaining tasks to process
  63235. */
  63236. remainingCount: number;
  63237. /**
  63238. * Defines the total number of tasks
  63239. */
  63240. totalCount: number;
  63241. /**
  63242. * Defines the task that was just processed
  63243. */
  63244. task: AbstractAssetTask;
  63245. /**
  63246. * Creates a AssetsProgressEvent
  63247. * @param remainingCount defines the number of remaining tasks to process
  63248. * @param totalCount defines the total number of tasks
  63249. * @param task defines the task that was just processed
  63250. */
  63251. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63252. }
  63253. /**
  63254. * Define a task used by AssetsManager to load meshes
  63255. */
  63256. export class MeshAssetTask extends AbstractAssetTask {
  63257. /**
  63258. * Defines the name of the task
  63259. */
  63260. name: string;
  63261. /**
  63262. * Defines the list of mesh's names you want to load
  63263. */
  63264. meshesNames: any;
  63265. /**
  63266. * Defines the root url to use as a base to load your meshes and associated resources
  63267. */
  63268. rootUrl: string;
  63269. /**
  63270. * Defines the filename of the scene to load from
  63271. */
  63272. sceneFilename: string;
  63273. /**
  63274. * Gets the list of loaded meshes
  63275. */
  63276. loadedMeshes: Array<AbstractMesh>;
  63277. /**
  63278. * Gets the list of loaded particle systems
  63279. */
  63280. loadedParticleSystems: Array<IParticleSystem>;
  63281. /**
  63282. * Gets the list of loaded skeletons
  63283. */
  63284. loadedSkeletons: Array<Skeleton>;
  63285. /**
  63286. * Gets the list of loaded animation groups
  63287. */
  63288. loadedAnimationGroups: Array<AnimationGroup>;
  63289. /**
  63290. * Callback called when the task is successful
  63291. */
  63292. onSuccess: (task: MeshAssetTask) => void;
  63293. /**
  63294. * Callback called when the task is successful
  63295. */
  63296. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63297. /**
  63298. * Creates a new MeshAssetTask
  63299. * @param name defines the name of the task
  63300. * @param meshesNames defines the list of mesh's names you want to load
  63301. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63302. * @param sceneFilename defines the filename of the scene to load from
  63303. */
  63304. constructor(
  63305. /**
  63306. * Defines the name of the task
  63307. */
  63308. name: string,
  63309. /**
  63310. * Defines the list of mesh's names you want to load
  63311. */
  63312. meshesNames: any,
  63313. /**
  63314. * Defines the root url to use as a base to load your meshes and associated resources
  63315. */
  63316. rootUrl: string,
  63317. /**
  63318. * Defines the filename of the scene to load from
  63319. */
  63320. sceneFilename: string);
  63321. /**
  63322. * Execute the current task
  63323. * @param scene defines the scene where you want your assets to be loaded
  63324. * @param onSuccess is a callback called when the task is successfully executed
  63325. * @param onError is a callback called if an error occurs
  63326. */
  63327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63328. }
  63329. /**
  63330. * Define a task used by AssetsManager to load text content
  63331. */
  63332. export class TextFileAssetTask extends AbstractAssetTask {
  63333. /**
  63334. * Defines the name of the task
  63335. */
  63336. name: string;
  63337. /**
  63338. * Defines the location of the file to load
  63339. */
  63340. url: string;
  63341. /**
  63342. * Gets the loaded text string
  63343. */
  63344. text: string;
  63345. /**
  63346. * Callback called when the task is successful
  63347. */
  63348. onSuccess: (task: TextFileAssetTask) => void;
  63349. /**
  63350. * Callback called when the task is successful
  63351. */
  63352. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63353. /**
  63354. * Creates a new TextFileAssetTask object
  63355. * @param name defines the name of the task
  63356. * @param url defines the location of the file to load
  63357. */
  63358. constructor(
  63359. /**
  63360. * Defines the name of the task
  63361. */
  63362. name: string,
  63363. /**
  63364. * Defines the location of the file to load
  63365. */
  63366. url: string);
  63367. /**
  63368. * Execute the current task
  63369. * @param scene defines the scene where you want your assets to be loaded
  63370. * @param onSuccess is a callback called when the task is successfully executed
  63371. * @param onError is a callback called if an error occurs
  63372. */
  63373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63374. }
  63375. /**
  63376. * Define a task used by AssetsManager to load binary data
  63377. */
  63378. export class BinaryFileAssetTask extends AbstractAssetTask {
  63379. /**
  63380. * Defines the name of the task
  63381. */
  63382. name: string;
  63383. /**
  63384. * Defines the location of the file to load
  63385. */
  63386. url: string;
  63387. /**
  63388. * Gets the lodaded data (as an array buffer)
  63389. */
  63390. data: ArrayBuffer;
  63391. /**
  63392. * Callback called when the task is successful
  63393. */
  63394. onSuccess: (task: BinaryFileAssetTask) => void;
  63395. /**
  63396. * Callback called when the task is successful
  63397. */
  63398. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63399. /**
  63400. * Creates a new BinaryFileAssetTask object
  63401. * @param name defines the name of the new task
  63402. * @param url defines the location of the file to load
  63403. */
  63404. constructor(
  63405. /**
  63406. * Defines the name of the task
  63407. */
  63408. name: string,
  63409. /**
  63410. * Defines the location of the file to load
  63411. */
  63412. url: string);
  63413. /**
  63414. * Execute the current task
  63415. * @param scene defines the scene where you want your assets to be loaded
  63416. * @param onSuccess is a callback called when the task is successfully executed
  63417. * @param onError is a callback called if an error occurs
  63418. */
  63419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63420. }
  63421. /**
  63422. * Define a task used by AssetsManager to load images
  63423. */
  63424. export class ImageAssetTask extends AbstractAssetTask {
  63425. /**
  63426. * Defines the name of the task
  63427. */
  63428. name: string;
  63429. /**
  63430. * Defines the location of the image to load
  63431. */
  63432. url: string;
  63433. /**
  63434. * Gets the loaded images
  63435. */
  63436. image: HTMLImageElement;
  63437. /**
  63438. * Callback called when the task is successful
  63439. */
  63440. onSuccess: (task: ImageAssetTask) => void;
  63441. /**
  63442. * Callback called when the task is successful
  63443. */
  63444. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63445. /**
  63446. * Creates a new ImageAssetTask
  63447. * @param name defines the name of the task
  63448. * @param url defines the location of the image to load
  63449. */
  63450. constructor(
  63451. /**
  63452. * Defines the name of the task
  63453. */
  63454. name: string,
  63455. /**
  63456. * Defines the location of the image to load
  63457. */
  63458. url: string);
  63459. /**
  63460. * Execute the current task
  63461. * @param scene defines the scene where you want your assets to be loaded
  63462. * @param onSuccess is a callback called when the task is successfully executed
  63463. * @param onError is a callback called if an error occurs
  63464. */
  63465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63466. }
  63467. /**
  63468. * Defines the interface used by texture loading tasks
  63469. */
  63470. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63471. /**
  63472. * Gets the loaded texture
  63473. */
  63474. texture: TEX;
  63475. }
  63476. /**
  63477. * Define a task used by AssetsManager to load 2D textures
  63478. */
  63479. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63480. /**
  63481. * Defines the name of the task
  63482. */
  63483. name: string;
  63484. /**
  63485. * Defines the location of the file to load
  63486. */
  63487. url: string;
  63488. /**
  63489. * Defines if mipmap should not be generated (default is false)
  63490. */
  63491. noMipmap?: boolean | undefined;
  63492. /**
  63493. * Defines if texture must be inverted on Y axis (default is false)
  63494. */
  63495. invertY?: boolean | undefined;
  63496. /**
  63497. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63498. */
  63499. samplingMode: number;
  63500. /**
  63501. * Gets the loaded texture
  63502. */
  63503. texture: Texture;
  63504. /**
  63505. * Callback called when the task is successful
  63506. */
  63507. onSuccess: (task: TextureAssetTask) => void;
  63508. /**
  63509. * Callback called when the task is successful
  63510. */
  63511. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63512. /**
  63513. * Creates a new TextureAssetTask object
  63514. * @param name defines the name of the task
  63515. * @param url defines the location of the file to load
  63516. * @param noMipmap defines if mipmap should not be generated (default is false)
  63517. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63518. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63519. */
  63520. constructor(
  63521. /**
  63522. * Defines the name of the task
  63523. */
  63524. name: string,
  63525. /**
  63526. * Defines the location of the file to load
  63527. */
  63528. url: string,
  63529. /**
  63530. * Defines if mipmap should not be generated (default is false)
  63531. */
  63532. noMipmap?: boolean | undefined,
  63533. /**
  63534. * Defines if texture must be inverted on Y axis (default is false)
  63535. */
  63536. invertY?: boolean | undefined,
  63537. /**
  63538. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63539. */
  63540. samplingMode?: number);
  63541. /**
  63542. * Execute the current task
  63543. * @param scene defines the scene where you want your assets to be loaded
  63544. * @param onSuccess is a callback called when the task is successfully executed
  63545. * @param onError is a callback called if an error occurs
  63546. */
  63547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63548. }
  63549. /**
  63550. * Define a task used by AssetsManager to load cube textures
  63551. */
  63552. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63553. /**
  63554. * Defines the name of the task
  63555. */
  63556. name: string;
  63557. /**
  63558. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63559. */
  63560. url: string;
  63561. /**
  63562. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63563. */
  63564. extensions?: string[] | undefined;
  63565. /**
  63566. * Defines if mipmaps should not be generated (default is false)
  63567. */
  63568. noMipmap?: boolean | undefined;
  63569. /**
  63570. * Defines the explicit list of files (undefined by default)
  63571. */
  63572. files?: string[] | undefined;
  63573. /**
  63574. * Gets the loaded texture
  63575. */
  63576. texture: CubeTexture;
  63577. /**
  63578. * Callback called when the task is successful
  63579. */
  63580. onSuccess: (task: CubeTextureAssetTask) => void;
  63581. /**
  63582. * Callback called when the task is successful
  63583. */
  63584. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63585. /**
  63586. * Creates a new CubeTextureAssetTask
  63587. * @param name defines the name of the task
  63588. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63589. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63590. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63591. * @param files defines the explicit list of files (undefined by default)
  63592. */
  63593. constructor(
  63594. /**
  63595. * Defines the name of the task
  63596. */
  63597. name: string,
  63598. /**
  63599. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63600. */
  63601. url: string,
  63602. /**
  63603. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63604. */
  63605. extensions?: string[] | undefined,
  63606. /**
  63607. * Defines if mipmaps should not be generated (default is false)
  63608. */
  63609. noMipmap?: boolean | undefined,
  63610. /**
  63611. * Defines the explicit list of files (undefined by default)
  63612. */
  63613. files?: string[] | undefined);
  63614. /**
  63615. * Execute the current task
  63616. * @param scene defines the scene where you want your assets to be loaded
  63617. * @param onSuccess is a callback called when the task is successfully executed
  63618. * @param onError is a callback called if an error occurs
  63619. */
  63620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63621. }
  63622. /**
  63623. * Define a task used by AssetsManager to load HDR cube textures
  63624. */
  63625. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63626. /**
  63627. * Defines the name of the task
  63628. */
  63629. name: string;
  63630. /**
  63631. * Defines the location of the file to load
  63632. */
  63633. url: string;
  63634. /**
  63635. * Defines the desired size (the more it increases the longer the generation will be)
  63636. */
  63637. size: number;
  63638. /**
  63639. * Defines if mipmaps should not be generated (default is false)
  63640. */
  63641. noMipmap: boolean;
  63642. /**
  63643. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63644. */
  63645. generateHarmonics: boolean;
  63646. /**
  63647. * 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)
  63648. */
  63649. gammaSpace: boolean;
  63650. /**
  63651. * Internal Use Only
  63652. */
  63653. reserved: boolean;
  63654. /**
  63655. * Gets the loaded texture
  63656. */
  63657. texture: HDRCubeTexture;
  63658. /**
  63659. * Callback called when the task is successful
  63660. */
  63661. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63662. /**
  63663. * Callback called when the task is successful
  63664. */
  63665. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63666. /**
  63667. * Creates a new HDRCubeTextureAssetTask object
  63668. * @param name defines the name of the task
  63669. * @param url defines the location of the file to load
  63670. * @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.
  63671. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63672. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63673. * @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)
  63674. * @param reserved Internal use only
  63675. */
  63676. constructor(
  63677. /**
  63678. * Defines the name of the task
  63679. */
  63680. name: string,
  63681. /**
  63682. * Defines the location of the file to load
  63683. */
  63684. url: string,
  63685. /**
  63686. * Defines the desired size (the more it increases the longer the generation will be)
  63687. */
  63688. size: number,
  63689. /**
  63690. * Defines if mipmaps should not be generated (default is false)
  63691. */
  63692. noMipmap?: boolean,
  63693. /**
  63694. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63695. */
  63696. generateHarmonics?: boolean,
  63697. /**
  63698. * 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)
  63699. */
  63700. gammaSpace?: boolean,
  63701. /**
  63702. * Internal Use Only
  63703. */
  63704. reserved?: boolean);
  63705. /**
  63706. * Execute the current task
  63707. * @param scene defines the scene where you want your assets to be loaded
  63708. * @param onSuccess is a callback called when the task is successfully executed
  63709. * @param onError is a callback called if an error occurs
  63710. */
  63711. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63712. }
  63713. /**
  63714. * Define a task used by AssetsManager to load Equirectangular cube textures
  63715. */
  63716. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63717. /**
  63718. * Defines the name of the task
  63719. */
  63720. name: string;
  63721. /**
  63722. * Defines the location of the file to load
  63723. */
  63724. url: string;
  63725. /**
  63726. * Defines the desired size (the more it increases the longer the generation will be)
  63727. */
  63728. size: number;
  63729. /**
  63730. * Defines if mipmaps should not be generated (default is false)
  63731. */
  63732. noMipmap: boolean;
  63733. /**
  63734. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63735. * but the standard material would require them in Gamma space) (default is true)
  63736. */
  63737. gammaSpace: boolean;
  63738. /**
  63739. * Gets the loaded texture
  63740. */
  63741. texture: EquiRectangularCubeTexture;
  63742. /**
  63743. * Callback called when the task is successful
  63744. */
  63745. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63746. /**
  63747. * Callback called when the task is successful
  63748. */
  63749. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63750. /**
  63751. * Creates a new EquiRectangularCubeTextureAssetTask object
  63752. * @param name defines the name of the task
  63753. * @param url defines the location of the file to load
  63754. * @param size defines the desired size (the more it increases the longer the generation will be)
  63755. * If the size is omitted this implies you are using a preprocessed cubemap.
  63756. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63757. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63758. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63759. * (default is true)
  63760. */
  63761. constructor(
  63762. /**
  63763. * Defines the name of the task
  63764. */
  63765. name: string,
  63766. /**
  63767. * Defines the location of the file to load
  63768. */
  63769. url: string,
  63770. /**
  63771. * Defines the desired size (the more it increases the longer the generation will be)
  63772. */
  63773. size: number,
  63774. /**
  63775. * Defines if mipmaps should not be generated (default is false)
  63776. */
  63777. noMipmap?: boolean,
  63778. /**
  63779. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63780. * but the standard material would require them in Gamma space) (default is true)
  63781. */
  63782. gammaSpace?: boolean);
  63783. /**
  63784. * Execute the current task
  63785. * @param scene defines the scene where you want your assets to be loaded
  63786. * @param onSuccess is a callback called when the task is successfully executed
  63787. * @param onError is a callback called if an error occurs
  63788. */
  63789. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63790. }
  63791. /**
  63792. * This class can be used to easily import assets into a scene
  63793. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63794. */
  63795. export class AssetsManager {
  63796. private _scene;
  63797. private _isLoading;
  63798. protected _tasks: AbstractAssetTask[];
  63799. protected _waitingTasksCount: number;
  63800. protected _totalTasksCount: number;
  63801. /**
  63802. * Callback called when all tasks are processed
  63803. */
  63804. onFinish: (tasks: AbstractAssetTask[]) => void;
  63805. /**
  63806. * Callback called when a task is successful
  63807. */
  63808. onTaskSuccess: (task: AbstractAssetTask) => void;
  63809. /**
  63810. * Callback called when a task had an error
  63811. */
  63812. onTaskError: (task: AbstractAssetTask) => void;
  63813. /**
  63814. * Callback called when a task is done (whatever the result is)
  63815. */
  63816. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63817. /**
  63818. * Observable called when all tasks are processed
  63819. */
  63820. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63821. /**
  63822. * Observable called when a task had an error
  63823. */
  63824. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63825. /**
  63826. * Observable called when all tasks were executed
  63827. */
  63828. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63829. /**
  63830. * Observable called when a task is done (whatever the result is)
  63831. */
  63832. onProgressObservable: Observable<IAssetsProgressEvent>;
  63833. /**
  63834. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63835. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63836. */
  63837. useDefaultLoadingScreen: boolean;
  63838. /**
  63839. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63840. * when all assets have been downloaded.
  63841. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63842. */
  63843. autoHideLoadingUI: boolean;
  63844. /**
  63845. * Creates a new AssetsManager
  63846. * @param scene defines the scene to work on
  63847. */
  63848. constructor(scene: Scene);
  63849. /**
  63850. * Add a MeshAssetTask to the list of active tasks
  63851. * @param taskName defines the name of the new task
  63852. * @param meshesNames defines the name of meshes to load
  63853. * @param rootUrl defines the root url to use to locate files
  63854. * @param sceneFilename defines the filename of the scene file
  63855. * @returns a new MeshAssetTask object
  63856. */
  63857. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63858. /**
  63859. * Add a TextFileAssetTask to the list of active tasks
  63860. * @param taskName defines the name of the new task
  63861. * @param url defines the url of the file to load
  63862. * @returns a new TextFileAssetTask object
  63863. */
  63864. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63865. /**
  63866. * Add a BinaryFileAssetTask to the list of active tasks
  63867. * @param taskName defines the name of the new task
  63868. * @param url defines the url of the file to load
  63869. * @returns a new BinaryFileAssetTask object
  63870. */
  63871. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63872. /**
  63873. * Add a ImageAssetTask to the list of active tasks
  63874. * @param taskName defines the name of the new task
  63875. * @param url defines the url of the file to load
  63876. * @returns a new ImageAssetTask object
  63877. */
  63878. addImageTask(taskName: string, url: string): ImageAssetTask;
  63879. /**
  63880. * Add a TextureAssetTask to the list of active tasks
  63881. * @param taskName defines the name of the new task
  63882. * @param url defines the url of the file to load
  63883. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63884. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63885. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63886. * @returns a new TextureAssetTask object
  63887. */
  63888. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63889. /**
  63890. * Add a CubeTextureAssetTask to the list of active tasks
  63891. * @param taskName defines the name of the new task
  63892. * @param url defines the url of the file to load
  63893. * @param extensions defines the extension to use to load the cube map (can be null)
  63894. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63895. * @param files defines the list of files to load (can be null)
  63896. * @returns a new CubeTextureAssetTask object
  63897. */
  63898. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63899. /**
  63900. *
  63901. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63902. * @param taskName defines the name of the new task
  63903. * @param url defines the url of the file to load
  63904. * @param size defines the size you want for the cubemap (can be null)
  63905. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63906. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63907. * @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)
  63908. * @param reserved Internal use only
  63909. * @returns a new HDRCubeTextureAssetTask object
  63910. */
  63911. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63912. /**
  63913. *
  63914. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63915. * @param taskName defines the name of the new task
  63916. * @param url defines the url of the file to load
  63917. * @param size defines the size you want for the cubemap (can be null)
  63918. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63919. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63920. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63921. * @returns a new EquiRectangularCubeTextureAssetTask object
  63922. */
  63923. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63924. /**
  63925. * Remove a task from the assets manager.
  63926. * @param task the task to remove
  63927. */
  63928. removeTask(task: AbstractAssetTask): void;
  63929. private _decreaseWaitingTasksCount;
  63930. private _runTask;
  63931. /**
  63932. * Reset the AssetsManager and remove all tasks
  63933. * @return the current instance of the AssetsManager
  63934. */
  63935. reset(): AssetsManager;
  63936. /**
  63937. * Start the loading process
  63938. * @return the current instance of the AssetsManager
  63939. */
  63940. load(): AssetsManager;
  63941. /**
  63942. * Start the loading process as an async operation
  63943. * @return a promise returning the list of failed tasks
  63944. */
  63945. loadAsync(): Promise<void>;
  63946. }
  63947. }
  63948. declare module "babylonjs/Misc/deferred" {
  63949. /**
  63950. * Wrapper class for promise with external resolve and reject.
  63951. */
  63952. export class Deferred<T> {
  63953. /**
  63954. * The promise associated with this deferred object.
  63955. */
  63956. readonly promise: Promise<T>;
  63957. private _resolve;
  63958. private _reject;
  63959. /**
  63960. * The resolve method of the promise associated with this deferred object.
  63961. */
  63962. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63963. /**
  63964. * The reject method of the promise associated with this deferred object.
  63965. */
  63966. readonly reject: (reason?: any) => void;
  63967. /**
  63968. * Constructor for this deferred object.
  63969. */
  63970. constructor();
  63971. }
  63972. }
  63973. declare module "babylonjs/Misc/meshExploder" {
  63974. import { Mesh } from "babylonjs/Meshes/mesh";
  63975. /**
  63976. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63977. */
  63978. export class MeshExploder {
  63979. private _centerMesh;
  63980. private _meshes;
  63981. private _meshesOrigins;
  63982. private _toCenterVectors;
  63983. private _scaledDirection;
  63984. private _newPosition;
  63985. private _centerPosition;
  63986. /**
  63987. * Explodes meshes from a center mesh.
  63988. * @param meshes The meshes to explode.
  63989. * @param centerMesh The mesh to be center of explosion.
  63990. */
  63991. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63992. private _setCenterMesh;
  63993. /**
  63994. * Get class name
  63995. * @returns "MeshExploder"
  63996. */
  63997. getClassName(): string;
  63998. /**
  63999. * "Exploded meshes"
  64000. * @returns Array of meshes with the centerMesh at index 0.
  64001. */
  64002. getMeshes(): Array<Mesh>;
  64003. /**
  64004. * Explodes meshes giving a specific direction
  64005. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64006. */
  64007. explode(direction?: number): void;
  64008. }
  64009. }
  64010. declare module "babylonjs/Misc/filesInput" {
  64011. import { Engine } from "babylonjs/Engines/engine";
  64012. import { Scene } from "babylonjs/scene";
  64013. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64014. /**
  64015. * Class used to help managing file picking and drag'n'drop
  64016. */
  64017. export class FilesInput {
  64018. /**
  64019. * List of files ready to be loaded
  64020. */
  64021. static readonly FilesToLoad: {
  64022. [key: string]: File;
  64023. };
  64024. /**
  64025. * Callback called when a file is processed
  64026. */
  64027. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64028. private _engine;
  64029. private _currentScene;
  64030. private _sceneLoadedCallback;
  64031. private _progressCallback;
  64032. private _additionalRenderLoopLogicCallback;
  64033. private _textureLoadingCallback;
  64034. private _startingProcessingFilesCallback;
  64035. private _onReloadCallback;
  64036. private _errorCallback;
  64037. private _elementToMonitor;
  64038. private _sceneFileToLoad;
  64039. private _filesToLoad;
  64040. /**
  64041. * Creates a new FilesInput
  64042. * @param engine defines the rendering engine
  64043. * @param scene defines the hosting scene
  64044. * @param sceneLoadedCallback callback called when scene is loaded
  64045. * @param progressCallback callback called to track progress
  64046. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64047. * @param textureLoadingCallback callback called when a texture is loading
  64048. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64049. * @param onReloadCallback callback called when a reload is requested
  64050. * @param errorCallback callback call if an error occurs
  64051. */
  64052. 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);
  64053. private _dragEnterHandler;
  64054. private _dragOverHandler;
  64055. private _dropHandler;
  64056. /**
  64057. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64058. * @param elementToMonitor defines the DOM element to track
  64059. */
  64060. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64061. /**
  64062. * Release all associated resources
  64063. */
  64064. dispose(): void;
  64065. private renderFunction;
  64066. private drag;
  64067. private drop;
  64068. private _traverseFolder;
  64069. private _processFiles;
  64070. /**
  64071. * Load files from a drop event
  64072. * @param event defines the drop event to use as source
  64073. */
  64074. loadFiles(event: any): void;
  64075. private _processReload;
  64076. /**
  64077. * Reload the current scene from the loaded files
  64078. */
  64079. reload(): void;
  64080. }
  64081. }
  64082. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64083. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64084. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64085. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64086. }
  64087. declare module "babylonjs/Misc/sceneOptimizer" {
  64088. import { Scene, IDisposable } from "babylonjs/scene";
  64089. import { Observable } from "babylonjs/Misc/observable";
  64090. /**
  64091. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64093. */
  64094. export class SceneOptimization {
  64095. /**
  64096. * Defines the priority of this optimization (0 by default which means first in the list)
  64097. */
  64098. priority: number;
  64099. /**
  64100. * Gets a string describing the action executed by the current optimization
  64101. * @returns description string
  64102. */
  64103. getDescription(): string;
  64104. /**
  64105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64106. * @param scene defines the current scene where to apply this optimization
  64107. * @param optimizer defines the current optimizer
  64108. * @returns true if everything that can be done was applied
  64109. */
  64110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64111. /**
  64112. * Creates the SceneOptimization object
  64113. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64114. * @param desc defines the description associated with the optimization
  64115. */
  64116. constructor(
  64117. /**
  64118. * Defines the priority of this optimization (0 by default which means first in the list)
  64119. */
  64120. priority?: number);
  64121. }
  64122. /**
  64123. * Defines an optimization used to reduce the size of render target textures
  64124. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64125. */
  64126. export class TextureOptimization extends SceneOptimization {
  64127. /**
  64128. * Defines the priority of this optimization (0 by default which means first in the list)
  64129. */
  64130. priority: number;
  64131. /**
  64132. * 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
  64133. */
  64134. maximumSize: number;
  64135. /**
  64136. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64137. */
  64138. step: number;
  64139. /**
  64140. * Gets a string describing the action executed by the current optimization
  64141. * @returns description string
  64142. */
  64143. getDescription(): string;
  64144. /**
  64145. * Creates the TextureOptimization object
  64146. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64147. * @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
  64148. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64149. */
  64150. constructor(
  64151. /**
  64152. * Defines the priority of this optimization (0 by default which means first in the list)
  64153. */
  64154. priority?: number,
  64155. /**
  64156. * 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
  64157. */
  64158. maximumSize?: number,
  64159. /**
  64160. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64161. */
  64162. step?: number);
  64163. /**
  64164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64165. * @param scene defines the current scene where to apply this optimization
  64166. * @param optimizer defines the current optimizer
  64167. * @returns true if everything that can be done was applied
  64168. */
  64169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64170. }
  64171. /**
  64172. * Defines an optimization used to increase or decrease the rendering resolution
  64173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64174. */
  64175. export class HardwareScalingOptimization extends SceneOptimization {
  64176. /**
  64177. * Defines the priority of this optimization (0 by default which means first in the list)
  64178. */
  64179. priority: number;
  64180. /**
  64181. * Defines the maximum scale to use (2 by default)
  64182. */
  64183. maximumScale: number;
  64184. /**
  64185. * Defines the step to use between two passes (0.5 by default)
  64186. */
  64187. step: number;
  64188. private _currentScale;
  64189. private _directionOffset;
  64190. /**
  64191. * Gets a string describing the action executed by the current optimization
  64192. * @return description string
  64193. */
  64194. getDescription(): string;
  64195. /**
  64196. * Creates the HardwareScalingOptimization object
  64197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64198. * @param maximumScale defines the maximum scale to use (2 by default)
  64199. * @param step defines the step to use between two passes (0.5 by default)
  64200. */
  64201. constructor(
  64202. /**
  64203. * Defines the priority of this optimization (0 by default which means first in the list)
  64204. */
  64205. priority?: number,
  64206. /**
  64207. * Defines the maximum scale to use (2 by default)
  64208. */
  64209. maximumScale?: number,
  64210. /**
  64211. * Defines the step to use between two passes (0.5 by default)
  64212. */
  64213. step?: number);
  64214. /**
  64215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64216. * @param scene defines the current scene where to apply this optimization
  64217. * @param optimizer defines the current optimizer
  64218. * @returns true if everything that can be done was applied
  64219. */
  64220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64221. }
  64222. /**
  64223. * Defines an optimization used to remove shadows
  64224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64225. */
  64226. export class ShadowsOptimization extends SceneOptimization {
  64227. /**
  64228. * Gets a string describing the action executed by the current optimization
  64229. * @return description string
  64230. */
  64231. getDescription(): string;
  64232. /**
  64233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64234. * @param scene defines the current scene where to apply this optimization
  64235. * @param optimizer defines the current optimizer
  64236. * @returns true if everything that can be done was applied
  64237. */
  64238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64239. }
  64240. /**
  64241. * Defines an optimization used to turn post-processes off
  64242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64243. */
  64244. export class PostProcessesOptimization extends SceneOptimization {
  64245. /**
  64246. * Gets a string describing the action executed by the current optimization
  64247. * @return description string
  64248. */
  64249. getDescription(): string;
  64250. /**
  64251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64252. * @param scene defines the current scene where to apply this optimization
  64253. * @param optimizer defines the current optimizer
  64254. * @returns true if everything that can be done was applied
  64255. */
  64256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64257. }
  64258. /**
  64259. * Defines an optimization used to turn lens flares off
  64260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64261. */
  64262. export class LensFlaresOptimization extends SceneOptimization {
  64263. /**
  64264. * Gets a string describing the action executed by the current optimization
  64265. * @return description string
  64266. */
  64267. getDescription(): string;
  64268. /**
  64269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64270. * @param scene defines the current scene where to apply this optimization
  64271. * @param optimizer defines the current optimizer
  64272. * @returns true if everything that can be done was applied
  64273. */
  64274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64275. }
  64276. /**
  64277. * Defines an optimization based on user defined callback.
  64278. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64279. */
  64280. export class CustomOptimization extends SceneOptimization {
  64281. /**
  64282. * Callback called to apply the custom optimization.
  64283. */
  64284. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64285. /**
  64286. * Callback called to get custom description
  64287. */
  64288. onGetDescription: () => string;
  64289. /**
  64290. * Gets a string describing the action executed by the current optimization
  64291. * @returns description string
  64292. */
  64293. getDescription(): string;
  64294. /**
  64295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64296. * @param scene defines the current scene where to apply this optimization
  64297. * @param optimizer defines the current optimizer
  64298. * @returns true if everything that can be done was applied
  64299. */
  64300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64301. }
  64302. /**
  64303. * Defines an optimization used to turn particles off
  64304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64305. */
  64306. export class ParticlesOptimization extends SceneOptimization {
  64307. /**
  64308. * Gets a string describing the action executed by the current optimization
  64309. * @return description string
  64310. */
  64311. getDescription(): string;
  64312. /**
  64313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64314. * @param scene defines the current scene where to apply this optimization
  64315. * @param optimizer defines the current optimizer
  64316. * @returns true if everything that can be done was applied
  64317. */
  64318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64319. }
  64320. /**
  64321. * Defines an optimization used to turn render targets off
  64322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64323. */
  64324. export class RenderTargetsOptimization extends SceneOptimization {
  64325. /**
  64326. * Gets a string describing the action executed by the current optimization
  64327. * @return description string
  64328. */
  64329. getDescription(): string;
  64330. /**
  64331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64332. * @param scene defines the current scene where to apply this optimization
  64333. * @param optimizer defines the current optimizer
  64334. * @returns true if everything that can be done was applied
  64335. */
  64336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64337. }
  64338. /**
  64339. * Defines an optimization used to merge meshes with compatible materials
  64340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64341. */
  64342. export class MergeMeshesOptimization extends SceneOptimization {
  64343. private static _UpdateSelectionTree;
  64344. /**
  64345. * Gets or sets a boolean which defines if optimization octree has to be updated
  64346. */
  64347. /**
  64348. * Gets or sets a boolean which defines if optimization octree has to be updated
  64349. */
  64350. static UpdateSelectionTree: boolean;
  64351. /**
  64352. * Gets a string describing the action executed by the current optimization
  64353. * @return description string
  64354. */
  64355. getDescription(): string;
  64356. private _canBeMerged;
  64357. /**
  64358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64359. * @param scene defines the current scene where to apply this optimization
  64360. * @param optimizer defines the current optimizer
  64361. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64362. * @returns true if everything that can be done was applied
  64363. */
  64364. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64365. }
  64366. /**
  64367. * Defines a list of options used by SceneOptimizer
  64368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64369. */
  64370. export class SceneOptimizerOptions {
  64371. /**
  64372. * Defines the target frame rate to reach (60 by default)
  64373. */
  64374. targetFrameRate: number;
  64375. /**
  64376. * Defines the interval between two checkes (2000ms by default)
  64377. */
  64378. trackerDuration: number;
  64379. /**
  64380. * Gets the list of optimizations to apply
  64381. */
  64382. optimizations: SceneOptimization[];
  64383. /**
  64384. * Creates a new list of options used by SceneOptimizer
  64385. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64386. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64387. */
  64388. constructor(
  64389. /**
  64390. * Defines the target frame rate to reach (60 by default)
  64391. */
  64392. targetFrameRate?: number,
  64393. /**
  64394. * Defines the interval between two checkes (2000ms by default)
  64395. */
  64396. trackerDuration?: number);
  64397. /**
  64398. * Add a new optimization
  64399. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64400. * @returns the current SceneOptimizerOptions
  64401. */
  64402. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64403. /**
  64404. * Add a new custom optimization
  64405. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64406. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64407. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64408. * @returns the current SceneOptimizerOptions
  64409. */
  64410. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64411. /**
  64412. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64413. * @param targetFrameRate defines the target frame rate (60 by default)
  64414. * @returns a SceneOptimizerOptions object
  64415. */
  64416. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64417. /**
  64418. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64419. * @param targetFrameRate defines the target frame rate (60 by default)
  64420. * @returns a SceneOptimizerOptions object
  64421. */
  64422. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64423. /**
  64424. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64425. * @param targetFrameRate defines the target frame rate (60 by default)
  64426. * @returns a SceneOptimizerOptions object
  64427. */
  64428. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64429. }
  64430. /**
  64431. * Class used to run optimizations in order to reach a target frame rate
  64432. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64433. */
  64434. export class SceneOptimizer implements IDisposable {
  64435. private _isRunning;
  64436. private _options;
  64437. private _scene;
  64438. private _currentPriorityLevel;
  64439. private _targetFrameRate;
  64440. private _trackerDuration;
  64441. private _currentFrameRate;
  64442. private _sceneDisposeObserver;
  64443. private _improvementMode;
  64444. /**
  64445. * Defines an observable called when the optimizer reaches the target frame rate
  64446. */
  64447. onSuccessObservable: Observable<SceneOptimizer>;
  64448. /**
  64449. * Defines an observable called when the optimizer enables an optimization
  64450. */
  64451. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64452. /**
  64453. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64454. */
  64455. onFailureObservable: Observable<SceneOptimizer>;
  64456. /**
  64457. * Gets a boolean indicating if the optimizer is in improvement mode
  64458. */
  64459. readonly isInImprovementMode: boolean;
  64460. /**
  64461. * Gets the current priority level (0 at start)
  64462. */
  64463. readonly currentPriorityLevel: number;
  64464. /**
  64465. * Gets the current frame rate checked by the SceneOptimizer
  64466. */
  64467. readonly currentFrameRate: number;
  64468. /**
  64469. * Gets or sets the current target frame rate (60 by default)
  64470. */
  64471. /**
  64472. * Gets or sets the current target frame rate (60 by default)
  64473. */
  64474. targetFrameRate: number;
  64475. /**
  64476. * Gets or sets the current interval between two checks (every 2000ms by default)
  64477. */
  64478. /**
  64479. * Gets or sets the current interval between two checks (every 2000ms by default)
  64480. */
  64481. trackerDuration: number;
  64482. /**
  64483. * Gets the list of active optimizations
  64484. */
  64485. readonly optimizations: SceneOptimization[];
  64486. /**
  64487. * Creates a new SceneOptimizer
  64488. * @param scene defines the scene to work on
  64489. * @param options defines the options to use with the SceneOptimizer
  64490. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64491. * @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)
  64492. */
  64493. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64494. /**
  64495. * Stops the current optimizer
  64496. */
  64497. stop(): void;
  64498. /**
  64499. * Reset the optimizer to initial step (current priority level = 0)
  64500. */
  64501. reset(): void;
  64502. /**
  64503. * Start the optimizer. By default it will try to reach a specific framerate
  64504. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64505. */
  64506. start(): void;
  64507. private _checkCurrentState;
  64508. /**
  64509. * Release all resources
  64510. */
  64511. dispose(): void;
  64512. /**
  64513. * Helper function to create a SceneOptimizer with one single line of code
  64514. * @param scene defines the scene to work on
  64515. * @param options defines the options to use with the SceneOptimizer
  64516. * @param onSuccess defines a callback to call on success
  64517. * @param onFailure defines a callback to call on failure
  64518. * @returns the new SceneOptimizer object
  64519. */
  64520. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64521. }
  64522. }
  64523. declare module "babylonjs/Misc/sceneSerializer" {
  64524. import { Scene } from "babylonjs/scene";
  64525. /**
  64526. * Class used to serialize a scene into a string
  64527. */
  64528. export class SceneSerializer {
  64529. /**
  64530. * Clear cache used by a previous serialization
  64531. */
  64532. static ClearCache(): void;
  64533. /**
  64534. * Serialize a scene into a JSON compatible object
  64535. * @param scene defines the scene to serialize
  64536. * @returns a JSON compatible object
  64537. */
  64538. static Serialize(scene: Scene): any;
  64539. /**
  64540. * Serialize a mesh into a JSON compatible object
  64541. * @param toSerialize defines the mesh to serialize
  64542. * @param withParents defines if parents must be serialized as well
  64543. * @param withChildren defines if children must be serialized as well
  64544. * @returns a JSON compatible object
  64545. */
  64546. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64547. }
  64548. }
  64549. declare module "babylonjs/Misc/textureTools" {
  64550. import { Texture } from "babylonjs/Materials/Textures/texture";
  64551. /**
  64552. * Class used to host texture specific utilities
  64553. */
  64554. export class TextureTools {
  64555. /**
  64556. * Uses the GPU to create a copy texture rescaled at a given size
  64557. * @param texture Texture to copy from
  64558. * @param width defines the desired width
  64559. * @param height defines the desired height
  64560. * @param useBilinearMode defines if bilinear mode has to be used
  64561. * @return the generated texture
  64562. */
  64563. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64564. }
  64565. }
  64566. declare module "babylonjs/Misc/videoRecorder" {
  64567. import { Nullable } from "babylonjs/types";
  64568. import { Engine } from "babylonjs/Engines/engine";
  64569. /**
  64570. * This represents the different options available for the video capture.
  64571. */
  64572. export interface VideoRecorderOptions {
  64573. /** Defines the mime type of the video. */
  64574. mimeType: string;
  64575. /** Defines the FPS the video should be recorded at. */
  64576. fps: number;
  64577. /** Defines the chunk size for the recording data. */
  64578. recordChunckSize: number;
  64579. /** The audio tracks to attach to the recording. */
  64580. audioTracks?: MediaStreamTrack[];
  64581. }
  64582. /**
  64583. * This can help with recording videos from BabylonJS.
  64584. * This is based on the available WebRTC functionalities of the browser.
  64585. *
  64586. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64587. */
  64588. export class VideoRecorder {
  64589. private static readonly _defaultOptions;
  64590. /**
  64591. * Returns whether or not the VideoRecorder is available in your browser.
  64592. * @param engine Defines the Babylon Engine.
  64593. * @returns true if supported otherwise false.
  64594. */
  64595. static IsSupported(engine: Engine): boolean;
  64596. private readonly _options;
  64597. private _canvas;
  64598. private _mediaRecorder;
  64599. private _recordedChunks;
  64600. private _fileName;
  64601. private _resolve;
  64602. private _reject;
  64603. /**
  64604. * True when a recording is already in progress.
  64605. */
  64606. readonly isRecording: boolean;
  64607. /**
  64608. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64609. * @param engine Defines the BabylonJS Engine you wish to record.
  64610. * @param options Defines options that can be used to customize the capture.
  64611. */
  64612. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64613. /**
  64614. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64615. */
  64616. stopRecording(): void;
  64617. /**
  64618. * Starts recording the canvas for a max duration specified in parameters.
  64619. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64620. * If null no automatic download will start and you can rely on the promise to get the data back.
  64621. * @param maxDuration Defines the maximum recording time in seconds.
  64622. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64623. * @return A promise callback at the end of the recording with the video data in Blob.
  64624. */
  64625. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64626. /**
  64627. * Releases internal resources used during the recording.
  64628. */
  64629. dispose(): void;
  64630. private _handleDataAvailable;
  64631. private _handleError;
  64632. private _handleStop;
  64633. }
  64634. }
  64635. declare module "babylonjs/Misc/screenshotTools" {
  64636. import { Camera } from "babylonjs/Cameras/camera";
  64637. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64638. import { Engine } from "babylonjs/Engines/engine";
  64639. /**
  64640. * Class containing a set of static utilities functions for screenshots
  64641. */
  64642. export class ScreenshotTools {
  64643. /**
  64644. * Captures a screenshot of the current rendering
  64645. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64646. * @param engine defines the rendering engine
  64647. * @param camera defines the source camera
  64648. * @param size This parameter can be set to a single number or to an object with the
  64649. * following (optional) properties: precision, width, height. If a single number is passed,
  64650. * it will be used for both width and height. If an object is passed, the screenshot size
  64651. * will be derived from the parameters. The precision property is a multiplier allowing
  64652. * rendering at a higher or lower resolution
  64653. * @param successCallback defines the callback receives a single parameter which contains the
  64654. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64655. * src parameter of an <img> to display it
  64656. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64657. * Check your browser for supported MIME types
  64658. */
  64659. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64660. /**
  64661. * Captures a screenshot of the current rendering
  64662. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64663. * @param engine defines the rendering engine
  64664. * @param camera defines the source camera
  64665. * @param size This parameter can be set to a single number or to an object with the
  64666. * following (optional) properties: precision, width, height. If a single number is passed,
  64667. * it will be used for both width and height. If an object is passed, the screenshot size
  64668. * will be derived from the parameters. The precision property is a multiplier allowing
  64669. * rendering at a higher or lower resolution
  64670. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64671. * Check your browser for supported MIME types
  64672. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64673. * to the src parameter of an <img> to display it
  64674. */
  64675. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64676. /**
  64677. * Generates an image screenshot from the specified camera.
  64678. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64679. * @param engine The engine to use for rendering
  64680. * @param camera The camera to use for rendering
  64681. * @param size This parameter can be set to a single number or to an object with the
  64682. * following (optional) properties: precision, width, height. If a single number is passed,
  64683. * it will be used for both width and height. If an object is passed, the screenshot size
  64684. * will be derived from the parameters. The precision property is a multiplier allowing
  64685. * rendering at a higher or lower resolution
  64686. * @param successCallback The callback receives a single parameter which contains the
  64687. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64688. * src parameter of an <img> to display it
  64689. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64690. * Check your browser for supported MIME types
  64691. * @param samples Texture samples (default: 1)
  64692. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64693. * @param fileName A name for for the downloaded file.
  64694. */
  64695. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64696. /**
  64697. * Generates an image screenshot from the specified camera.
  64698. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64699. * @param engine The engine to use for rendering
  64700. * @param camera The camera to use for rendering
  64701. * @param size This parameter can be set to a single number or to an object with the
  64702. * following (optional) properties: precision, width, height. If a single number is passed,
  64703. * it will be used for both width and height. If an object is passed, the screenshot size
  64704. * will be derived from the parameters. The precision property is a multiplier allowing
  64705. * rendering at a higher or lower resolution
  64706. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64707. * Check your browser for supported MIME types
  64708. * @param samples Texture samples (default: 1)
  64709. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64710. * @param fileName A name for for the downloaded file.
  64711. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64712. * to the src parameter of an <img> to display it
  64713. */
  64714. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64715. /**
  64716. * Gets height and width for screenshot size
  64717. * @private
  64718. */
  64719. private static _getScreenshotSize;
  64720. }
  64721. }
  64722. declare module "babylonjs/Misc/index" {
  64723. export * from "babylonjs/Misc/andOrNotEvaluator";
  64724. export * from "babylonjs/Misc/assetsManager";
  64725. export * from "babylonjs/Misc/dds";
  64726. export * from "babylonjs/Misc/decorators";
  64727. export * from "babylonjs/Misc/deferred";
  64728. export * from "babylonjs/Misc/environmentTextureTools";
  64729. export * from "babylonjs/Misc/meshExploder";
  64730. export * from "babylonjs/Misc/filesInput";
  64731. export * from "babylonjs/Misc/HighDynamicRange/index";
  64732. export * from "babylonjs/Misc/khronosTextureContainer";
  64733. export * from "babylonjs/Misc/observable";
  64734. export * from "babylonjs/Misc/performanceMonitor";
  64735. export * from "babylonjs/Misc/promise";
  64736. export * from "babylonjs/Misc/sceneOptimizer";
  64737. export * from "babylonjs/Misc/sceneSerializer";
  64738. export * from "babylonjs/Misc/smartArray";
  64739. export * from "babylonjs/Misc/stringDictionary";
  64740. export * from "babylonjs/Misc/tags";
  64741. export * from "babylonjs/Misc/textureTools";
  64742. export * from "babylonjs/Misc/tga";
  64743. export * from "babylonjs/Misc/tools";
  64744. export * from "babylonjs/Misc/videoRecorder";
  64745. export * from "babylonjs/Misc/virtualJoystick";
  64746. export * from "babylonjs/Misc/workerPool";
  64747. export * from "babylonjs/Misc/logger";
  64748. export * from "babylonjs/Misc/typeStore";
  64749. export * from "babylonjs/Misc/filesInputStore";
  64750. export * from "babylonjs/Misc/deepCopier";
  64751. export * from "babylonjs/Misc/pivotTools";
  64752. export * from "babylonjs/Misc/precisionDate";
  64753. export * from "babylonjs/Misc/screenshotTools";
  64754. export * from "babylonjs/Misc/typeStore";
  64755. export * from "babylonjs/Misc/webRequest";
  64756. export * from "babylonjs/Misc/iInspectable";
  64757. export * from "babylonjs/Misc/brdfTextureTools";
  64758. export * from "babylonjs/Misc/gradients";
  64759. export * from "babylonjs/Misc/perfCounter";
  64760. export * from "babylonjs/Misc/fileRequest";
  64761. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64762. export * from "babylonjs/Misc/retryStrategy";
  64763. export * from "babylonjs/Misc/loadFileError";
  64764. }
  64765. declare module "babylonjs/index" {
  64766. export * from "babylonjs/abstractScene";
  64767. export * from "babylonjs/Actions/index";
  64768. export * from "babylonjs/Animations/index";
  64769. export * from "babylonjs/assetContainer";
  64770. export * from "babylonjs/Audio/index";
  64771. export * from "babylonjs/Behaviors/index";
  64772. export * from "babylonjs/Bones/index";
  64773. export * from "babylonjs/Cameras/index";
  64774. export * from "babylonjs/Collisions/index";
  64775. export * from "babylonjs/Culling/index";
  64776. export * from "babylonjs/Debug/index";
  64777. export * from "babylonjs/Engines/index";
  64778. export * from "babylonjs/Events/index";
  64779. export * from "babylonjs/Gamepads/index";
  64780. export * from "babylonjs/Gizmos/index";
  64781. export * from "babylonjs/Helpers/index";
  64782. export * from "babylonjs/Instrumentation/index";
  64783. export * from "babylonjs/Layers/index";
  64784. export * from "babylonjs/LensFlares/index";
  64785. export * from "babylonjs/Lights/index";
  64786. export * from "babylonjs/Loading/index";
  64787. export * from "babylonjs/Materials/index";
  64788. export * from "babylonjs/Maths/index";
  64789. export * from "babylonjs/Meshes/index";
  64790. export * from "babylonjs/Morph/index";
  64791. export * from "babylonjs/Navigation/index";
  64792. export * from "babylonjs/node";
  64793. export * from "babylonjs/Offline/index";
  64794. export * from "babylonjs/Particles/index";
  64795. export * from "babylonjs/Physics/index";
  64796. export * from "babylonjs/PostProcesses/index";
  64797. export * from "babylonjs/Probes/index";
  64798. export * from "babylonjs/Rendering/index";
  64799. export * from "babylonjs/scene";
  64800. export * from "babylonjs/sceneComponent";
  64801. export * from "babylonjs/Sprites/index";
  64802. export * from "babylonjs/States/index";
  64803. export * from "babylonjs/Misc/index";
  64804. export * from "babylonjs/types";
  64805. }
  64806. declare module "babylonjs/Animations/pathCursor" {
  64807. import { Vector3 } from "babylonjs/Maths/math.vector";
  64808. import { Path2 } from "babylonjs/Maths/math.path";
  64809. /**
  64810. * A cursor which tracks a point on a path
  64811. */
  64812. export class PathCursor {
  64813. private path;
  64814. /**
  64815. * Stores path cursor callbacks for when an onchange event is triggered
  64816. */
  64817. private _onchange;
  64818. /**
  64819. * The value of the path cursor
  64820. */
  64821. value: number;
  64822. /**
  64823. * The animation array of the path cursor
  64824. */
  64825. animations: Animation[];
  64826. /**
  64827. * Initializes the path cursor
  64828. * @param path The path to track
  64829. */
  64830. constructor(path: Path2);
  64831. /**
  64832. * Gets the cursor point on the path
  64833. * @returns A point on the path cursor at the cursor location
  64834. */
  64835. getPoint(): Vector3;
  64836. /**
  64837. * Moves the cursor ahead by the step amount
  64838. * @param step The amount to move the cursor forward
  64839. * @returns This path cursor
  64840. */
  64841. moveAhead(step?: number): PathCursor;
  64842. /**
  64843. * Moves the cursor behind by the step amount
  64844. * @param step The amount to move the cursor back
  64845. * @returns This path cursor
  64846. */
  64847. moveBack(step?: number): PathCursor;
  64848. /**
  64849. * Moves the cursor by the step amount
  64850. * If the step amount is greater than one, an exception is thrown
  64851. * @param step The amount to move the cursor
  64852. * @returns This path cursor
  64853. */
  64854. move(step: number): PathCursor;
  64855. /**
  64856. * Ensures that the value is limited between zero and one
  64857. * @returns This path cursor
  64858. */
  64859. private ensureLimits;
  64860. /**
  64861. * Runs onchange callbacks on change (used by the animation engine)
  64862. * @returns This path cursor
  64863. */
  64864. private raiseOnChange;
  64865. /**
  64866. * Executes a function on change
  64867. * @param f A path cursor onchange callback
  64868. * @returns This path cursor
  64869. */
  64870. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64871. }
  64872. }
  64873. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64874. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64875. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64876. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64877. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64878. }
  64879. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64880. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64881. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64882. }
  64883. declare module "babylonjs/Engines/Processors/index" {
  64884. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64885. export * from "babylonjs/Engines/Processors/Expressions/index";
  64886. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64887. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64888. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64889. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64890. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64891. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64892. }
  64893. declare module "babylonjs/Legacy/legacy" {
  64894. import * as Babylon from "babylonjs/index";
  64895. export * from "babylonjs/index";
  64896. }
  64897. declare module "babylonjs/Shaders/blur.fragment" {
  64898. /** @hidden */
  64899. export var blurPixelShader: {
  64900. name: string;
  64901. shader: string;
  64902. };
  64903. }
  64904. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64905. /** @hidden */
  64906. export var pointCloudVertexDeclaration: {
  64907. name: string;
  64908. shader: string;
  64909. };
  64910. }
  64911. declare module "babylonjs" {
  64912. export * from "babylonjs/Legacy/legacy";
  64913. }
  64914. declare module BABYLON {
  64915. /** Alias type for value that can be null */
  64916. export type Nullable<T> = T | null;
  64917. /**
  64918. * Alias type for number that are floats
  64919. * @ignorenaming
  64920. */
  64921. export type float = number;
  64922. /**
  64923. * Alias type for number that are doubles.
  64924. * @ignorenaming
  64925. */
  64926. export type double = number;
  64927. /**
  64928. * Alias type for number that are integer
  64929. * @ignorenaming
  64930. */
  64931. export type int = number;
  64932. /** Alias type for number array or Float32Array */
  64933. export type FloatArray = number[] | Float32Array;
  64934. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64935. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64936. /**
  64937. * Alias for types that can be used by a Buffer or VertexBuffer.
  64938. */
  64939. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64940. /**
  64941. * Alias type for primitive types
  64942. * @ignorenaming
  64943. */
  64944. type Primitive = undefined | null | boolean | string | number | Function;
  64945. /**
  64946. * Type modifier to make all the properties of an object Readonly
  64947. */
  64948. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64949. /**
  64950. * Type modifier to make all the properties of an object Readonly recursively
  64951. */
  64952. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64953. /** @hidden */
  64954. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64955. }
  64956. /** @hidden */
  64957. /** @hidden */
  64958. type DeepImmutableObject<T> = {
  64959. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64960. };
  64961. }
  64962. declare module BABYLON {
  64963. /**
  64964. * A class serves as a medium between the observable and its observers
  64965. */
  64966. export class EventState {
  64967. /**
  64968. * Create a new EventState
  64969. * @param mask defines the mask associated with this state
  64970. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64971. * @param target defines the original target of the state
  64972. * @param currentTarget defines the current target of the state
  64973. */
  64974. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64975. /**
  64976. * Initialize the current event state
  64977. * @param mask defines the mask associated with this state
  64978. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64979. * @param target defines the original target of the state
  64980. * @param currentTarget defines the current target of the state
  64981. * @returns the current event state
  64982. */
  64983. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64984. /**
  64985. * An Observer can set this property to true to prevent subsequent observers of being notified
  64986. */
  64987. skipNextObservers: boolean;
  64988. /**
  64989. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64990. */
  64991. mask: number;
  64992. /**
  64993. * The object that originally notified the event
  64994. */
  64995. target?: any;
  64996. /**
  64997. * The current object in the bubbling phase
  64998. */
  64999. currentTarget?: any;
  65000. /**
  65001. * This will be populated with the return value of the last function that was executed.
  65002. * If it is the first function in the callback chain it will be the event data.
  65003. */
  65004. lastReturnValue?: any;
  65005. }
  65006. /**
  65007. * Represent an Observer registered to a given Observable object.
  65008. */
  65009. export class Observer<T> {
  65010. /**
  65011. * Defines the callback to call when the observer is notified
  65012. */
  65013. callback: (eventData: T, eventState: EventState) => void;
  65014. /**
  65015. * Defines the mask of the observer (used to filter notifications)
  65016. */
  65017. mask: number;
  65018. /**
  65019. * Defines the current scope used to restore the JS context
  65020. */
  65021. scope: any;
  65022. /** @hidden */
  65023. _willBeUnregistered: boolean;
  65024. /**
  65025. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65026. */
  65027. unregisterOnNextCall: boolean;
  65028. /**
  65029. * Creates a new observer
  65030. * @param callback defines the callback to call when the observer is notified
  65031. * @param mask defines the mask of the observer (used to filter notifications)
  65032. * @param scope defines the current scope used to restore the JS context
  65033. */
  65034. constructor(
  65035. /**
  65036. * Defines the callback to call when the observer is notified
  65037. */
  65038. callback: (eventData: T, eventState: EventState) => void,
  65039. /**
  65040. * Defines the mask of the observer (used to filter notifications)
  65041. */
  65042. mask: number,
  65043. /**
  65044. * Defines the current scope used to restore the JS context
  65045. */
  65046. scope?: any);
  65047. }
  65048. /**
  65049. * Represent a list of observers registered to multiple Observables object.
  65050. */
  65051. export class MultiObserver<T> {
  65052. private _observers;
  65053. private _observables;
  65054. /**
  65055. * Release associated resources
  65056. */
  65057. dispose(): void;
  65058. /**
  65059. * Raise a callback when one of the observable will notify
  65060. * @param observables defines a list of observables to watch
  65061. * @param callback defines the callback to call on notification
  65062. * @param mask defines the mask used to filter notifications
  65063. * @param scope defines the current scope used to restore the JS context
  65064. * @returns the new MultiObserver
  65065. */
  65066. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65067. }
  65068. /**
  65069. * The Observable class is a simple implementation of the Observable pattern.
  65070. *
  65071. * 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.
  65072. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65073. * 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).
  65074. * 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.
  65075. */
  65076. export class Observable<T> {
  65077. private _observers;
  65078. private _eventState;
  65079. private _onObserverAdded;
  65080. /**
  65081. * Gets the list of observers
  65082. */
  65083. readonly observers: Array<Observer<T>>;
  65084. /**
  65085. * Creates a new observable
  65086. * @param onObserverAdded defines a callback to call when a new observer is added
  65087. */
  65088. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65089. /**
  65090. * Create a new Observer with the specified callback
  65091. * @param callback the callback that will be executed for that Observer
  65092. * @param mask the mask used to filter observers
  65093. * @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.
  65094. * @param scope optional scope for the callback to be called from
  65095. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65096. * @returns the new observer created for the callback
  65097. */
  65098. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65099. /**
  65100. * Create a new Observer with the specified callback and unregisters after the next notification
  65101. * @param callback the callback that will be executed for that Observer
  65102. * @returns the new observer created for the callback
  65103. */
  65104. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65105. /**
  65106. * Remove an Observer from the Observable object
  65107. * @param observer the instance of the Observer to remove
  65108. * @returns false if it doesn't belong to this Observable
  65109. */
  65110. remove(observer: Nullable<Observer<T>>): boolean;
  65111. /**
  65112. * Remove a callback from the Observable object
  65113. * @param callback the callback to remove
  65114. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65115. * @returns false if it doesn't belong to this Observable
  65116. */
  65117. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65118. private _deferUnregister;
  65119. private _remove;
  65120. /**
  65121. * Moves the observable to the top of the observer list making it get called first when notified
  65122. * @param observer the observer to move
  65123. */
  65124. makeObserverTopPriority(observer: Observer<T>): void;
  65125. /**
  65126. * Moves the observable to the bottom of the observer list making it get called last when notified
  65127. * @param observer the observer to move
  65128. */
  65129. makeObserverBottomPriority(observer: Observer<T>): void;
  65130. /**
  65131. * Notify all Observers by calling their respective callback with the given data
  65132. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65133. * @param eventData defines the data to send to all observers
  65134. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65135. * @param target defines the original target of the state
  65136. * @param currentTarget defines the current target of the state
  65137. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65138. */
  65139. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65140. /**
  65141. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65142. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65143. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65144. * and it is crucial that all callbacks will be executed.
  65145. * The order of the callbacks is kept, callbacks are not executed parallel.
  65146. *
  65147. * @param eventData The data to be sent to each callback
  65148. * @param mask is used to filter observers defaults to -1
  65149. * @param target defines the callback target (see EventState)
  65150. * @param currentTarget defines he current object in the bubbling phase
  65151. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65152. */
  65153. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65154. /**
  65155. * Notify a specific observer
  65156. * @param observer defines the observer to notify
  65157. * @param eventData defines the data to be sent to each callback
  65158. * @param mask is used to filter observers defaults to -1
  65159. */
  65160. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65161. /**
  65162. * Gets a boolean indicating if the observable has at least one observer
  65163. * @returns true is the Observable has at least one Observer registered
  65164. */
  65165. hasObservers(): boolean;
  65166. /**
  65167. * Clear the list of observers
  65168. */
  65169. clear(): void;
  65170. /**
  65171. * Clone the current observable
  65172. * @returns a new observable
  65173. */
  65174. clone(): Observable<T>;
  65175. /**
  65176. * Does this observable handles observer registered with a given mask
  65177. * @param mask defines the mask to be tested
  65178. * @return whether or not one observer registered with the given mask is handeled
  65179. **/
  65180. hasSpecificMask(mask?: number): boolean;
  65181. }
  65182. }
  65183. declare module BABYLON {
  65184. /**
  65185. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65186. * Babylon.js
  65187. */
  65188. export class DomManagement {
  65189. /**
  65190. * Checks if the window object exists
  65191. * @returns true if the window object exists
  65192. */
  65193. static IsWindowObjectExist(): boolean;
  65194. /**
  65195. * Extracts text content from a DOM element hierarchy
  65196. * @param element defines the root element
  65197. * @returns a string
  65198. */
  65199. static GetDOMTextContent(element: HTMLElement): string;
  65200. }
  65201. }
  65202. declare module BABYLON {
  65203. /**
  65204. * Logger used througouht the application to allow configuration of
  65205. * the log level required for the messages.
  65206. */
  65207. export class Logger {
  65208. /**
  65209. * No log
  65210. */
  65211. static readonly NoneLogLevel: number;
  65212. /**
  65213. * Only message logs
  65214. */
  65215. static readonly MessageLogLevel: number;
  65216. /**
  65217. * Only warning logs
  65218. */
  65219. static readonly WarningLogLevel: number;
  65220. /**
  65221. * Only error logs
  65222. */
  65223. static readonly ErrorLogLevel: number;
  65224. /**
  65225. * All logs
  65226. */
  65227. static readonly AllLogLevel: number;
  65228. private static _LogCache;
  65229. /**
  65230. * Gets a value indicating the number of loading errors
  65231. * @ignorenaming
  65232. */
  65233. static errorsCount: number;
  65234. /**
  65235. * Callback called when a new log is added
  65236. */
  65237. static OnNewCacheEntry: (entry: string) => void;
  65238. private static _AddLogEntry;
  65239. private static _FormatMessage;
  65240. private static _LogDisabled;
  65241. private static _LogEnabled;
  65242. private static _WarnDisabled;
  65243. private static _WarnEnabled;
  65244. private static _ErrorDisabled;
  65245. private static _ErrorEnabled;
  65246. /**
  65247. * Log a message to the console
  65248. */
  65249. static Log: (message: string) => void;
  65250. /**
  65251. * Write a warning message to the console
  65252. */
  65253. static Warn: (message: string) => void;
  65254. /**
  65255. * Write an error message to the console
  65256. */
  65257. static Error: (message: string) => void;
  65258. /**
  65259. * Gets current log cache (list of logs)
  65260. */
  65261. static readonly LogCache: string;
  65262. /**
  65263. * Clears the log cache
  65264. */
  65265. static ClearLogCache(): void;
  65266. /**
  65267. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65268. */
  65269. static LogLevels: number;
  65270. }
  65271. }
  65272. declare module BABYLON {
  65273. /** @hidden */
  65274. export class _TypeStore {
  65275. /** @hidden */
  65276. static RegisteredTypes: {
  65277. [key: string]: Object;
  65278. };
  65279. /** @hidden */
  65280. static GetClass(fqdn: string): any;
  65281. }
  65282. }
  65283. declare module BABYLON {
  65284. /**
  65285. * Class containing a set of static utilities functions for deep copy.
  65286. */
  65287. export class DeepCopier {
  65288. /**
  65289. * Tries to copy an object by duplicating every property
  65290. * @param source defines the source object
  65291. * @param destination defines the target object
  65292. * @param doNotCopyList defines a list of properties to avoid
  65293. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65294. */
  65295. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65296. }
  65297. }
  65298. declare module BABYLON {
  65299. /**
  65300. * Class containing a set of static utilities functions for precision date
  65301. */
  65302. export class PrecisionDate {
  65303. /**
  65304. * Gets either window.performance.now() if supported or Date.now() else
  65305. */
  65306. static readonly Now: number;
  65307. }
  65308. }
  65309. declare module BABYLON {
  65310. /** @hidden */
  65311. export class _DevTools {
  65312. static WarnImport(name: string): string;
  65313. }
  65314. }
  65315. declare module BABYLON {
  65316. /**
  65317. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65318. */
  65319. export class WebRequest {
  65320. private _xhr;
  65321. /**
  65322. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65323. * i.e. when loading files, where the server/service expects an Authorization header
  65324. */
  65325. static CustomRequestHeaders: {
  65326. [key: string]: string;
  65327. };
  65328. /**
  65329. * Add callback functions in this array to update all the requests before they get sent to the network
  65330. */
  65331. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65332. private _injectCustomRequestHeaders;
  65333. /**
  65334. * Gets or sets a function to be called when loading progress changes
  65335. */
  65336. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65337. /**
  65338. * Returns client's state
  65339. */
  65340. readonly readyState: number;
  65341. /**
  65342. * Returns client's status
  65343. */
  65344. readonly status: number;
  65345. /**
  65346. * Returns client's status as a text
  65347. */
  65348. readonly statusText: string;
  65349. /**
  65350. * Returns client's response
  65351. */
  65352. readonly response: any;
  65353. /**
  65354. * Returns client's response url
  65355. */
  65356. readonly responseURL: string;
  65357. /**
  65358. * Returns client's response as text
  65359. */
  65360. readonly responseText: string;
  65361. /**
  65362. * Gets or sets the expected response type
  65363. */
  65364. responseType: XMLHttpRequestResponseType;
  65365. /** @hidden */
  65366. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65367. /** @hidden */
  65368. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65369. /**
  65370. * Cancels any network activity
  65371. */
  65372. abort(): void;
  65373. /**
  65374. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65375. * @param body defines an optional request body
  65376. */
  65377. send(body?: Document | BodyInit | null): void;
  65378. /**
  65379. * Sets the request method, request URL
  65380. * @param method defines the method to use (GET, POST, etc..)
  65381. * @param url defines the url to connect with
  65382. */
  65383. open(method: string, url: string): void;
  65384. }
  65385. }
  65386. declare module BABYLON {
  65387. /**
  65388. * File request interface
  65389. */
  65390. export interface IFileRequest {
  65391. /**
  65392. * Raised when the request is complete (success or error).
  65393. */
  65394. onCompleteObservable: Observable<IFileRequest>;
  65395. /**
  65396. * Aborts the request for a file.
  65397. */
  65398. abort: () => void;
  65399. }
  65400. }
  65401. declare module BABYLON {
  65402. /**
  65403. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65404. */
  65405. export class PerformanceMonitor {
  65406. private _enabled;
  65407. private _rollingFrameTime;
  65408. private _lastFrameTimeMs;
  65409. /**
  65410. * constructor
  65411. * @param frameSampleSize The number of samples required to saturate the sliding window
  65412. */
  65413. constructor(frameSampleSize?: number);
  65414. /**
  65415. * Samples current frame
  65416. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65417. */
  65418. sampleFrame(timeMs?: number): void;
  65419. /**
  65420. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65421. */
  65422. readonly averageFrameTime: number;
  65423. /**
  65424. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65425. */
  65426. readonly averageFrameTimeVariance: number;
  65427. /**
  65428. * Returns the frame time of the most recent frame
  65429. */
  65430. readonly instantaneousFrameTime: number;
  65431. /**
  65432. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65433. */
  65434. readonly averageFPS: number;
  65435. /**
  65436. * Returns the average framerate in frames per second using the most recent frame time
  65437. */
  65438. readonly instantaneousFPS: number;
  65439. /**
  65440. * Returns true if enough samples have been taken to completely fill the sliding window
  65441. */
  65442. readonly isSaturated: boolean;
  65443. /**
  65444. * Enables contributions to the sliding window sample set
  65445. */
  65446. enable(): void;
  65447. /**
  65448. * Disables contributions to the sliding window sample set
  65449. * Samples will not be interpolated over the disabled period
  65450. */
  65451. disable(): void;
  65452. /**
  65453. * Returns true if sampling is enabled
  65454. */
  65455. readonly isEnabled: boolean;
  65456. /**
  65457. * Resets performance monitor
  65458. */
  65459. reset(): void;
  65460. }
  65461. /**
  65462. * RollingAverage
  65463. *
  65464. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65465. */
  65466. export class RollingAverage {
  65467. /**
  65468. * Current average
  65469. */
  65470. average: number;
  65471. /**
  65472. * Current variance
  65473. */
  65474. variance: number;
  65475. protected _samples: Array<number>;
  65476. protected _sampleCount: number;
  65477. protected _pos: number;
  65478. protected _m2: number;
  65479. /**
  65480. * constructor
  65481. * @param length The number of samples required to saturate the sliding window
  65482. */
  65483. constructor(length: number);
  65484. /**
  65485. * Adds a sample to the sample set
  65486. * @param v The sample value
  65487. */
  65488. add(v: number): void;
  65489. /**
  65490. * Returns previously added values or null if outside of history or outside the sliding window domain
  65491. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65492. * @return Value previously recorded with add() or null if outside of range
  65493. */
  65494. history(i: number): number;
  65495. /**
  65496. * Returns true if enough samples have been taken to completely fill the sliding window
  65497. * @return true if sample-set saturated
  65498. */
  65499. isSaturated(): boolean;
  65500. /**
  65501. * Resets the rolling average (equivalent to 0 samples taken so far)
  65502. */
  65503. reset(): void;
  65504. /**
  65505. * Wraps a value around the sample range boundaries
  65506. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65507. * @return Wrapped position in sample range
  65508. */
  65509. protected _wrapPosition(i: number): number;
  65510. }
  65511. }
  65512. declare module BABYLON {
  65513. /**
  65514. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65515. * The underlying implementation relies on an associative array to ensure the best performances.
  65516. * The value can be anything including 'null' but except 'undefined'
  65517. */
  65518. export class StringDictionary<T> {
  65519. /**
  65520. * This will clear this dictionary and copy the content from the 'source' one.
  65521. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65522. * @param source the dictionary to take the content from and copy to this dictionary
  65523. */
  65524. copyFrom(source: StringDictionary<T>): void;
  65525. /**
  65526. * Get a value based from its key
  65527. * @param key the given key to get the matching value from
  65528. * @return the value if found, otherwise undefined is returned
  65529. */
  65530. get(key: string): T | undefined;
  65531. /**
  65532. * Get a value from its key or add it if it doesn't exist.
  65533. * This method will ensure you that a given key/data will be present in the dictionary.
  65534. * @param key the given key to get the matching value from
  65535. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65536. * The factory will only be invoked if there's no data for the given key.
  65537. * @return the value corresponding to the key.
  65538. */
  65539. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65540. /**
  65541. * Get a value from its key if present in the dictionary otherwise add it
  65542. * @param key the key to get the value from
  65543. * @param val if there's no such key/value pair in the dictionary add it with this value
  65544. * @return the value corresponding to the key
  65545. */
  65546. getOrAdd(key: string, val: T): T;
  65547. /**
  65548. * Check if there's a given key in the dictionary
  65549. * @param key the key to check for
  65550. * @return true if the key is present, false otherwise
  65551. */
  65552. contains(key: string): boolean;
  65553. /**
  65554. * Add a new key and its corresponding value
  65555. * @param key the key to add
  65556. * @param value the value corresponding to the key
  65557. * @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
  65558. */
  65559. add(key: string, value: T): boolean;
  65560. /**
  65561. * Update a specific value associated to a key
  65562. * @param key defines the key to use
  65563. * @param value defines the value to store
  65564. * @returns true if the value was updated (or false if the key was not found)
  65565. */
  65566. set(key: string, value: T): boolean;
  65567. /**
  65568. * Get the element of the given key and remove it from the dictionary
  65569. * @param key defines the key to search
  65570. * @returns the value associated with the key or null if not found
  65571. */
  65572. getAndRemove(key: string): Nullable<T>;
  65573. /**
  65574. * Remove a key/value from the dictionary.
  65575. * @param key the key to remove
  65576. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65577. */
  65578. remove(key: string): boolean;
  65579. /**
  65580. * Clear the whole content of the dictionary
  65581. */
  65582. clear(): void;
  65583. /**
  65584. * Gets the current count
  65585. */
  65586. readonly count: number;
  65587. /**
  65588. * Execute a callback on each key/val of the dictionary.
  65589. * Note that you can remove any element in this dictionary in the callback implementation
  65590. * @param callback the callback to execute on a given key/value pair
  65591. */
  65592. forEach(callback: (key: string, val: T) => void): void;
  65593. /**
  65594. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65595. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65596. * Note that you can remove any element in this dictionary in the callback implementation
  65597. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65598. * @returns the first item
  65599. */
  65600. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65601. private _count;
  65602. private _data;
  65603. }
  65604. }
  65605. declare module BABYLON {
  65606. /**
  65607. * Class used to store gfx data (like WebGLBuffer)
  65608. */
  65609. export class DataBuffer {
  65610. /**
  65611. * Gets or sets the number of objects referencing this buffer
  65612. */
  65613. references: number;
  65614. /** Gets or sets the size of the underlying buffer */
  65615. capacity: number;
  65616. /**
  65617. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65618. */
  65619. is32Bits: boolean;
  65620. /**
  65621. * Gets the underlying buffer
  65622. */
  65623. readonly underlyingResource: any;
  65624. }
  65625. }
  65626. declare module BABYLON {
  65627. /**
  65628. * Class used to store data that will be store in GPU memory
  65629. */
  65630. export class Buffer {
  65631. private _engine;
  65632. private _buffer;
  65633. /** @hidden */
  65634. _data: Nullable<DataArray>;
  65635. private _updatable;
  65636. private _instanced;
  65637. /**
  65638. * Gets the byte stride.
  65639. */
  65640. readonly byteStride: number;
  65641. /**
  65642. * Constructor
  65643. * @param engine the engine
  65644. * @param data the data to use for this buffer
  65645. * @param updatable whether the data is updatable
  65646. * @param stride the stride (optional)
  65647. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65648. * @param instanced whether the buffer is instanced (optional)
  65649. * @param useBytes set to true if the stride in in bytes (optional)
  65650. */
  65651. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65652. /**
  65653. * Create a new VertexBuffer based on the current buffer
  65654. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65655. * @param offset defines offset in the buffer (0 by default)
  65656. * @param size defines the size in floats of attributes (position is 3 for instance)
  65657. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65658. * @param instanced defines if the vertex buffer contains indexed data
  65659. * @param useBytes defines if the offset and stride are in bytes
  65660. * @returns the new vertex buffer
  65661. */
  65662. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65663. /**
  65664. * Gets a boolean indicating if the Buffer is updatable?
  65665. * @returns true if the buffer is updatable
  65666. */
  65667. isUpdatable(): boolean;
  65668. /**
  65669. * Gets current buffer's data
  65670. * @returns a DataArray or null
  65671. */
  65672. getData(): Nullable<DataArray>;
  65673. /**
  65674. * Gets underlying native buffer
  65675. * @returns underlying native buffer
  65676. */
  65677. getBuffer(): Nullable<DataBuffer>;
  65678. /**
  65679. * Gets the stride in float32 units (i.e. byte stride / 4).
  65680. * May not be an integer if the byte stride is not divisible by 4.
  65681. * DEPRECATED. Use byteStride instead.
  65682. * @returns the stride in float32 units
  65683. */
  65684. getStrideSize(): number;
  65685. /**
  65686. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65687. * @param data defines the data to store
  65688. */
  65689. create(data?: Nullable<DataArray>): void;
  65690. /** @hidden */
  65691. _rebuild(): void;
  65692. /**
  65693. * Update current buffer data
  65694. * @param data defines the data to store
  65695. */
  65696. update(data: DataArray): void;
  65697. /**
  65698. * Updates the data directly.
  65699. * @param data the new data
  65700. * @param offset the new offset
  65701. * @param vertexCount the vertex count (optional)
  65702. * @param useBytes set to true if the offset is in bytes
  65703. */
  65704. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65705. /**
  65706. * Release all resources
  65707. */
  65708. dispose(): void;
  65709. }
  65710. /**
  65711. * Specialized buffer used to store vertex data
  65712. */
  65713. export class VertexBuffer {
  65714. /** @hidden */
  65715. _buffer: Buffer;
  65716. private _kind;
  65717. private _size;
  65718. private _ownsBuffer;
  65719. private _instanced;
  65720. private _instanceDivisor;
  65721. /**
  65722. * The byte type.
  65723. */
  65724. static readonly BYTE: number;
  65725. /**
  65726. * The unsigned byte type.
  65727. */
  65728. static readonly UNSIGNED_BYTE: number;
  65729. /**
  65730. * The short type.
  65731. */
  65732. static readonly SHORT: number;
  65733. /**
  65734. * The unsigned short type.
  65735. */
  65736. static readonly UNSIGNED_SHORT: number;
  65737. /**
  65738. * The integer type.
  65739. */
  65740. static readonly INT: number;
  65741. /**
  65742. * The unsigned integer type.
  65743. */
  65744. static readonly UNSIGNED_INT: number;
  65745. /**
  65746. * The float type.
  65747. */
  65748. static readonly FLOAT: number;
  65749. /**
  65750. * Gets or sets the instance divisor when in instanced mode
  65751. */
  65752. instanceDivisor: number;
  65753. /**
  65754. * Gets the byte stride.
  65755. */
  65756. readonly byteStride: number;
  65757. /**
  65758. * Gets the byte offset.
  65759. */
  65760. readonly byteOffset: number;
  65761. /**
  65762. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65763. */
  65764. readonly normalized: boolean;
  65765. /**
  65766. * Gets the data type of each component in the array.
  65767. */
  65768. readonly type: number;
  65769. /**
  65770. * Constructor
  65771. * @param engine the engine
  65772. * @param data the data to use for this vertex buffer
  65773. * @param kind the vertex buffer kind
  65774. * @param updatable whether the data is updatable
  65775. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65776. * @param stride the stride (optional)
  65777. * @param instanced whether the buffer is instanced (optional)
  65778. * @param offset the offset of the data (optional)
  65779. * @param size the number of components (optional)
  65780. * @param type the type of the component (optional)
  65781. * @param normalized whether the data contains normalized data (optional)
  65782. * @param useBytes set to true if stride and offset are in bytes (optional)
  65783. */
  65784. 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);
  65785. /** @hidden */
  65786. _rebuild(): void;
  65787. /**
  65788. * Returns the kind of the VertexBuffer (string)
  65789. * @returns a string
  65790. */
  65791. getKind(): string;
  65792. /**
  65793. * Gets a boolean indicating if the VertexBuffer is updatable?
  65794. * @returns true if the buffer is updatable
  65795. */
  65796. isUpdatable(): boolean;
  65797. /**
  65798. * Gets current buffer's data
  65799. * @returns a DataArray or null
  65800. */
  65801. getData(): Nullable<DataArray>;
  65802. /**
  65803. * Gets underlying native buffer
  65804. * @returns underlying native buffer
  65805. */
  65806. getBuffer(): Nullable<DataBuffer>;
  65807. /**
  65808. * Gets the stride in float32 units (i.e. byte stride / 4).
  65809. * May not be an integer if the byte stride is not divisible by 4.
  65810. * DEPRECATED. Use byteStride instead.
  65811. * @returns the stride in float32 units
  65812. */
  65813. getStrideSize(): number;
  65814. /**
  65815. * Returns the offset as a multiple of the type byte length.
  65816. * DEPRECATED. Use byteOffset instead.
  65817. * @returns the offset in bytes
  65818. */
  65819. getOffset(): number;
  65820. /**
  65821. * Returns the number of components per vertex attribute (integer)
  65822. * @returns the size in float
  65823. */
  65824. getSize(): number;
  65825. /**
  65826. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65827. * @returns true if this buffer is instanced
  65828. */
  65829. getIsInstanced(): boolean;
  65830. /**
  65831. * Returns the instancing divisor, zero for non-instanced (integer).
  65832. * @returns a number
  65833. */
  65834. getInstanceDivisor(): number;
  65835. /**
  65836. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65837. * @param data defines the data to store
  65838. */
  65839. create(data?: DataArray): void;
  65840. /**
  65841. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65842. * This function will create a new buffer if the current one is not updatable
  65843. * @param data defines the data to store
  65844. */
  65845. update(data: DataArray): void;
  65846. /**
  65847. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65848. * Returns the directly updated WebGLBuffer.
  65849. * @param data the new data
  65850. * @param offset the new offset
  65851. * @param useBytes set to true if the offset is in bytes
  65852. */
  65853. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65854. /**
  65855. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65856. */
  65857. dispose(): void;
  65858. /**
  65859. * Enumerates each value of this vertex buffer as numbers.
  65860. * @param count the number of values to enumerate
  65861. * @param callback the callback function called for each value
  65862. */
  65863. forEach(count: number, callback: (value: number, index: number) => void): void;
  65864. /**
  65865. * Positions
  65866. */
  65867. static readonly PositionKind: string;
  65868. /**
  65869. * Normals
  65870. */
  65871. static readonly NormalKind: string;
  65872. /**
  65873. * Tangents
  65874. */
  65875. static readonly TangentKind: string;
  65876. /**
  65877. * Texture coordinates
  65878. */
  65879. static readonly UVKind: string;
  65880. /**
  65881. * Texture coordinates 2
  65882. */
  65883. static readonly UV2Kind: string;
  65884. /**
  65885. * Texture coordinates 3
  65886. */
  65887. static readonly UV3Kind: string;
  65888. /**
  65889. * Texture coordinates 4
  65890. */
  65891. static readonly UV4Kind: string;
  65892. /**
  65893. * Texture coordinates 5
  65894. */
  65895. static readonly UV5Kind: string;
  65896. /**
  65897. * Texture coordinates 6
  65898. */
  65899. static readonly UV6Kind: string;
  65900. /**
  65901. * Colors
  65902. */
  65903. static readonly ColorKind: string;
  65904. /**
  65905. * Matrix indices (for bones)
  65906. */
  65907. static readonly MatricesIndicesKind: string;
  65908. /**
  65909. * Matrix weights (for bones)
  65910. */
  65911. static readonly MatricesWeightsKind: string;
  65912. /**
  65913. * Additional matrix indices (for bones)
  65914. */
  65915. static readonly MatricesIndicesExtraKind: string;
  65916. /**
  65917. * Additional matrix weights (for bones)
  65918. */
  65919. static readonly MatricesWeightsExtraKind: string;
  65920. /**
  65921. * Deduces the stride given a kind.
  65922. * @param kind The kind string to deduce
  65923. * @returns The deduced stride
  65924. */
  65925. static DeduceStride(kind: string): number;
  65926. /**
  65927. * Gets the byte length of the given type.
  65928. * @param type the type
  65929. * @returns the number of bytes
  65930. */
  65931. static GetTypeByteLength(type: number): number;
  65932. /**
  65933. * Enumerates each value of the given parameters as numbers.
  65934. * @param data the data to enumerate
  65935. * @param byteOffset the byte offset of the data
  65936. * @param byteStride the byte stride of the data
  65937. * @param componentCount the number of components per element
  65938. * @param componentType the type of the component
  65939. * @param count the number of values to enumerate
  65940. * @param normalized whether the data is normalized
  65941. * @param callback the callback function called for each value
  65942. */
  65943. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65944. private static _GetFloatValue;
  65945. }
  65946. }
  65947. declare module BABYLON {
  65948. /**
  65949. * Scalar computation library
  65950. */
  65951. export class Scalar {
  65952. /**
  65953. * Two pi constants convenient for computation.
  65954. */
  65955. static TwoPi: number;
  65956. /**
  65957. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65958. * @param a number
  65959. * @param b number
  65960. * @param epsilon (default = 1.401298E-45)
  65961. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65962. */
  65963. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65964. /**
  65965. * Returns a string : the upper case translation of the number i to hexadecimal.
  65966. * @param i number
  65967. * @returns the upper case translation of the number i to hexadecimal.
  65968. */
  65969. static ToHex(i: number): string;
  65970. /**
  65971. * Returns -1 if value is negative and +1 is value is positive.
  65972. * @param value the value
  65973. * @returns the value itself if it's equal to zero.
  65974. */
  65975. static Sign(value: number): number;
  65976. /**
  65977. * Returns the value itself if it's between min and max.
  65978. * Returns min if the value is lower than min.
  65979. * Returns max if the value is greater than max.
  65980. * @param value the value to clmap
  65981. * @param min the min value to clamp to (default: 0)
  65982. * @param max the max value to clamp to (default: 1)
  65983. * @returns the clamped value
  65984. */
  65985. static Clamp(value: number, min?: number, max?: number): number;
  65986. /**
  65987. * the log2 of value.
  65988. * @param value the value to compute log2 of
  65989. * @returns the log2 of value.
  65990. */
  65991. static Log2(value: number): number;
  65992. /**
  65993. * Loops the value, so that it is never larger than length and never smaller than 0.
  65994. *
  65995. * This is similar to the modulo operator but it works with floating point numbers.
  65996. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65997. * With t = 5 and length = 2.5, the result would be 0.0.
  65998. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65999. * @param value the value
  66000. * @param length the length
  66001. * @returns the looped value
  66002. */
  66003. static Repeat(value: number, length: number): number;
  66004. /**
  66005. * Normalize the value between 0.0 and 1.0 using min and max values
  66006. * @param value value to normalize
  66007. * @param min max to normalize between
  66008. * @param max min to normalize between
  66009. * @returns the normalized value
  66010. */
  66011. static Normalize(value: number, min: number, max: number): number;
  66012. /**
  66013. * Denormalize the value from 0.0 and 1.0 using min and max values
  66014. * @param normalized value to denormalize
  66015. * @param min max to denormalize between
  66016. * @param max min to denormalize between
  66017. * @returns the denormalized value
  66018. */
  66019. static Denormalize(normalized: number, min: number, max: number): number;
  66020. /**
  66021. * Calculates the shortest difference between two given angles given in degrees.
  66022. * @param current current angle in degrees
  66023. * @param target target angle in degrees
  66024. * @returns the delta
  66025. */
  66026. static DeltaAngle(current: number, target: number): number;
  66027. /**
  66028. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66029. * @param tx value
  66030. * @param length length
  66031. * @returns The returned value will move back and forth between 0 and length
  66032. */
  66033. static PingPong(tx: number, length: number): number;
  66034. /**
  66035. * Interpolates between min and max with smoothing at the limits.
  66036. *
  66037. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66038. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66039. * @param from from
  66040. * @param to to
  66041. * @param tx value
  66042. * @returns the smooth stepped value
  66043. */
  66044. static SmoothStep(from: number, to: number, tx: number): number;
  66045. /**
  66046. * Moves a value current towards target.
  66047. *
  66048. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66049. * Negative values of maxDelta pushes the value away from target.
  66050. * @param current current value
  66051. * @param target target value
  66052. * @param maxDelta max distance to move
  66053. * @returns resulting value
  66054. */
  66055. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66056. /**
  66057. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66058. *
  66059. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66060. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66061. * @param current current value
  66062. * @param target target value
  66063. * @param maxDelta max distance to move
  66064. * @returns resulting angle
  66065. */
  66066. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66067. /**
  66068. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66069. * @param start start value
  66070. * @param end target value
  66071. * @param amount amount to lerp between
  66072. * @returns the lerped value
  66073. */
  66074. static Lerp(start: number, end: number, amount: number): number;
  66075. /**
  66076. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66077. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66078. * @param start start value
  66079. * @param end target value
  66080. * @param amount amount to lerp between
  66081. * @returns the lerped value
  66082. */
  66083. static LerpAngle(start: number, end: number, amount: number): number;
  66084. /**
  66085. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66086. * @param a start value
  66087. * @param b target value
  66088. * @param value value between a and b
  66089. * @returns the inverseLerp value
  66090. */
  66091. static InverseLerp(a: number, b: number, value: number): number;
  66092. /**
  66093. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66094. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66095. * @param value1 spline value
  66096. * @param tangent1 spline value
  66097. * @param value2 spline value
  66098. * @param tangent2 spline value
  66099. * @param amount input value
  66100. * @returns hermite result
  66101. */
  66102. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66103. /**
  66104. * Returns a random float number between and min and max values
  66105. * @param min min value of random
  66106. * @param max max value of random
  66107. * @returns random value
  66108. */
  66109. static RandomRange(min: number, max: number): number;
  66110. /**
  66111. * This function returns percentage of a number in a given range.
  66112. *
  66113. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66114. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66115. * @param number to convert to percentage
  66116. * @param min min range
  66117. * @param max max range
  66118. * @returns the percentage
  66119. */
  66120. static RangeToPercent(number: number, min: number, max: number): number;
  66121. /**
  66122. * This function returns number that corresponds to the percentage in a given range.
  66123. *
  66124. * PercentToRange(0.34,0,100) will return 34.
  66125. * @param percent to convert to number
  66126. * @param min min range
  66127. * @param max max range
  66128. * @returns the number
  66129. */
  66130. static PercentToRange(percent: number, min: number, max: number): number;
  66131. /**
  66132. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66133. * @param angle The angle to normalize in radian.
  66134. * @return The converted angle.
  66135. */
  66136. static NormalizeRadians(angle: number): number;
  66137. }
  66138. }
  66139. declare module BABYLON {
  66140. /**
  66141. * Constant used to convert a value to gamma space
  66142. * @ignorenaming
  66143. */
  66144. export const ToGammaSpace: number;
  66145. /**
  66146. * Constant used to convert a value to linear space
  66147. * @ignorenaming
  66148. */
  66149. export const ToLinearSpace = 2.2;
  66150. /**
  66151. * Constant used to define the minimal number value in Babylon.js
  66152. * @ignorenaming
  66153. */
  66154. let Epsilon: number;
  66155. }
  66156. declare module BABYLON {
  66157. /**
  66158. * Class used to represent a viewport on screen
  66159. */
  66160. export class Viewport {
  66161. /** viewport left coordinate */
  66162. x: number;
  66163. /** viewport top coordinate */
  66164. y: number;
  66165. /**viewport width */
  66166. width: number;
  66167. /** viewport height */
  66168. height: number;
  66169. /**
  66170. * Creates a Viewport object located at (x, y) and sized (width, height)
  66171. * @param x defines viewport left coordinate
  66172. * @param y defines viewport top coordinate
  66173. * @param width defines the viewport width
  66174. * @param height defines the viewport height
  66175. */
  66176. constructor(
  66177. /** viewport left coordinate */
  66178. x: number,
  66179. /** viewport top coordinate */
  66180. y: number,
  66181. /**viewport width */
  66182. width: number,
  66183. /** viewport height */
  66184. height: number);
  66185. /**
  66186. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66187. * @param renderWidth defines the rendering width
  66188. * @param renderHeight defines the rendering height
  66189. * @returns a new Viewport
  66190. */
  66191. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66192. /**
  66193. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66194. * @param renderWidth defines the rendering width
  66195. * @param renderHeight defines the rendering height
  66196. * @param ref defines the target viewport
  66197. * @returns the current viewport
  66198. */
  66199. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66200. /**
  66201. * Returns a new Viewport copied from the current one
  66202. * @returns a new Viewport
  66203. */
  66204. clone(): Viewport;
  66205. }
  66206. }
  66207. declare module BABYLON {
  66208. /**
  66209. * Class containing a set of static utilities functions for arrays.
  66210. */
  66211. export class ArrayTools {
  66212. /**
  66213. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66214. * @param size the number of element to construct and put in the array
  66215. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66216. * @returns a new array filled with new objects
  66217. */
  66218. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66219. }
  66220. }
  66221. declare module BABYLON {
  66222. /**
  66223. * @hidden
  66224. */
  66225. export interface IColor4Like {
  66226. r: float;
  66227. g: float;
  66228. b: float;
  66229. a: float;
  66230. }
  66231. /**
  66232. * @hidden
  66233. */
  66234. export interface IColor3Like {
  66235. r: float;
  66236. g: float;
  66237. b: float;
  66238. }
  66239. /**
  66240. * @hidden
  66241. */
  66242. export interface IVector4Like {
  66243. x: float;
  66244. y: float;
  66245. z: float;
  66246. w: float;
  66247. }
  66248. /**
  66249. * @hidden
  66250. */
  66251. export interface IVector3Like {
  66252. x: float;
  66253. y: float;
  66254. z: float;
  66255. }
  66256. /**
  66257. * @hidden
  66258. */
  66259. export interface IVector2Like {
  66260. x: float;
  66261. y: float;
  66262. }
  66263. /**
  66264. * @hidden
  66265. */
  66266. export interface IMatrixLike {
  66267. toArray(): DeepImmutable<Float32Array>;
  66268. updateFlag: int;
  66269. }
  66270. /**
  66271. * @hidden
  66272. */
  66273. export interface IViewportLike {
  66274. x: float;
  66275. y: float;
  66276. width: float;
  66277. height: float;
  66278. }
  66279. /**
  66280. * @hidden
  66281. */
  66282. export interface IPlaneLike {
  66283. normal: IVector3Like;
  66284. d: float;
  66285. normalize(): void;
  66286. }
  66287. }
  66288. declare module BABYLON {
  66289. /**
  66290. * Class representing a vector containing 2 coordinates
  66291. */
  66292. export class Vector2 {
  66293. /** defines the first coordinate */
  66294. x: number;
  66295. /** defines the second coordinate */
  66296. y: number;
  66297. /**
  66298. * Creates a new Vector2 from the given x and y coordinates
  66299. * @param x defines the first coordinate
  66300. * @param y defines the second coordinate
  66301. */
  66302. constructor(
  66303. /** defines the first coordinate */
  66304. x?: number,
  66305. /** defines the second coordinate */
  66306. y?: number);
  66307. /**
  66308. * Gets a string with the Vector2 coordinates
  66309. * @returns a string with the Vector2 coordinates
  66310. */
  66311. toString(): string;
  66312. /**
  66313. * Gets class name
  66314. * @returns the string "Vector2"
  66315. */
  66316. getClassName(): string;
  66317. /**
  66318. * Gets current vector hash code
  66319. * @returns the Vector2 hash code as a number
  66320. */
  66321. getHashCode(): number;
  66322. /**
  66323. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66324. * @param array defines the source array
  66325. * @param index defines the offset in source array
  66326. * @returns the current Vector2
  66327. */
  66328. toArray(array: FloatArray, index?: number): Vector2;
  66329. /**
  66330. * Copy the current vector to an array
  66331. * @returns a new array with 2 elements: the Vector2 coordinates.
  66332. */
  66333. asArray(): number[];
  66334. /**
  66335. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66336. * @param source defines the source Vector2
  66337. * @returns the current updated Vector2
  66338. */
  66339. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66340. /**
  66341. * Sets the Vector2 coordinates with the given floats
  66342. * @param x defines the first coordinate
  66343. * @param y defines the second coordinate
  66344. * @returns the current updated Vector2
  66345. */
  66346. copyFromFloats(x: number, y: number): Vector2;
  66347. /**
  66348. * Sets the Vector2 coordinates with the given floats
  66349. * @param x defines the first coordinate
  66350. * @param y defines the second coordinate
  66351. * @returns the current updated Vector2
  66352. */
  66353. set(x: number, y: number): Vector2;
  66354. /**
  66355. * Add another vector with the current one
  66356. * @param otherVector defines the other vector
  66357. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66358. */
  66359. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66360. /**
  66361. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66362. * @param otherVector defines the other vector
  66363. * @param result defines the target vector
  66364. * @returns the unmodified current Vector2
  66365. */
  66366. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66367. /**
  66368. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66369. * @param otherVector defines the other vector
  66370. * @returns the current updated Vector2
  66371. */
  66372. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66373. /**
  66374. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66375. * @param otherVector defines the other vector
  66376. * @returns a new Vector2
  66377. */
  66378. addVector3(otherVector: Vector3): Vector2;
  66379. /**
  66380. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66381. * @param otherVector defines the other vector
  66382. * @returns a new Vector2
  66383. */
  66384. subtract(otherVector: Vector2): Vector2;
  66385. /**
  66386. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66387. * @param otherVector defines the other vector
  66388. * @param result defines the target vector
  66389. * @returns the unmodified current Vector2
  66390. */
  66391. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66392. /**
  66393. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66394. * @param otherVector defines the other vector
  66395. * @returns the current updated Vector2
  66396. */
  66397. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66398. /**
  66399. * Multiplies in place the current Vector2 coordinates by the given ones
  66400. * @param otherVector defines the other vector
  66401. * @returns the current updated Vector2
  66402. */
  66403. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66404. /**
  66405. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66406. * @param otherVector defines the other vector
  66407. * @returns a new Vector2
  66408. */
  66409. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66410. /**
  66411. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66412. * @param otherVector defines the other vector
  66413. * @param result defines the target vector
  66414. * @returns the unmodified current Vector2
  66415. */
  66416. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66417. /**
  66418. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66419. * @param x defines the first coordinate
  66420. * @param y defines the second coordinate
  66421. * @returns a new Vector2
  66422. */
  66423. multiplyByFloats(x: number, y: number): Vector2;
  66424. /**
  66425. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66426. * @param otherVector defines the other vector
  66427. * @returns a new Vector2
  66428. */
  66429. divide(otherVector: Vector2): Vector2;
  66430. /**
  66431. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66432. * @param otherVector defines the other vector
  66433. * @param result defines the target vector
  66434. * @returns the unmodified current Vector2
  66435. */
  66436. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66437. /**
  66438. * Divides the current Vector2 coordinates by the given ones
  66439. * @param otherVector defines the other vector
  66440. * @returns the current updated Vector2
  66441. */
  66442. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66443. /**
  66444. * Gets a new Vector2 with current Vector2 negated coordinates
  66445. * @returns a new Vector2
  66446. */
  66447. negate(): Vector2;
  66448. /**
  66449. * Multiply the Vector2 coordinates by scale
  66450. * @param scale defines the scaling factor
  66451. * @returns the current updated Vector2
  66452. */
  66453. scaleInPlace(scale: number): Vector2;
  66454. /**
  66455. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66456. * @param scale defines the scaling factor
  66457. * @returns a new Vector2
  66458. */
  66459. scale(scale: number): Vector2;
  66460. /**
  66461. * Scale the current Vector2 values by a factor to a given Vector2
  66462. * @param scale defines the scale factor
  66463. * @param result defines the Vector2 object where to store the result
  66464. * @returns the unmodified current Vector2
  66465. */
  66466. scaleToRef(scale: number, result: Vector2): Vector2;
  66467. /**
  66468. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66469. * @param scale defines the scale factor
  66470. * @param result defines the Vector2 object where to store the result
  66471. * @returns the unmodified current Vector2
  66472. */
  66473. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66474. /**
  66475. * Gets a boolean if two vectors are equals
  66476. * @param otherVector defines the other vector
  66477. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66478. */
  66479. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66480. /**
  66481. * Gets a boolean if two vectors are equals (using an epsilon value)
  66482. * @param otherVector defines the other vector
  66483. * @param epsilon defines the minimal distance to consider equality
  66484. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66485. */
  66486. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66487. /**
  66488. * Gets a new Vector2 from current Vector2 floored values
  66489. * @returns a new Vector2
  66490. */
  66491. floor(): Vector2;
  66492. /**
  66493. * Gets a new Vector2 from current Vector2 floored values
  66494. * @returns a new Vector2
  66495. */
  66496. fract(): Vector2;
  66497. /**
  66498. * Gets the length of the vector
  66499. * @returns the vector length (float)
  66500. */
  66501. length(): number;
  66502. /**
  66503. * Gets the vector squared length
  66504. * @returns the vector squared length (float)
  66505. */
  66506. lengthSquared(): number;
  66507. /**
  66508. * Normalize the vector
  66509. * @returns the current updated Vector2
  66510. */
  66511. normalize(): Vector2;
  66512. /**
  66513. * Gets a new Vector2 copied from the Vector2
  66514. * @returns a new Vector2
  66515. */
  66516. clone(): Vector2;
  66517. /**
  66518. * Gets a new Vector2(0, 0)
  66519. * @returns a new Vector2
  66520. */
  66521. static Zero(): Vector2;
  66522. /**
  66523. * Gets a new Vector2(1, 1)
  66524. * @returns a new Vector2
  66525. */
  66526. static One(): Vector2;
  66527. /**
  66528. * Gets a new Vector2 set from the given index element of the given array
  66529. * @param array defines the data source
  66530. * @param offset defines the offset in the data source
  66531. * @returns a new Vector2
  66532. */
  66533. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66534. /**
  66535. * Sets "result" from the given index element of the given array
  66536. * @param array defines the data source
  66537. * @param offset defines the offset in the data source
  66538. * @param result defines the target vector
  66539. */
  66540. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66541. /**
  66542. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66543. * @param value1 defines 1st point of control
  66544. * @param value2 defines 2nd point of control
  66545. * @param value3 defines 3rd point of control
  66546. * @param value4 defines 4th point of control
  66547. * @param amount defines the interpolation factor
  66548. * @returns a new Vector2
  66549. */
  66550. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66551. /**
  66552. * 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".
  66553. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66554. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66555. * @param value defines the value to clamp
  66556. * @param min defines the lower limit
  66557. * @param max defines the upper limit
  66558. * @returns a new Vector2
  66559. */
  66560. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66561. /**
  66562. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66563. * @param value1 defines the 1st control point
  66564. * @param tangent1 defines the outgoing tangent
  66565. * @param value2 defines the 2nd control point
  66566. * @param tangent2 defines the incoming tangent
  66567. * @param amount defines the interpolation factor
  66568. * @returns a new Vector2
  66569. */
  66570. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66571. /**
  66572. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66573. * @param start defines the start vector
  66574. * @param end defines the end vector
  66575. * @param amount defines the interpolation factor
  66576. * @returns a new Vector2
  66577. */
  66578. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66579. /**
  66580. * Gets the dot product of the vector "left" and the vector "right"
  66581. * @param left defines first vector
  66582. * @param right defines second vector
  66583. * @returns the dot product (float)
  66584. */
  66585. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66586. /**
  66587. * Returns a new Vector2 equal to the normalized given vector
  66588. * @param vector defines the vector to normalize
  66589. * @returns a new Vector2
  66590. */
  66591. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66592. /**
  66593. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66594. * @param left defines 1st vector
  66595. * @param right defines 2nd vector
  66596. * @returns a new Vector2
  66597. */
  66598. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66599. /**
  66600. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66601. * @param left defines 1st vector
  66602. * @param right defines 2nd vector
  66603. * @returns a new Vector2
  66604. */
  66605. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66606. /**
  66607. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66608. * @param vector defines the vector to transform
  66609. * @param transformation defines the matrix to apply
  66610. * @returns a new Vector2
  66611. */
  66612. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66613. /**
  66614. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66615. * @param vector defines the vector to transform
  66616. * @param transformation defines the matrix to apply
  66617. * @param result defines the target vector
  66618. */
  66619. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66620. /**
  66621. * Determines if a given vector is included in a triangle
  66622. * @param p defines the vector to test
  66623. * @param p0 defines 1st triangle point
  66624. * @param p1 defines 2nd triangle point
  66625. * @param p2 defines 3rd triangle point
  66626. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66627. */
  66628. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66629. /**
  66630. * Gets the distance between the vectors "value1" and "value2"
  66631. * @param value1 defines first vector
  66632. * @param value2 defines second vector
  66633. * @returns the distance between vectors
  66634. */
  66635. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66636. /**
  66637. * Returns the squared distance between the vectors "value1" and "value2"
  66638. * @param value1 defines first vector
  66639. * @param value2 defines second vector
  66640. * @returns the squared distance between vectors
  66641. */
  66642. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66643. /**
  66644. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66645. * @param value1 defines first vector
  66646. * @param value2 defines second vector
  66647. * @returns a new Vector2
  66648. */
  66649. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66650. /**
  66651. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66652. * @param p defines the middle point
  66653. * @param segA defines one point of the segment
  66654. * @param segB defines the other point of the segment
  66655. * @returns the shortest distance
  66656. */
  66657. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66658. }
  66659. /**
  66660. * Classed used to store (x,y,z) vector representation
  66661. * A Vector3 is the main object used in 3D geometry
  66662. * It can represent etiher the coordinates of a point the space, either a direction
  66663. * Reminder: js uses a left handed forward facing system
  66664. */
  66665. export class Vector3 {
  66666. /**
  66667. * Defines the first coordinates (on X axis)
  66668. */
  66669. x: number;
  66670. /**
  66671. * Defines the second coordinates (on Y axis)
  66672. */
  66673. y: number;
  66674. /**
  66675. * Defines the third coordinates (on Z axis)
  66676. */
  66677. z: number;
  66678. private static _UpReadOnly;
  66679. private static _ZeroReadOnly;
  66680. /**
  66681. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66682. * @param x defines the first coordinates (on X axis)
  66683. * @param y defines the second coordinates (on Y axis)
  66684. * @param z defines the third coordinates (on Z axis)
  66685. */
  66686. constructor(
  66687. /**
  66688. * Defines the first coordinates (on X axis)
  66689. */
  66690. x?: number,
  66691. /**
  66692. * Defines the second coordinates (on Y axis)
  66693. */
  66694. y?: number,
  66695. /**
  66696. * Defines the third coordinates (on Z axis)
  66697. */
  66698. z?: number);
  66699. /**
  66700. * Creates a string representation of the Vector3
  66701. * @returns a string with the Vector3 coordinates.
  66702. */
  66703. toString(): string;
  66704. /**
  66705. * Gets the class name
  66706. * @returns the string "Vector3"
  66707. */
  66708. getClassName(): string;
  66709. /**
  66710. * Creates the Vector3 hash code
  66711. * @returns a number which tends to be unique between Vector3 instances
  66712. */
  66713. getHashCode(): number;
  66714. /**
  66715. * Creates an array containing three elements : the coordinates of the Vector3
  66716. * @returns a new array of numbers
  66717. */
  66718. asArray(): number[];
  66719. /**
  66720. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66721. * @param array defines the destination array
  66722. * @param index defines the offset in the destination array
  66723. * @returns the current Vector3
  66724. */
  66725. toArray(array: FloatArray, index?: number): Vector3;
  66726. /**
  66727. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66728. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66729. */
  66730. toQuaternion(): Quaternion;
  66731. /**
  66732. * Adds the given vector to the current Vector3
  66733. * @param otherVector defines the second operand
  66734. * @returns the current updated Vector3
  66735. */
  66736. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66737. /**
  66738. * Adds the given coordinates to the current Vector3
  66739. * @param x defines the x coordinate of the operand
  66740. * @param y defines the y coordinate of the operand
  66741. * @param z defines the z coordinate of the operand
  66742. * @returns the current updated Vector3
  66743. */
  66744. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66745. /**
  66746. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66747. * @param otherVector defines the second operand
  66748. * @returns the resulting Vector3
  66749. */
  66750. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66751. /**
  66752. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66753. * @param otherVector defines the second operand
  66754. * @param result defines the Vector3 object where to store the result
  66755. * @returns the current Vector3
  66756. */
  66757. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66758. /**
  66759. * Subtract the given vector from the current Vector3
  66760. * @param otherVector defines the second operand
  66761. * @returns the current updated Vector3
  66762. */
  66763. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66764. /**
  66765. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66766. * @param otherVector defines the second operand
  66767. * @returns the resulting Vector3
  66768. */
  66769. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66770. /**
  66771. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66772. * @param otherVector defines the second operand
  66773. * @param result defines the Vector3 object where to store the result
  66774. * @returns the current Vector3
  66775. */
  66776. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66777. /**
  66778. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66779. * @param x defines the x coordinate of the operand
  66780. * @param y defines the y coordinate of the operand
  66781. * @param z defines the z coordinate of the operand
  66782. * @returns the resulting Vector3
  66783. */
  66784. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66785. /**
  66786. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66787. * @param x defines the x coordinate of the operand
  66788. * @param y defines the y coordinate of the operand
  66789. * @param z defines the z coordinate of the operand
  66790. * @param result defines the Vector3 object where to store the result
  66791. * @returns the current Vector3
  66792. */
  66793. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66794. /**
  66795. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66796. * @returns a new Vector3
  66797. */
  66798. negate(): Vector3;
  66799. /**
  66800. * Multiplies the Vector3 coordinates by the float "scale"
  66801. * @param scale defines the multiplier factor
  66802. * @returns the current updated Vector3
  66803. */
  66804. scaleInPlace(scale: number): Vector3;
  66805. /**
  66806. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66807. * @param scale defines the multiplier factor
  66808. * @returns a new Vector3
  66809. */
  66810. scale(scale: number): Vector3;
  66811. /**
  66812. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66813. * @param scale defines the multiplier factor
  66814. * @param result defines the Vector3 object where to store the result
  66815. * @returns the current Vector3
  66816. */
  66817. scaleToRef(scale: number, result: Vector3): Vector3;
  66818. /**
  66819. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66820. * @param scale defines the scale factor
  66821. * @param result defines the Vector3 object where to store the result
  66822. * @returns the unmodified current Vector3
  66823. */
  66824. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66825. /**
  66826. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66827. * @param otherVector defines the second operand
  66828. * @returns true if both vectors are equals
  66829. */
  66830. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66831. /**
  66832. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66833. * @param otherVector defines the second operand
  66834. * @param epsilon defines the minimal distance to define values as equals
  66835. * @returns true if both vectors are distant less than epsilon
  66836. */
  66837. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66838. /**
  66839. * Returns true if the current Vector3 coordinates equals the given floats
  66840. * @param x defines the x coordinate of the operand
  66841. * @param y defines the y coordinate of the operand
  66842. * @param z defines the z coordinate of the operand
  66843. * @returns true if both vectors are equals
  66844. */
  66845. equalsToFloats(x: number, y: number, z: number): boolean;
  66846. /**
  66847. * Multiplies the current Vector3 coordinates by the given ones
  66848. * @param otherVector defines the second operand
  66849. * @returns the current updated Vector3
  66850. */
  66851. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66852. /**
  66853. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66854. * @param otherVector defines the second operand
  66855. * @returns the new Vector3
  66856. */
  66857. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66858. /**
  66859. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66860. * @param otherVector defines the second operand
  66861. * @param result defines the Vector3 object where to store the result
  66862. * @returns the current Vector3
  66863. */
  66864. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66865. /**
  66866. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66867. * @param x defines the x coordinate of the operand
  66868. * @param y defines the y coordinate of the operand
  66869. * @param z defines the z coordinate of the operand
  66870. * @returns the new Vector3
  66871. */
  66872. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66873. /**
  66874. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66875. * @param otherVector defines the second operand
  66876. * @returns the new Vector3
  66877. */
  66878. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66879. /**
  66880. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66881. * @param otherVector defines the second operand
  66882. * @param result defines the Vector3 object where to store the result
  66883. * @returns the current Vector3
  66884. */
  66885. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66886. /**
  66887. * Divides the current Vector3 coordinates by the given ones.
  66888. * @param otherVector defines the second operand
  66889. * @returns the current updated Vector3
  66890. */
  66891. divideInPlace(otherVector: Vector3): Vector3;
  66892. /**
  66893. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66894. * @param other defines the second operand
  66895. * @returns the current updated Vector3
  66896. */
  66897. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66898. /**
  66899. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66900. * @param other defines the second operand
  66901. * @returns the current updated Vector3
  66902. */
  66903. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66904. /**
  66905. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66906. * @param x defines the x coordinate of the operand
  66907. * @param y defines the y coordinate of the operand
  66908. * @param z defines the z coordinate of the operand
  66909. * @returns the current updated Vector3
  66910. */
  66911. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66912. /**
  66913. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66914. * @param x defines the x coordinate of the operand
  66915. * @param y defines the y coordinate of the operand
  66916. * @param z defines the z coordinate of the operand
  66917. * @returns the current updated Vector3
  66918. */
  66919. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66920. /**
  66921. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66922. * Check if is non uniform within a certain amount of decimal places to account for this
  66923. * @param epsilon the amount the values can differ
  66924. * @returns if the the vector is non uniform to a certain number of decimal places
  66925. */
  66926. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66927. /**
  66928. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66929. */
  66930. readonly isNonUniform: boolean;
  66931. /**
  66932. * Gets a new Vector3 from current Vector3 floored values
  66933. * @returns a new Vector3
  66934. */
  66935. floor(): Vector3;
  66936. /**
  66937. * Gets a new Vector3 from current Vector3 floored values
  66938. * @returns a new Vector3
  66939. */
  66940. fract(): Vector3;
  66941. /**
  66942. * Gets the length of the Vector3
  66943. * @returns the length of the Vector3
  66944. */
  66945. length(): number;
  66946. /**
  66947. * Gets the squared length of the Vector3
  66948. * @returns squared length of the Vector3
  66949. */
  66950. lengthSquared(): number;
  66951. /**
  66952. * Normalize the current Vector3.
  66953. * Please note that this is an in place operation.
  66954. * @returns the current updated Vector3
  66955. */
  66956. normalize(): Vector3;
  66957. /**
  66958. * Reorders the x y z properties of the vector in place
  66959. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66960. * @returns the current updated vector
  66961. */
  66962. reorderInPlace(order: string): this;
  66963. /**
  66964. * Rotates the vector around 0,0,0 by a quaternion
  66965. * @param quaternion the rotation quaternion
  66966. * @param result vector to store the result
  66967. * @returns the resulting vector
  66968. */
  66969. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66970. /**
  66971. * Rotates a vector around a given point
  66972. * @param quaternion the rotation quaternion
  66973. * @param point the point to rotate around
  66974. * @param result vector to store the result
  66975. * @returns the resulting vector
  66976. */
  66977. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66978. /**
  66979. * Normalize the current Vector3 with the given input length.
  66980. * Please note that this is an in place operation.
  66981. * @param len the length of the vector
  66982. * @returns the current updated Vector3
  66983. */
  66984. normalizeFromLength(len: number): Vector3;
  66985. /**
  66986. * Normalize the current Vector3 to a new vector
  66987. * @returns the new Vector3
  66988. */
  66989. normalizeToNew(): Vector3;
  66990. /**
  66991. * Normalize the current Vector3 to the reference
  66992. * @param reference define the Vector3 to update
  66993. * @returns the updated Vector3
  66994. */
  66995. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66996. /**
  66997. * Creates a new Vector3 copied from the current Vector3
  66998. * @returns the new Vector3
  66999. */
  67000. clone(): Vector3;
  67001. /**
  67002. * Copies the given vector coordinates to the current Vector3 ones
  67003. * @param source defines the source Vector3
  67004. * @returns the current updated Vector3
  67005. */
  67006. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67007. /**
  67008. * Copies the given floats to the current Vector3 coordinates
  67009. * @param x defines the x coordinate of the operand
  67010. * @param y defines the y coordinate of the operand
  67011. * @param z defines the z coordinate of the operand
  67012. * @returns the current updated Vector3
  67013. */
  67014. copyFromFloats(x: number, y: number, z: number): Vector3;
  67015. /**
  67016. * Copies the given floats to the current Vector3 coordinates
  67017. * @param x defines the x coordinate of the operand
  67018. * @param y defines the y coordinate of the operand
  67019. * @param z defines the z coordinate of the operand
  67020. * @returns the current updated Vector3
  67021. */
  67022. set(x: number, y: number, z: number): Vector3;
  67023. /**
  67024. * Copies the given float to the current Vector3 coordinates
  67025. * @param v defines the x, y and z coordinates of the operand
  67026. * @returns the current updated Vector3
  67027. */
  67028. setAll(v: number): Vector3;
  67029. /**
  67030. * Get the clip factor between two vectors
  67031. * @param vector0 defines the first operand
  67032. * @param vector1 defines the second operand
  67033. * @param axis defines the axis to use
  67034. * @param size defines the size along the axis
  67035. * @returns the clip factor
  67036. */
  67037. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67038. /**
  67039. * Get angle between two vectors
  67040. * @param vector0 angle between vector0 and vector1
  67041. * @param vector1 angle between vector0 and vector1
  67042. * @param normal direction of the normal
  67043. * @return the angle between vector0 and vector1
  67044. */
  67045. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67046. /**
  67047. * Returns a new Vector3 set from the index "offset" of the given array
  67048. * @param array defines the source array
  67049. * @param offset defines the offset in the source array
  67050. * @returns the new Vector3
  67051. */
  67052. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67053. /**
  67054. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67055. * This function is deprecated. Use FromArray instead
  67056. * @param array defines the source array
  67057. * @param offset defines the offset in the source array
  67058. * @returns the new Vector3
  67059. */
  67060. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67061. /**
  67062. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67063. * @param array defines the source array
  67064. * @param offset defines the offset in the source array
  67065. * @param result defines the Vector3 where to store the result
  67066. */
  67067. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67068. /**
  67069. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67070. * This function is deprecated. Use FromArrayToRef instead.
  67071. * @param array defines the source array
  67072. * @param offset defines the offset in the source array
  67073. * @param result defines the Vector3 where to store the result
  67074. */
  67075. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67076. /**
  67077. * Sets the given vector "result" with the given floats.
  67078. * @param x defines the x coordinate of the source
  67079. * @param y defines the y coordinate of the source
  67080. * @param z defines the z coordinate of the source
  67081. * @param result defines the Vector3 where to store the result
  67082. */
  67083. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67084. /**
  67085. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67086. * @returns a new empty Vector3
  67087. */
  67088. static Zero(): Vector3;
  67089. /**
  67090. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67091. * @returns a new unit Vector3
  67092. */
  67093. static One(): Vector3;
  67094. /**
  67095. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67096. * @returns a new up Vector3
  67097. */
  67098. static Up(): Vector3;
  67099. /**
  67100. * Gets a up Vector3 that must not be updated
  67101. */
  67102. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67103. /**
  67104. * Gets a zero Vector3 that must not be updated
  67105. */
  67106. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67107. /**
  67108. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67109. * @returns a new down Vector3
  67110. */
  67111. static Down(): Vector3;
  67112. /**
  67113. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67114. * @returns a new forward Vector3
  67115. */
  67116. static Forward(): Vector3;
  67117. /**
  67118. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67119. * @returns a new forward Vector3
  67120. */
  67121. static Backward(): Vector3;
  67122. /**
  67123. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67124. * @returns a new right Vector3
  67125. */
  67126. static Right(): Vector3;
  67127. /**
  67128. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67129. * @returns a new left Vector3
  67130. */
  67131. static Left(): Vector3;
  67132. /**
  67133. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67134. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67135. * @param vector defines the Vector3 to transform
  67136. * @param transformation defines the transformation matrix
  67137. * @returns the transformed Vector3
  67138. */
  67139. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67140. /**
  67141. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67142. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67143. * @param vector defines the Vector3 to transform
  67144. * @param transformation defines the transformation matrix
  67145. * @param result defines the Vector3 where to store the result
  67146. */
  67147. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67148. /**
  67149. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67150. * This method computes tranformed coordinates only, not transformed direction vectors
  67151. * @param x define the x coordinate of the source vector
  67152. * @param y define the y coordinate of the source vector
  67153. * @param z define the z coordinate of the source vector
  67154. * @param transformation defines the transformation matrix
  67155. * @param result defines the Vector3 where to store the result
  67156. */
  67157. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67158. /**
  67159. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67160. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67161. * @param vector defines the Vector3 to transform
  67162. * @param transformation defines the transformation matrix
  67163. * @returns the new Vector3
  67164. */
  67165. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67166. /**
  67167. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67168. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67169. * @param vector defines the Vector3 to transform
  67170. * @param transformation defines the transformation matrix
  67171. * @param result defines the Vector3 where to store the result
  67172. */
  67173. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67174. /**
  67175. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67176. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67177. * @param x define the x coordinate of the source vector
  67178. * @param y define the y coordinate of the source vector
  67179. * @param z define the z coordinate of the source vector
  67180. * @param transformation defines the transformation matrix
  67181. * @param result defines the Vector3 where to store the result
  67182. */
  67183. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67184. /**
  67185. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67186. * @param value1 defines the first control point
  67187. * @param value2 defines the second control point
  67188. * @param value3 defines the third control point
  67189. * @param value4 defines the fourth control point
  67190. * @param amount defines the amount on the spline to use
  67191. * @returns the new Vector3
  67192. */
  67193. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67194. /**
  67195. * 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"
  67196. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67197. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67198. * @param value defines the current value
  67199. * @param min defines the lower range value
  67200. * @param max defines the upper range value
  67201. * @returns the new Vector3
  67202. */
  67203. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67204. /**
  67205. * 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"
  67206. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67207. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67208. * @param value defines the current value
  67209. * @param min defines the lower range value
  67210. * @param max defines the upper range value
  67211. * @param result defines the Vector3 where to store the result
  67212. */
  67213. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67214. /**
  67215. * Checks if a given vector is inside a specific range
  67216. * @param v defines the vector to test
  67217. * @param min defines the minimum range
  67218. * @param max defines the maximum range
  67219. */
  67220. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67221. /**
  67222. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67223. * @param value1 defines the first control point
  67224. * @param tangent1 defines the first tangent vector
  67225. * @param value2 defines the second control point
  67226. * @param tangent2 defines the second tangent vector
  67227. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67228. * @returns the new Vector3
  67229. */
  67230. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67231. /**
  67232. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67233. * @param start defines the start value
  67234. * @param end defines the end value
  67235. * @param amount max defines amount between both (between 0 and 1)
  67236. * @returns the new Vector3
  67237. */
  67238. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67239. /**
  67240. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67241. * @param start defines the start value
  67242. * @param end defines the end value
  67243. * @param amount max defines amount between both (between 0 and 1)
  67244. * @param result defines the Vector3 where to store the result
  67245. */
  67246. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67247. /**
  67248. * Returns the dot product (float) between the vectors "left" and "right"
  67249. * @param left defines the left operand
  67250. * @param right defines the right operand
  67251. * @returns the dot product
  67252. */
  67253. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67254. /**
  67255. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67256. * The cross product is then orthogonal to both "left" and "right"
  67257. * @param left defines the left operand
  67258. * @param right defines the right operand
  67259. * @returns the cross product
  67260. */
  67261. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67262. /**
  67263. * Sets the given vector "result" with the cross product of "left" and "right"
  67264. * The cross product is then orthogonal to both "left" and "right"
  67265. * @param left defines the left operand
  67266. * @param right defines the right operand
  67267. * @param result defines the Vector3 where to store the result
  67268. */
  67269. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67270. /**
  67271. * Returns a new Vector3 as the normalization of the given vector
  67272. * @param vector defines the Vector3 to normalize
  67273. * @returns the new Vector3
  67274. */
  67275. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67276. /**
  67277. * Sets the given vector "result" with the normalization of the given first vector
  67278. * @param vector defines the Vector3 to normalize
  67279. * @param result defines the Vector3 where to store the result
  67280. */
  67281. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67282. /**
  67283. * Project a Vector3 onto screen space
  67284. * @param vector defines the Vector3 to project
  67285. * @param world defines the world matrix to use
  67286. * @param transform defines the transform (view x projection) matrix to use
  67287. * @param viewport defines the screen viewport to use
  67288. * @returns the new Vector3
  67289. */
  67290. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67291. /** @hidden */
  67292. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67293. /**
  67294. * Unproject from screen space to object space
  67295. * @param source defines the screen space Vector3 to use
  67296. * @param viewportWidth defines the current width of the viewport
  67297. * @param viewportHeight defines the current height of the viewport
  67298. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67299. * @param transform defines the transform (view x projection) matrix to use
  67300. * @returns the new Vector3
  67301. */
  67302. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67303. /**
  67304. * Unproject from screen space to object space
  67305. * @param source defines the screen space Vector3 to use
  67306. * @param viewportWidth defines the current width of the viewport
  67307. * @param viewportHeight defines the current height of the viewport
  67308. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67309. * @param view defines the view matrix to use
  67310. * @param projection defines the projection matrix to use
  67311. * @returns the new Vector3
  67312. */
  67313. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67314. /**
  67315. * Unproject from screen space to object space
  67316. * @param source defines the screen space Vector3 to use
  67317. * @param viewportWidth defines the current width of the viewport
  67318. * @param viewportHeight defines the current height of the viewport
  67319. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67320. * @param view defines the view matrix to use
  67321. * @param projection defines the projection matrix to use
  67322. * @param result defines the Vector3 where to store the result
  67323. */
  67324. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67325. /**
  67326. * Unproject from screen space to object space
  67327. * @param sourceX defines the screen space x coordinate to use
  67328. * @param sourceY defines the screen space y coordinate to use
  67329. * @param sourceZ defines the screen space z coordinate to use
  67330. * @param viewportWidth defines the current width of the viewport
  67331. * @param viewportHeight defines the current height of the viewport
  67332. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67333. * @param view defines the view matrix to use
  67334. * @param projection defines the projection matrix to use
  67335. * @param result defines the Vector3 where to store the result
  67336. */
  67337. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67338. /**
  67339. * Gets the minimal coordinate values between two Vector3
  67340. * @param left defines the first operand
  67341. * @param right defines the second operand
  67342. * @returns the new Vector3
  67343. */
  67344. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67345. /**
  67346. * Gets the maximal coordinate values between two Vector3
  67347. * @param left defines the first operand
  67348. * @param right defines the second operand
  67349. * @returns the new Vector3
  67350. */
  67351. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67352. /**
  67353. * Returns the distance between the vectors "value1" and "value2"
  67354. * @param value1 defines the first operand
  67355. * @param value2 defines the second operand
  67356. * @returns the distance
  67357. */
  67358. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67359. /**
  67360. * Returns the squared distance between the vectors "value1" and "value2"
  67361. * @param value1 defines the first operand
  67362. * @param value2 defines the second operand
  67363. * @returns the squared distance
  67364. */
  67365. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67366. /**
  67367. * Returns a new Vector3 located at the center between "value1" and "value2"
  67368. * @param value1 defines the first operand
  67369. * @param value2 defines the second operand
  67370. * @returns the new Vector3
  67371. */
  67372. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67373. /**
  67374. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67375. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67376. * to something in order to rotate it from its local system to the given target system
  67377. * Note: axis1, axis2 and axis3 are normalized during this operation
  67378. * @param axis1 defines the first axis
  67379. * @param axis2 defines the second axis
  67380. * @param axis3 defines the third axis
  67381. * @returns a new Vector3
  67382. */
  67383. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67384. /**
  67385. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67386. * @param axis1 defines the first axis
  67387. * @param axis2 defines the second axis
  67388. * @param axis3 defines the third axis
  67389. * @param ref defines the Vector3 where to store the result
  67390. */
  67391. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67392. }
  67393. /**
  67394. * Vector4 class created for EulerAngle class conversion to Quaternion
  67395. */
  67396. export class Vector4 {
  67397. /** x value of the vector */
  67398. x: number;
  67399. /** y value of the vector */
  67400. y: number;
  67401. /** z value of the vector */
  67402. z: number;
  67403. /** w value of the vector */
  67404. w: number;
  67405. /**
  67406. * Creates a Vector4 object from the given floats.
  67407. * @param x x value of the vector
  67408. * @param y y value of the vector
  67409. * @param z z value of the vector
  67410. * @param w w value of the vector
  67411. */
  67412. constructor(
  67413. /** x value of the vector */
  67414. x: number,
  67415. /** y value of the vector */
  67416. y: number,
  67417. /** z value of the vector */
  67418. z: number,
  67419. /** w value of the vector */
  67420. w: number);
  67421. /**
  67422. * Returns the string with the Vector4 coordinates.
  67423. * @returns a string containing all the vector values
  67424. */
  67425. toString(): string;
  67426. /**
  67427. * Returns the string "Vector4".
  67428. * @returns "Vector4"
  67429. */
  67430. getClassName(): string;
  67431. /**
  67432. * Returns the Vector4 hash code.
  67433. * @returns a unique hash code
  67434. */
  67435. getHashCode(): number;
  67436. /**
  67437. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67438. * @returns the resulting array
  67439. */
  67440. asArray(): number[];
  67441. /**
  67442. * Populates the given array from the given index with the Vector4 coordinates.
  67443. * @param array array to populate
  67444. * @param index index of the array to start at (default: 0)
  67445. * @returns the Vector4.
  67446. */
  67447. toArray(array: FloatArray, index?: number): Vector4;
  67448. /**
  67449. * Adds the given vector to the current Vector4.
  67450. * @param otherVector the vector to add
  67451. * @returns the updated Vector4.
  67452. */
  67453. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67454. /**
  67455. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67456. * @param otherVector the vector to add
  67457. * @returns the resulting vector
  67458. */
  67459. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67460. /**
  67461. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67462. * @param otherVector the vector to add
  67463. * @param result the vector to store the result
  67464. * @returns the current Vector4.
  67465. */
  67466. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67467. /**
  67468. * Subtract in place the given vector from the current Vector4.
  67469. * @param otherVector the vector to subtract
  67470. * @returns the updated Vector4.
  67471. */
  67472. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67473. /**
  67474. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67475. * @param otherVector the vector to add
  67476. * @returns the new vector with the result
  67477. */
  67478. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67479. /**
  67480. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67481. * @param otherVector the vector to subtract
  67482. * @param result the vector to store the result
  67483. * @returns the current Vector4.
  67484. */
  67485. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67486. /**
  67487. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67488. */
  67489. /**
  67490. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67491. * @param x value to subtract
  67492. * @param y value to subtract
  67493. * @param z value to subtract
  67494. * @param w value to subtract
  67495. * @returns new vector containing the result
  67496. */
  67497. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67498. /**
  67499. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67500. * @param x value to subtract
  67501. * @param y value to subtract
  67502. * @param z value to subtract
  67503. * @param w value to subtract
  67504. * @param result the vector to store the result in
  67505. * @returns the current Vector4.
  67506. */
  67507. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67508. /**
  67509. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67510. * @returns a new vector with the negated values
  67511. */
  67512. negate(): Vector4;
  67513. /**
  67514. * Multiplies the current Vector4 coordinates by scale (float).
  67515. * @param scale the number to scale with
  67516. * @returns the updated Vector4.
  67517. */
  67518. scaleInPlace(scale: number): Vector4;
  67519. /**
  67520. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67521. * @param scale the number to scale with
  67522. * @returns a new vector with the result
  67523. */
  67524. scale(scale: number): Vector4;
  67525. /**
  67526. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67527. * @param scale the number to scale with
  67528. * @param result a vector to store the result in
  67529. * @returns the current Vector4.
  67530. */
  67531. scaleToRef(scale: number, result: Vector4): Vector4;
  67532. /**
  67533. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67534. * @param scale defines the scale factor
  67535. * @param result defines the Vector4 object where to store the result
  67536. * @returns the unmodified current Vector4
  67537. */
  67538. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67539. /**
  67540. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67541. * @param otherVector the vector to compare against
  67542. * @returns true if they are equal
  67543. */
  67544. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67545. /**
  67546. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67547. * @param otherVector vector to compare against
  67548. * @param epsilon (Default: very small number)
  67549. * @returns true if they are equal
  67550. */
  67551. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67552. /**
  67553. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67554. * @param x x value to compare against
  67555. * @param y y value to compare against
  67556. * @param z z value to compare against
  67557. * @param w w value to compare against
  67558. * @returns true if equal
  67559. */
  67560. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67561. /**
  67562. * Multiplies in place the current Vector4 by the given one.
  67563. * @param otherVector vector to multiple with
  67564. * @returns the updated Vector4.
  67565. */
  67566. multiplyInPlace(otherVector: Vector4): Vector4;
  67567. /**
  67568. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67569. * @param otherVector vector to multiple with
  67570. * @returns resulting new vector
  67571. */
  67572. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67573. /**
  67574. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67575. * @param otherVector vector to multiple with
  67576. * @param result vector to store the result
  67577. * @returns the current Vector4.
  67578. */
  67579. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67580. /**
  67581. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67582. * @param x x value multiply with
  67583. * @param y y value multiply with
  67584. * @param z z value multiply with
  67585. * @param w w value multiply with
  67586. * @returns resulting new vector
  67587. */
  67588. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67589. /**
  67590. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67591. * @param otherVector vector to devide with
  67592. * @returns resulting new vector
  67593. */
  67594. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67595. /**
  67596. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67597. * @param otherVector vector to devide with
  67598. * @param result vector to store the result
  67599. * @returns the current Vector4.
  67600. */
  67601. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67602. /**
  67603. * Divides the current Vector3 coordinates by the given ones.
  67604. * @param otherVector vector to devide with
  67605. * @returns the updated Vector3.
  67606. */
  67607. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67608. /**
  67609. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67610. * @param other defines the second operand
  67611. * @returns the current updated Vector4
  67612. */
  67613. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67614. /**
  67615. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67616. * @param other defines the second operand
  67617. * @returns the current updated Vector4
  67618. */
  67619. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67620. /**
  67621. * Gets a new Vector4 from current Vector4 floored values
  67622. * @returns a new Vector4
  67623. */
  67624. floor(): Vector4;
  67625. /**
  67626. * Gets a new Vector4 from current Vector3 floored values
  67627. * @returns a new Vector4
  67628. */
  67629. fract(): Vector4;
  67630. /**
  67631. * Returns the Vector4 length (float).
  67632. * @returns the length
  67633. */
  67634. length(): number;
  67635. /**
  67636. * Returns the Vector4 squared length (float).
  67637. * @returns the length squared
  67638. */
  67639. lengthSquared(): number;
  67640. /**
  67641. * Normalizes in place the Vector4.
  67642. * @returns the updated Vector4.
  67643. */
  67644. normalize(): Vector4;
  67645. /**
  67646. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67647. * @returns this converted to a new vector3
  67648. */
  67649. toVector3(): Vector3;
  67650. /**
  67651. * Returns a new Vector4 copied from the current one.
  67652. * @returns the new cloned vector
  67653. */
  67654. clone(): Vector4;
  67655. /**
  67656. * Updates the current Vector4 with the given one coordinates.
  67657. * @param source the source vector to copy from
  67658. * @returns the updated Vector4.
  67659. */
  67660. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67661. /**
  67662. * Updates the current Vector4 coordinates with the given floats.
  67663. * @param x float to copy from
  67664. * @param y float to copy from
  67665. * @param z float to copy from
  67666. * @param w float to copy from
  67667. * @returns the updated Vector4.
  67668. */
  67669. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67670. /**
  67671. * Updates the current Vector4 coordinates with the given floats.
  67672. * @param x float to set from
  67673. * @param y float to set from
  67674. * @param z float to set from
  67675. * @param w float to set from
  67676. * @returns the updated Vector4.
  67677. */
  67678. set(x: number, y: number, z: number, w: number): Vector4;
  67679. /**
  67680. * Copies the given float to the current Vector3 coordinates
  67681. * @param v defines the x, y, z and w coordinates of the operand
  67682. * @returns the current updated Vector3
  67683. */
  67684. setAll(v: number): Vector4;
  67685. /**
  67686. * Returns a new Vector4 set from the starting index of the given array.
  67687. * @param array the array to pull values from
  67688. * @param offset the offset into the array to start at
  67689. * @returns the new vector
  67690. */
  67691. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67692. /**
  67693. * Updates the given vector "result" from the starting index of the given array.
  67694. * @param array the array to pull values from
  67695. * @param offset the offset into the array to start at
  67696. * @param result the vector to store the result in
  67697. */
  67698. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67699. /**
  67700. * Updates the given vector "result" from the starting index of the given Float32Array.
  67701. * @param array the array to pull values from
  67702. * @param offset the offset into the array to start at
  67703. * @param result the vector to store the result in
  67704. */
  67705. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67706. /**
  67707. * Updates the given vector "result" coordinates from the given floats.
  67708. * @param x float to set from
  67709. * @param y float to set from
  67710. * @param z float to set from
  67711. * @param w float to set from
  67712. * @param result the vector to the floats in
  67713. */
  67714. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67715. /**
  67716. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67717. * @returns the new vector
  67718. */
  67719. static Zero(): Vector4;
  67720. /**
  67721. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67722. * @returns the new vector
  67723. */
  67724. static One(): Vector4;
  67725. /**
  67726. * Returns a new normalized Vector4 from the given one.
  67727. * @param vector the vector to normalize
  67728. * @returns the vector
  67729. */
  67730. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67731. /**
  67732. * Updates the given vector "result" from the normalization of the given one.
  67733. * @param vector the vector to normalize
  67734. * @param result the vector to store the result in
  67735. */
  67736. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67737. /**
  67738. * Returns a vector with the minimum values from the left and right vectors
  67739. * @param left left vector to minimize
  67740. * @param right right vector to minimize
  67741. * @returns a new vector with the minimum of the left and right vector values
  67742. */
  67743. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67744. /**
  67745. * Returns a vector with the maximum values from the left and right vectors
  67746. * @param left left vector to maximize
  67747. * @param right right vector to maximize
  67748. * @returns a new vector with the maximum of the left and right vector values
  67749. */
  67750. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67751. /**
  67752. * Returns the distance (float) between the vectors "value1" and "value2".
  67753. * @param value1 value to calulate the distance between
  67754. * @param value2 value to calulate the distance between
  67755. * @return the distance between the two vectors
  67756. */
  67757. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67758. /**
  67759. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67760. * @param value1 value to calulate the distance between
  67761. * @param value2 value to calulate the distance between
  67762. * @return the distance between the two vectors squared
  67763. */
  67764. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67765. /**
  67766. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67767. * @param value1 value to calulate the center between
  67768. * @param value2 value to calulate the center between
  67769. * @return the center between the two vectors
  67770. */
  67771. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67772. /**
  67773. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67774. * This methods computes transformed normalized direction vectors only.
  67775. * @param vector the vector to transform
  67776. * @param transformation the transformation matrix to apply
  67777. * @returns the new vector
  67778. */
  67779. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67780. /**
  67781. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67782. * This methods computes transformed normalized direction vectors only.
  67783. * @param vector the vector to transform
  67784. * @param transformation the transformation matrix to apply
  67785. * @param result the vector to store the result in
  67786. */
  67787. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67788. /**
  67789. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67790. * This methods computes transformed normalized direction vectors only.
  67791. * @param x value to transform
  67792. * @param y value to transform
  67793. * @param z value to transform
  67794. * @param w value to transform
  67795. * @param transformation the transformation matrix to apply
  67796. * @param result the vector to store the results in
  67797. */
  67798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67799. /**
  67800. * Creates a new Vector4 from a Vector3
  67801. * @param source defines the source data
  67802. * @param w defines the 4th component (default is 0)
  67803. * @returns a new Vector4
  67804. */
  67805. static FromVector3(source: Vector3, w?: number): Vector4;
  67806. }
  67807. /**
  67808. * Class used to store quaternion data
  67809. * @see https://en.wikipedia.org/wiki/Quaternion
  67810. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67811. */
  67812. export class Quaternion {
  67813. /** defines the first component (0 by default) */
  67814. x: number;
  67815. /** defines the second component (0 by default) */
  67816. y: number;
  67817. /** defines the third component (0 by default) */
  67818. z: number;
  67819. /** defines the fourth component (1.0 by default) */
  67820. w: number;
  67821. /**
  67822. * Creates a new Quaternion from the given floats
  67823. * @param x defines the first component (0 by default)
  67824. * @param y defines the second component (0 by default)
  67825. * @param z defines the third component (0 by default)
  67826. * @param w defines the fourth component (1.0 by default)
  67827. */
  67828. constructor(
  67829. /** defines the first component (0 by default) */
  67830. x?: number,
  67831. /** defines the second component (0 by default) */
  67832. y?: number,
  67833. /** defines the third component (0 by default) */
  67834. z?: number,
  67835. /** defines the fourth component (1.0 by default) */
  67836. w?: number);
  67837. /**
  67838. * Gets a string representation for the current quaternion
  67839. * @returns a string with the Quaternion coordinates
  67840. */
  67841. toString(): string;
  67842. /**
  67843. * Gets the class name of the quaternion
  67844. * @returns the string "Quaternion"
  67845. */
  67846. getClassName(): string;
  67847. /**
  67848. * Gets a hash code for this quaternion
  67849. * @returns the quaternion hash code
  67850. */
  67851. getHashCode(): number;
  67852. /**
  67853. * Copy the quaternion to an array
  67854. * @returns a new array populated with 4 elements from the quaternion coordinates
  67855. */
  67856. asArray(): number[];
  67857. /**
  67858. * Check if two quaternions are equals
  67859. * @param otherQuaternion defines the second operand
  67860. * @return true if the current quaternion and the given one coordinates are strictly equals
  67861. */
  67862. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67863. /**
  67864. * Clone the current quaternion
  67865. * @returns a new quaternion copied from the current one
  67866. */
  67867. clone(): Quaternion;
  67868. /**
  67869. * Copy a quaternion to the current one
  67870. * @param other defines the other quaternion
  67871. * @returns the updated current quaternion
  67872. */
  67873. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67874. /**
  67875. * Updates the current quaternion with the given float coordinates
  67876. * @param x defines the x coordinate
  67877. * @param y defines the y coordinate
  67878. * @param z defines the z coordinate
  67879. * @param w defines the w coordinate
  67880. * @returns the updated current quaternion
  67881. */
  67882. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67883. /**
  67884. * Updates the current quaternion from the given float coordinates
  67885. * @param x defines the x coordinate
  67886. * @param y defines the y coordinate
  67887. * @param z defines the z coordinate
  67888. * @param w defines the w coordinate
  67889. * @returns the updated current quaternion
  67890. */
  67891. set(x: number, y: number, z: number, w: number): Quaternion;
  67892. /**
  67893. * Adds two quaternions
  67894. * @param other defines the second operand
  67895. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67896. */
  67897. add(other: DeepImmutable<Quaternion>): Quaternion;
  67898. /**
  67899. * Add a quaternion to the current one
  67900. * @param other defines the quaternion to add
  67901. * @returns the current quaternion
  67902. */
  67903. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67904. /**
  67905. * Subtract two quaternions
  67906. * @param other defines the second operand
  67907. * @returns a new quaternion as the subtraction result of the given one from the current one
  67908. */
  67909. subtract(other: Quaternion): Quaternion;
  67910. /**
  67911. * Multiplies the current quaternion by a scale factor
  67912. * @param value defines the scale factor
  67913. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67914. */
  67915. scale(value: number): Quaternion;
  67916. /**
  67917. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67918. * @param scale defines the scale factor
  67919. * @param result defines the Quaternion object where to store the result
  67920. * @returns the unmodified current quaternion
  67921. */
  67922. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67923. /**
  67924. * Multiplies in place the current quaternion by a scale factor
  67925. * @param value defines the scale factor
  67926. * @returns the current modified quaternion
  67927. */
  67928. scaleInPlace(value: number): Quaternion;
  67929. /**
  67930. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67931. * @param scale defines the scale factor
  67932. * @param result defines the Quaternion object where to store the result
  67933. * @returns the unmodified current quaternion
  67934. */
  67935. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67936. /**
  67937. * Multiplies two quaternions
  67938. * @param q1 defines the second operand
  67939. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67940. */
  67941. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67942. /**
  67943. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67944. * @param q1 defines the second operand
  67945. * @param result defines the target quaternion
  67946. * @returns the current quaternion
  67947. */
  67948. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67949. /**
  67950. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67951. * @param q1 defines the second operand
  67952. * @returns the currentupdated quaternion
  67953. */
  67954. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67955. /**
  67956. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67957. * @param ref defines the target quaternion
  67958. * @returns the current quaternion
  67959. */
  67960. conjugateToRef(ref: Quaternion): Quaternion;
  67961. /**
  67962. * Conjugates in place (1-q) the current quaternion
  67963. * @returns the current updated quaternion
  67964. */
  67965. conjugateInPlace(): Quaternion;
  67966. /**
  67967. * Conjugates in place (1-q) the current quaternion
  67968. * @returns a new quaternion
  67969. */
  67970. conjugate(): Quaternion;
  67971. /**
  67972. * Gets length of current quaternion
  67973. * @returns the quaternion length (float)
  67974. */
  67975. length(): number;
  67976. /**
  67977. * Normalize in place the current quaternion
  67978. * @returns the current updated quaternion
  67979. */
  67980. normalize(): Quaternion;
  67981. /**
  67982. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67983. * @param order is a reserved parameter and is ignore for now
  67984. * @returns a new Vector3 containing the Euler angles
  67985. */
  67986. toEulerAngles(order?: string): Vector3;
  67987. /**
  67988. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67989. * @param result defines the vector which will be filled with the Euler angles
  67990. * @param order is a reserved parameter and is ignore for now
  67991. * @returns the current unchanged quaternion
  67992. */
  67993. toEulerAnglesToRef(result: Vector3): Quaternion;
  67994. /**
  67995. * Updates the given rotation matrix with the current quaternion values
  67996. * @param result defines the target matrix
  67997. * @returns the current unchanged quaternion
  67998. */
  67999. toRotationMatrix(result: Matrix): Quaternion;
  68000. /**
  68001. * Updates the current quaternion from the given rotation matrix values
  68002. * @param matrix defines the source matrix
  68003. * @returns the current updated quaternion
  68004. */
  68005. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68006. /**
  68007. * Creates a new quaternion from a rotation matrix
  68008. * @param matrix defines the source matrix
  68009. * @returns a new quaternion created from the given rotation matrix values
  68010. */
  68011. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68012. /**
  68013. * Updates the given quaternion with the given rotation matrix values
  68014. * @param matrix defines the source matrix
  68015. * @param result defines the target quaternion
  68016. */
  68017. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68018. /**
  68019. * Returns the dot product (float) between the quaternions "left" and "right"
  68020. * @param left defines the left operand
  68021. * @param right defines the right operand
  68022. * @returns the dot product
  68023. */
  68024. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68025. /**
  68026. * Checks if the two quaternions are close to each other
  68027. * @param quat0 defines the first quaternion to check
  68028. * @param quat1 defines the second quaternion to check
  68029. * @returns true if the two quaternions are close to each other
  68030. */
  68031. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68032. /**
  68033. * Creates an empty quaternion
  68034. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68035. */
  68036. static Zero(): Quaternion;
  68037. /**
  68038. * Inverse a given quaternion
  68039. * @param q defines the source quaternion
  68040. * @returns a new quaternion as the inverted current quaternion
  68041. */
  68042. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68043. /**
  68044. * Inverse a given quaternion
  68045. * @param q defines the source quaternion
  68046. * @param result the quaternion the result will be stored in
  68047. * @returns the result quaternion
  68048. */
  68049. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68050. /**
  68051. * Creates an identity quaternion
  68052. * @returns the identity quaternion
  68053. */
  68054. static Identity(): Quaternion;
  68055. /**
  68056. * Gets a boolean indicating if the given quaternion is identity
  68057. * @param quaternion defines the quaternion to check
  68058. * @returns true if the quaternion is identity
  68059. */
  68060. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68061. /**
  68062. * Creates a quaternion from a rotation around an axis
  68063. * @param axis defines the axis to use
  68064. * @param angle defines the angle to use
  68065. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68066. */
  68067. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68068. /**
  68069. * Creates a rotation around an axis and stores it into the given quaternion
  68070. * @param axis defines the axis to use
  68071. * @param angle defines the angle to use
  68072. * @param result defines the target quaternion
  68073. * @returns the target quaternion
  68074. */
  68075. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68076. /**
  68077. * Creates a new quaternion from data stored into an array
  68078. * @param array defines the data source
  68079. * @param offset defines the offset in the source array where the data starts
  68080. * @returns a new quaternion
  68081. */
  68082. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68083. /**
  68084. * Create a quaternion from Euler rotation angles
  68085. * @param x Pitch
  68086. * @param y Yaw
  68087. * @param z Roll
  68088. * @returns the new Quaternion
  68089. */
  68090. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68091. /**
  68092. * Updates a quaternion from Euler rotation angles
  68093. * @param x Pitch
  68094. * @param y Yaw
  68095. * @param z Roll
  68096. * @param result the quaternion to store the result
  68097. * @returns the updated quaternion
  68098. */
  68099. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68100. /**
  68101. * Create a quaternion from Euler rotation vector
  68102. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68103. * @returns the new Quaternion
  68104. */
  68105. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68106. /**
  68107. * Updates a quaternion from Euler rotation vector
  68108. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68109. * @param result the quaternion to store the result
  68110. * @returns the updated quaternion
  68111. */
  68112. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68113. /**
  68114. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68115. * @param yaw defines the rotation around Y axis
  68116. * @param pitch defines the rotation around X axis
  68117. * @param roll defines the rotation around Z axis
  68118. * @returns the new quaternion
  68119. */
  68120. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68121. /**
  68122. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68123. * @param yaw defines the rotation around Y axis
  68124. * @param pitch defines the rotation around X axis
  68125. * @param roll defines the rotation around Z axis
  68126. * @param result defines the target quaternion
  68127. */
  68128. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68129. /**
  68130. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68131. * @param alpha defines the rotation around first axis
  68132. * @param beta defines the rotation around second axis
  68133. * @param gamma defines the rotation around third axis
  68134. * @returns the new quaternion
  68135. */
  68136. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68137. /**
  68138. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68139. * @param alpha defines the rotation around first axis
  68140. * @param beta defines the rotation around second axis
  68141. * @param gamma defines the rotation around third axis
  68142. * @param result defines the target quaternion
  68143. */
  68144. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68145. /**
  68146. * 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)
  68147. * @param axis1 defines the first axis
  68148. * @param axis2 defines the second axis
  68149. * @param axis3 defines the third axis
  68150. * @returns the new quaternion
  68151. */
  68152. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68153. /**
  68154. * 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
  68155. * @param axis1 defines the first axis
  68156. * @param axis2 defines the second axis
  68157. * @param axis3 defines the third axis
  68158. * @param ref defines the target quaternion
  68159. */
  68160. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68161. /**
  68162. * Interpolates between two quaternions
  68163. * @param left defines first quaternion
  68164. * @param right defines second quaternion
  68165. * @param amount defines the gradient to use
  68166. * @returns the new interpolated quaternion
  68167. */
  68168. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68169. /**
  68170. * Interpolates between two quaternions and stores it into a target quaternion
  68171. * @param left defines first quaternion
  68172. * @param right defines second quaternion
  68173. * @param amount defines the gradient to use
  68174. * @param result defines the target quaternion
  68175. */
  68176. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68177. /**
  68178. * Interpolate between two quaternions using Hermite interpolation
  68179. * @param value1 defines first quaternion
  68180. * @param tangent1 defines the incoming tangent
  68181. * @param value2 defines second quaternion
  68182. * @param tangent2 defines the outgoing tangent
  68183. * @param amount defines the target quaternion
  68184. * @returns the new interpolated quaternion
  68185. */
  68186. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68187. }
  68188. /**
  68189. * Class used to store matrix data (4x4)
  68190. */
  68191. export class Matrix {
  68192. private static _updateFlagSeed;
  68193. private static _identityReadOnly;
  68194. private _isIdentity;
  68195. private _isIdentityDirty;
  68196. private _isIdentity3x2;
  68197. private _isIdentity3x2Dirty;
  68198. /**
  68199. * Gets the update flag of the matrix which is an unique number for the matrix.
  68200. * It will be incremented every time the matrix data change.
  68201. * You can use it to speed the comparison between two versions of the same matrix.
  68202. */
  68203. updateFlag: number;
  68204. private readonly _m;
  68205. /**
  68206. * Gets the internal data of the matrix
  68207. */
  68208. readonly m: DeepImmutable<Float32Array>;
  68209. /** @hidden */
  68210. _markAsUpdated(): void;
  68211. /** @hidden */
  68212. private _updateIdentityStatus;
  68213. /**
  68214. * Creates an empty matrix (filled with zeros)
  68215. */
  68216. constructor();
  68217. /**
  68218. * Check if the current matrix is identity
  68219. * @returns true is the matrix is the identity matrix
  68220. */
  68221. isIdentity(): boolean;
  68222. /**
  68223. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68224. * @returns true is the matrix is the identity matrix
  68225. */
  68226. isIdentityAs3x2(): boolean;
  68227. /**
  68228. * Gets the determinant of the matrix
  68229. * @returns the matrix determinant
  68230. */
  68231. determinant(): number;
  68232. /**
  68233. * Returns the matrix as a Float32Array
  68234. * @returns the matrix underlying array
  68235. */
  68236. toArray(): DeepImmutable<Float32Array>;
  68237. /**
  68238. * Returns the matrix as a Float32Array
  68239. * @returns the matrix underlying array.
  68240. */
  68241. asArray(): DeepImmutable<Float32Array>;
  68242. /**
  68243. * Inverts the current matrix in place
  68244. * @returns the current inverted matrix
  68245. */
  68246. invert(): Matrix;
  68247. /**
  68248. * Sets all the matrix elements to zero
  68249. * @returns the current matrix
  68250. */
  68251. reset(): Matrix;
  68252. /**
  68253. * Adds the current matrix with a second one
  68254. * @param other defines the matrix to add
  68255. * @returns a new matrix as the addition of the current matrix and the given one
  68256. */
  68257. add(other: DeepImmutable<Matrix>): Matrix;
  68258. /**
  68259. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68260. * @param other defines the matrix to add
  68261. * @param result defines the target matrix
  68262. * @returns the current matrix
  68263. */
  68264. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68265. /**
  68266. * Adds in place the given matrix to the current matrix
  68267. * @param other defines the second operand
  68268. * @returns the current updated matrix
  68269. */
  68270. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68271. /**
  68272. * Sets the given matrix to the current inverted Matrix
  68273. * @param other defines the target matrix
  68274. * @returns the unmodified current matrix
  68275. */
  68276. invertToRef(other: Matrix): Matrix;
  68277. /**
  68278. * add a value at the specified position in the current Matrix
  68279. * @param index the index of the value within the matrix. between 0 and 15.
  68280. * @param value the value to be added
  68281. * @returns the current updated matrix
  68282. */
  68283. addAtIndex(index: number, value: number): Matrix;
  68284. /**
  68285. * mutiply the specified position in the current Matrix by a value
  68286. * @param index the index of the value within the matrix. between 0 and 15.
  68287. * @param value the value to be added
  68288. * @returns the current updated matrix
  68289. */
  68290. multiplyAtIndex(index: number, value: number): Matrix;
  68291. /**
  68292. * Inserts the translation vector (using 3 floats) in the current matrix
  68293. * @param x defines the 1st component of the translation
  68294. * @param y defines the 2nd component of the translation
  68295. * @param z defines the 3rd component of the translation
  68296. * @returns the current updated matrix
  68297. */
  68298. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68299. /**
  68300. * Adds the translation vector (using 3 floats) in the current matrix
  68301. * @param x defines the 1st component of the translation
  68302. * @param y defines the 2nd component of the translation
  68303. * @param z defines the 3rd component of the translation
  68304. * @returns the current updated matrix
  68305. */
  68306. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68307. /**
  68308. * Inserts the translation vector in the current matrix
  68309. * @param vector3 defines the translation to insert
  68310. * @returns the current updated matrix
  68311. */
  68312. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68313. /**
  68314. * Gets the translation value of the current matrix
  68315. * @returns a new Vector3 as the extracted translation from the matrix
  68316. */
  68317. getTranslation(): Vector3;
  68318. /**
  68319. * Fill a Vector3 with the extracted translation from the matrix
  68320. * @param result defines the Vector3 where to store the translation
  68321. * @returns the current matrix
  68322. */
  68323. getTranslationToRef(result: Vector3): Matrix;
  68324. /**
  68325. * Remove rotation and scaling part from the matrix
  68326. * @returns the updated matrix
  68327. */
  68328. removeRotationAndScaling(): Matrix;
  68329. /**
  68330. * Multiply two matrices
  68331. * @param other defines the second operand
  68332. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68333. */
  68334. multiply(other: DeepImmutable<Matrix>): Matrix;
  68335. /**
  68336. * Copy the current matrix from the given one
  68337. * @param other defines the source matrix
  68338. * @returns the current updated matrix
  68339. */
  68340. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68341. /**
  68342. * Populates the given array from the starting index with the current matrix values
  68343. * @param array defines the target array
  68344. * @param offset defines the offset in the target array where to start storing values
  68345. * @returns the current matrix
  68346. */
  68347. copyToArray(array: Float32Array, offset?: number): Matrix;
  68348. /**
  68349. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68350. * @param other defines the second operand
  68351. * @param result defines the matrix where to store the multiplication
  68352. * @returns the current matrix
  68353. */
  68354. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68355. /**
  68356. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68357. * @param other defines the second operand
  68358. * @param result defines the array where to store the multiplication
  68359. * @param offset defines the offset in the target array where to start storing values
  68360. * @returns the current matrix
  68361. */
  68362. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68363. /**
  68364. * Check equality between this matrix and a second one
  68365. * @param value defines the second matrix to compare
  68366. * @returns true is the current matrix and the given one values are strictly equal
  68367. */
  68368. equals(value: DeepImmutable<Matrix>): boolean;
  68369. /**
  68370. * Clone the current matrix
  68371. * @returns a new matrix from the current matrix
  68372. */
  68373. clone(): Matrix;
  68374. /**
  68375. * Returns the name of the current matrix class
  68376. * @returns the string "Matrix"
  68377. */
  68378. getClassName(): string;
  68379. /**
  68380. * Gets the hash code of the current matrix
  68381. * @returns the hash code
  68382. */
  68383. getHashCode(): number;
  68384. /**
  68385. * Decomposes the current Matrix into a translation, rotation and scaling components
  68386. * @param scale defines the scale vector3 given as a reference to update
  68387. * @param rotation defines the rotation quaternion given as a reference to update
  68388. * @param translation defines the translation vector3 given as a reference to update
  68389. * @returns true if operation was successful
  68390. */
  68391. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68392. /**
  68393. * Gets specific row of the matrix
  68394. * @param index defines the number of the row to get
  68395. * @returns the index-th row of the current matrix as a new Vector4
  68396. */
  68397. getRow(index: number): Nullable<Vector4>;
  68398. /**
  68399. * Sets the index-th row of the current matrix to the vector4 values
  68400. * @param index defines the number of the row to set
  68401. * @param row defines the target vector4
  68402. * @returns the updated current matrix
  68403. */
  68404. setRow(index: number, row: Vector4): Matrix;
  68405. /**
  68406. * Compute the transpose of the matrix
  68407. * @returns the new transposed matrix
  68408. */
  68409. transpose(): Matrix;
  68410. /**
  68411. * Compute the transpose of the matrix and store it in a given matrix
  68412. * @param result defines the target matrix
  68413. * @returns the current matrix
  68414. */
  68415. transposeToRef(result: Matrix): Matrix;
  68416. /**
  68417. * Sets the index-th row of the current matrix with the given 4 x float values
  68418. * @param index defines the row index
  68419. * @param x defines the x component to set
  68420. * @param y defines the y component to set
  68421. * @param z defines the z component to set
  68422. * @param w defines the w component to set
  68423. * @returns the updated current matrix
  68424. */
  68425. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68426. /**
  68427. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68428. * @param scale defines the scale factor
  68429. * @returns a new matrix
  68430. */
  68431. scale(scale: number): Matrix;
  68432. /**
  68433. * Scale the current matrix values by a factor to a given result matrix
  68434. * @param scale defines the scale factor
  68435. * @param result defines the matrix to store the result
  68436. * @returns the current matrix
  68437. */
  68438. scaleToRef(scale: number, result: Matrix): Matrix;
  68439. /**
  68440. * Scale the current matrix values by a factor and add the result to a given matrix
  68441. * @param scale defines the scale factor
  68442. * @param result defines the Matrix to store the result
  68443. * @returns the current matrix
  68444. */
  68445. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68446. /**
  68447. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68448. * @param ref matrix to store the result
  68449. */
  68450. toNormalMatrix(ref: Matrix): void;
  68451. /**
  68452. * Gets only rotation part of the current matrix
  68453. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68454. */
  68455. getRotationMatrix(): Matrix;
  68456. /**
  68457. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68458. * @param result defines the target matrix to store data to
  68459. * @returns the current matrix
  68460. */
  68461. getRotationMatrixToRef(result: Matrix): Matrix;
  68462. /**
  68463. * Toggles model matrix from being right handed to left handed in place and vice versa
  68464. */
  68465. toggleModelMatrixHandInPlace(): void;
  68466. /**
  68467. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68468. */
  68469. toggleProjectionMatrixHandInPlace(): void;
  68470. /**
  68471. * Creates a matrix from an array
  68472. * @param array defines the source array
  68473. * @param offset defines an offset in the source array
  68474. * @returns a new Matrix set from the starting index of the given array
  68475. */
  68476. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68477. /**
  68478. * Copy the content of an array into a given matrix
  68479. * @param array defines the source array
  68480. * @param offset defines an offset in the source array
  68481. * @param result defines the target matrix
  68482. */
  68483. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68484. /**
  68485. * Stores an array into a matrix after having multiplied each component by a given factor
  68486. * @param array defines the source array
  68487. * @param offset defines the offset in the source array
  68488. * @param scale defines the scaling factor
  68489. * @param result defines the target matrix
  68490. */
  68491. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68492. /**
  68493. * Gets an identity matrix that must not be updated
  68494. */
  68495. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68496. /**
  68497. * Stores a list of values (16) inside a given matrix
  68498. * @param initialM11 defines 1st value of 1st row
  68499. * @param initialM12 defines 2nd value of 1st row
  68500. * @param initialM13 defines 3rd value of 1st row
  68501. * @param initialM14 defines 4th value of 1st row
  68502. * @param initialM21 defines 1st value of 2nd row
  68503. * @param initialM22 defines 2nd value of 2nd row
  68504. * @param initialM23 defines 3rd value of 2nd row
  68505. * @param initialM24 defines 4th value of 2nd row
  68506. * @param initialM31 defines 1st value of 3rd row
  68507. * @param initialM32 defines 2nd value of 3rd row
  68508. * @param initialM33 defines 3rd value of 3rd row
  68509. * @param initialM34 defines 4th value of 3rd row
  68510. * @param initialM41 defines 1st value of 4th row
  68511. * @param initialM42 defines 2nd value of 4th row
  68512. * @param initialM43 defines 3rd value of 4th row
  68513. * @param initialM44 defines 4th value of 4th row
  68514. * @param result defines the target matrix
  68515. */
  68516. 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;
  68517. /**
  68518. * Creates new matrix from a list of values (16)
  68519. * @param initialM11 defines 1st value of 1st row
  68520. * @param initialM12 defines 2nd value of 1st row
  68521. * @param initialM13 defines 3rd value of 1st row
  68522. * @param initialM14 defines 4th value of 1st row
  68523. * @param initialM21 defines 1st value of 2nd row
  68524. * @param initialM22 defines 2nd value of 2nd row
  68525. * @param initialM23 defines 3rd value of 2nd row
  68526. * @param initialM24 defines 4th value of 2nd row
  68527. * @param initialM31 defines 1st value of 3rd row
  68528. * @param initialM32 defines 2nd value of 3rd row
  68529. * @param initialM33 defines 3rd value of 3rd row
  68530. * @param initialM34 defines 4th value of 3rd row
  68531. * @param initialM41 defines 1st value of 4th row
  68532. * @param initialM42 defines 2nd value of 4th row
  68533. * @param initialM43 defines 3rd value of 4th row
  68534. * @param initialM44 defines 4th value of 4th row
  68535. * @returns the new matrix
  68536. */
  68537. 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;
  68538. /**
  68539. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68540. * @param scale defines the scale vector3
  68541. * @param rotation defines the rotation quaternion
  68542. * @param translation defines the translation vector3
  68543. * @returns a new matrix
  68544. */
  68545. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68546. /**
  68547. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68548. * @param scale defines the scale vector3
  68549. * @param rotation defines the rotation quaternion
  68550. * @param translation defines the translation vector3
  68551. * @param result defines the target matrix
  68552. */
  68553. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68554. /**
  68555. * Creates a new identity matrix
  68556. * @returns a new identity matrix
  68557. */
  68558. static Identity(): Matrix;
  68559. /**
  68560. * Creates a new identity matrix and stores the result in a given matrix
  68561. * @param result defines the target matrix
  68562. */
  68563. static IdentityToRef(result: Matrix): void;
  68564. /**
  68565. * Creates a new zero matrix
  68566. * @returns a new zero matrix
  68567. */
  68568. static Zero(): Matrix;
  68569. /**
  68570. * Creates a new rotation matrix for "angle" radians around the X axis
  68571. * @param angle defines the angle (in radians) to use
  68572. * @return the new matrix
  68573. */
  68574. static RotationX(angle: number): Matrix;
  68575. /**
  68576. * Creates a new matrix as the invert of a given matrix
  68577. * @param source defines the source matrix
  68578. * @returns the new matrix
  68579. */
  68580. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68581. /**
  68582. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68583. * @param angle defines the angle (in radians) to use
  68584. * @param result defines the target matrix
  68585. */
  68586. static RotationXToRef(angle: number, result: Matrix): void;
  68587. /**
  68588. * Creates a new rotation matrix for "angle" radians around the Y axis
  68589. * @param angle defines the angle (in radians) to use
  68590. * @return the new matrix
  68591. */
  68592. static RotationY(angle: number): Matrix;
  68593. /**
  68594. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68595. * @param angle defines the angle (in radians) to use
  68596. * @param result defines the target matrix
  68597. */
  68598. static RotationYToRef(angle: number, result: Matrix): void;
  68599. /**
  68600. * Creates a new rotation matrix for "angle" radians around the Z axis
  68601. * @param angle defines the angle (in radians) to use
  68602. * @return the new matrix
  68603. */
  68604. static RotationZ(angle: number): Matrix;
  68605. /**
  68606. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68607. * @param angle defines the angle (in radians) to use
  68608. * @param result defines the target matrix
  68609. */
  68610. static RotationZToRef(angle: number, result: Matrix): void;
  68611. /**
  68612. * Creates a new rotation matrix for "angle" radians around the given axis
  68613. * @param axis defines the axis to use
  68614. * @param angle defines the angle (in radians) to use
  68615. * @return the new matrix
  68616. */
  68617. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68618. /**
  68619. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68620. * @param axis defines the axis to use
  68621. * @param angle defines the angle (in radians) to use
  68622. * @param result defines the target matrix
  68623. */
  68624. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68625. /**
  68626. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68627. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68628. * @param from defines the vector to align
  68629. * @param to defines the vector to align to
  68630. * @param result defines the target matrix
  68631. */
  68632. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68633. /**
  68634. * Creates a rotation matrix
  68635. * @param yaw defines the yaw angle in radians (Y axis)
  68636. * @param pitch defines the pitch angle in radians (X axis)
  68637. * @param roll defines the roll angle in radians (X axis)
  68638. * @returns the new rotation matrix
  68639. */
  68640. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68641. /**
  68642. * Creates a rotation matrix and stores it in a given matrix
  68643. * @param yaw defines the yaw angle in radians (Y axis)
  68644. * @param pitch defines the pitch angle in radians (X axis)
  68645. * @param roll defines the roll angle in radians (X axis)
  68646. * @param result defines the target matrix
  68647. */
  68648. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68649. /**
  68650. * Creates a scaling matrix
  68651. * @param x defines the scale factor on X axis
  68652. * @param y defines the scale factor on Y axis
  68653. * @param z defines the scale factor on Z axis
  68654. * @returns the new matrix
  68655. */
  68656. static Scaling(x: number, y: number, z: number): Matrix;
  68657. /**
  68658. * Creates a scaling matrix and stores it in a given matrix
  68659. * @param x defines the scale factor on X axis
  68660. * @param y defines the scale factor on Y axis
  68661. * @param z defines the scale factor on Z axis
  68662. * @param result defines the target matrix
  68663. */
  68664. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68665. /**
  68666. * Creates a translation matrix
  68667. * @param x defines the translation on X axis
  68668. * @param y defines the translation on Y axis
  68669. * @param z defines the translationon Z axis
  68670. * @returns the new matrix
  68671. */
  68672. static Translation(x: number, y: number, z: number): Matrix;
  68673. /**
  68674. * Creates a translation matrix and stores it in a given matrix
  68675. * @param x defines the translation on X axis
  68676. * @param y defines the translation on Y axis
  68677. * @param z defines the translationon Z axis
  68678. * @param result defines the target matrix
  68679. */
  68680. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68681. /**
  68682. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68683. * @param startValue defines the start value
  68684. * @param endValue defines the end value
  68685. * @param gradient defines the gradient factor
  68686. * @returns the new matrix
  68687. */
  68688. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68689. /**
  68690. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68691. * @param startValue defines the start value
  68692. * @param endValue defines the end value
  68693. * @param gradient defines the gradient factor
  68694. * @param result defines the Matrix object where to store data
  68695. */
  68696. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68697. /**
  68698. * Builds a new matrix whose values are computed by:
  68699. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68700. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68701. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68702. * @param startValue defines the first matrix
  68703. * @param endValue defines the second matrix
  68704. * @param gradient defines the gradient between the two matrices
  68705. * @returns the new matrix
  68706. */
  68707. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68708. /**
  68709. * Update a matrix to values which are computed by:
  68710. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68711. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68712. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68713. * @param startValue defines the first matrix
  68714. * @param endValue defines the second matrix
  68715. * @param gradient defines the gradient between the two matrices
  68716. * @param result defines the target matrix
  68717. */
  68718. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68719. /**
  68720. * 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"
  68721. * This function works in left handed mode
  68722. * @param eye defines the final position of the entity
  68723. * @param target defines where the entity should look at
  68724. * @param up defines the up vector for the entity
  68725. * @returns the new matrix
  68726. */
  68727. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68728. /**
  68729. * 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".
  68730. * This function works in left handed mode
  68731. * @param eye defines the final position of the entity
  68732. * @param target defines where the entity should look at
  68733. * @param up defines the up vector for the entity
  68734. * @param result defines the target matrix
  68735. */
  68736. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68737. /**
  68738. * 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"
  68739. * This function works in right handed mode
  68740. * @param eye defines the final position of the entity
  68741. * @param target defines where the entity should look at
  68742. * @param up defines the up vector for the entity
  68743. * @returns the new matrix
  68744. */
  68745. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68746. /**
  68747. * 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".
  68748. * This function works in right handed mode
  68749. * @param eye defines the final position of the entity
  68750. * @param target defines where the entity should look at
  68751. * @param up defines the up vector for the entity
  68752. * @param result defines the target matrix
  68753. */
  68754. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68755. /**
  68756. * Create a left-handed orthographic projection matrix
  68757. * @param width defines the viewport width
  68758. * @param height defines the viewport height
  68759. * @param znear defines the near clip plane
  68760. * @param zfar defines the far clip plane
  68761. * @returns a new matrix as a left-handed orthographic projection matrix
  68762. */
  68763. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68764. /**
  68765. * Store a left-handed orthographic projection to a given matrix
  68766. * @param width defines the viewport width
  68767. * @param height defines the viewport height
  68768. * @param znear defines the near clip plane
  68769. * @param zfar defines the far clip plane
  68770. * @param result defines the target matrix
  68771. */
  68772. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68773. /**
  68774. * Create a left-handed orthographic projection matrix
  68775. * @param left defines the viewport left coordinate
  68776. * @param right defines the viewport right coordinate
  68777. * @param bottom defines the viewport bottom coordinate
  68778. * @param top defines the viewport top coordinate
  68779. * @param znear defines the near clip plane
  68780. * @param zfar defines the far clip plane
  68781. * @returns a new matrix as a left-handed orthographic projection matrix
  68782. */
  68783. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68784. /**
  68785. * Stores a left-handed orthographic projection into a given matrix
  68786. * @param left defines the viewport left coordinate
  68787. * @param right defines the viewport right coordinate
  68788. * @param bottom defines the viewport bottom coordinate
  68789. * @param top defines the viewport top coordinate
  68790. * @param znear defines the near clip plane
  68791. * @param zfar defines the far clip plane
  68792. * @param result defines the target matrix
  68793. */
  68794. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68795. /**
  68796. * Creates a right-handed orthographic projection matrix
  68797. * @param left defines the viewport left coordinate
  68798. * @param right defines the viewport right coordinate
  68799. * @param bottom defines the viewport bottom coordinate
  68800. * @param top defines the viewport top coordinate
  68801. * @param znear defines the near clip plane
  68802. * @param zfar defines the far clip plane
  68803. * @returns a new matrix as a right-handed orthographic projection matrix
  68804. */
  68805. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68806. /**
  68807. * Stores a right-handed orthographic projection into a given matrix
  68808. * @param left defines the viewport left coordinate
  68809. * @param right defines the viewport right coordinate
  68810. * @param bottom defines the viewport bottom coordinate
  68811. * @param top defines the viewport top coordinate
  68812. * @param znear defines the near clip plane
  68813. * @param zfar defines the far clip plane
  68814. * @param result defines the target matrix
  68815. */
  68816. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68817. /**
  68818. * Creates a left-handed perspective projection matrix
  68819. * @param width defines the viewport width
  68820. * @param height defines the viewport height
  68821. * @param znear defines the near clip plane
  68822. * @param zfar defines the far clip plane
  68823. * @returns a new matrix as a left-handed perspective projection matrix
  68824. */
  68825. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68826. /**
  68827. * Creates a left-handed perspective projection matrix
  68828. * @param fov defines the horizontal field of view
  68829. * @param aspect defines the aspect ratio
  68830. * @param znear defines the near clip plane
  68831. * @param zfar defines the far clip plane
  68832. * @returns a new matrix as a left-handed perspective projection matrix
  68833. */
  68834. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68835. /**
  68836. * Stores a left-handed perspective projection into a given matrix
  68837. * @param fov defines the horizontal field of view
  68838. * @param aspect defines the aspect ratio
  68839. * @param znear defines the near clip plane
  68840. * @param zfar defines the far clip plane
  68841. * @param result defines the target matrix
  68842. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68843. */
  68844. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68845. /**
  68846. * Creates a right-handed perspective projection matrix
  68847. * @param fov defines the horizontal field of view
  68848. * @param aspect defines the aspect ratio
  68849. * @param znear defines the near clip plane
  68850. * @param zfar defines the far clip plane
  68851. * @returns a new matrix as a right-handed perspective projection matrix
  68852. */
  68853. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68854. /**
  68855. * Stores a right-handed perspective projection into a given matrix
  68856. * @param fov defines the horizontal field of view
  68857. * @param aspect defines the aspect ratio
  68858. * @param znear defines the near clip plane
  68859. * @param zfar defines the far clip plane
  68860. * @param result defines the target matrix
  68861. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68862. */
  68863. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68864. /**
  68865. * Stores a perspective projection for WebVR info a given matrix
  68866. * @param fov defines the field of view
  68867. * @param znear defines the near clip plane
  68868. * @param zfar defines the far clip plane
  68869. * @param result defines the target matrix
  68870. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68871. */
  68872. static PerspectiveFovWebVRToRef(fov: {
  68873. upDegrees: number;
  68874. downDegrees: number;
  68875. leftDegrees: number;
  68876. rightDegrees: number;
  68877. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68878. /**
  68879. * Computes a complete transformation matrix
  68880. * @param viewport defines the viewport to use
  68881. * @param world defines the world matrix
  68882. * @param view defines the view matrix
  68883. * @param projection defines the projection matrix
  68884. * @param zmin defines the near clip plane
  68885. * @param zmax defines the far clip plane
  68886. * @returns the transformation matrix
  68887. */
  68888. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68889. /**
  68890. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68891. * @param matrix defines the matrix to use
  68892. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68893. */
  68894. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68895. /**
  68896. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68897. * @param matrix defines the matrix to use
  68898. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68899. */
  68900. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68901. /**
  68902. * Compute the transpose of a given matrix
  68903. * @param matrix defines the matrix to transpose
  68904. * @returns the new matrix
  68905. */
  68906. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68907. /**
  68908. * Compute the transpose of a matrix and store it in a target matrix
  68909. * @param matrix defines the matrix to transpose
  68910. * @param result defines the target matrix
  68911. */
  68912. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68913. /**
  68914. * Computes a reflection matrix from a plane
  68915. * @param plane defines the reflection plane
  68916. * @returns a new matrix
  68917. */
  68918. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68919. /**
  68920. * Computes a reflection matrix from a plane
  68921. * @param plane defines the reflection plane
  68922. * @param result defines the target matrix
  68923. */
  68924. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68925. /**
  68926. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68927. * @param xaxis defines the value of the 1st axis
  68928. * @param yaxis defines the value of the 2nd axis
  68929. * @param zaxis defines the value of the 3rd axis
  68930. * @param result defines the target matrix
  68931. */
  68932. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68933. /**
  68934. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68935. * @param quat defines the quaternion to use
  68936. * @param result defines the target matrix
  68937. */
  68938. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68939. }
  68940. /**
  68941. * @hidden
  68942. */
  68943. export class TmpVectors {
  68944. static Vector2: Vector2[];
  68945. static Vector3: Vector3[];
  68946. static Vector4: Vector4[];
  68947. static Quaternion: Quaternion[];
  68948. static Matrix: Matrix[];
  68949. }
  68950. }
  68951. declare module BABYLON {
  68952. /** Defines the cross module used constants to avoid circular dependncies */
  68953. export class Constants {
  68954. /** Defines that alpha blending is disabled */
  68955. static readonly ALPHA_DISABLE: number;
  68956. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68957. static readonly ALPHA_ADD: number;
  68958. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68959. static readonly ALPHA_COMBINE: number;
  68960. /** Defines that alpha blending to DEST - SRC * DEST */
  68961. static readonly ALPHA_SUBTRACT: number;
  68962. /** Defines that alpha blending to SRC * DEST */
  68963. static readonly ALPHA_MULTIPLY: number;
  68964. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68965. static readonly ALPHA_MAXIMIZED: number;
  68966. /** Defines that alpha blending to SRC + DEST */
  68967. static readonly ALPHA_ONEONE: number;
  68968. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68969. static readonly ALPHA_PREMULTIPLIED: number;
  68970. /**
  68971. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68972. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68973. */
  68974. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68975. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68976. static readonly ALPHA_INTERPOLATE: number;
  68977. /**
  68978. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68979. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68980. */
  68981. static readonly ALPHA_SCREENMODE: number;
  68982. /** Defines that the ressource is not delayed*/
  68983. static readonly DELAYLOADSTATE_NONE: number;
  68984. /** Defines that the ressource was successfully delay loaded */
  68985. static readonly DELAYLOADSTATE_LOADED: number;
  68986. /** Defines that the ressource is currently delay loading */
  68987. static readonly DELAYLOADSTATE_LOADING: number;
  68988. /** Defines that the ressource is delayed and has not started loading */
  68989. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68990. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68991. static readonly NEVER: number;
  68992. /** 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 */
  68993. static readonly ALWAYS: number;
  68994. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68995. static readonly LESS: number;
  68996. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68997. static readonly EQUAL: number;
  68998. /** 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 */
  68999. static readonly LEQUAL: number;
  69000. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69001. static readonly GREATER: number;
  69002. /** 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 */
  69003. static readonly GEQUAL: number;
  69004. /** 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 */
  69005. static readonly NOTEQUAL: number;
  69006. /** Passed to stencilOperation to specify that stencil value must be kept */
  69007. static readonly KEEP: number;
  69008. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69009. static readonly REPLACE: number;
  69010. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69011. static readonly INCR: number;
  69012. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69013. static readonly DECR: number;
  69014. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69015. static readonly INVERT: number;
  69016. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69017. static readonly INCR_WRAP: number;
  69018. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69019. static readonly DECR_WRAP: number;
  69020. /** Texture is not repeating outside of 0..1 UVs */
  69021. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69022. /** Texture is repeating outside of 0..1 UVs */
  69023. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69024. /** Texture is repeating and mirrored */
  69025. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69026. /** ALPHA */
  69027. static readonly TEXTUREFORMAT_ALPHA: number;
  69028. /** LUMINANCE */
  69029. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69030. /** LUMINANCE_ALPHA */
  69031. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69032. /** RGB */
  69033. static readonly TEXTUREFORMAT_RGB: number;
  69034. /** RGBA */
  69035. static readonly TEXTUREFORMAT_RGBA: number;
  69036. /** RED */
  69037. static readonly TEXTUREFORMAT_RED: number;
  69038. /** RED (2nd reference) */
  69039. static readonly TEXTUREFORMAT_R: number;
  69040. /** RG */
  69041. static readonly TEXTUREFORMAT_RG: number;
  69042. /** RED_INTEGER */
  69043. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69044. /** RED_INTEGER (2nd reference) */
  69045. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69046. /** RG_INTEGER */
  69047. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69048. /** RGB_INTEGER */
  69049. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69050. /** RGBA_INTEGER */
  69051. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69052. /** UNSIGNED_BYTE */
  69053. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69054. /** UNSIGNED_BYTE (2nd reference) */
  69055. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69056. /** FLOAT */
  69057. static readonly TEXTURETYPE_FLOAT: number;
  69058. /** HALF_FLOAT */
  69059. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69060. /** BYTE */
  69061. static readonly TEXTURETYPE_BYTE: number;
  69062. /** SHORT */
  69063. static readonly TEXTURETYPE_SHORT: number;
  69064. /** UNSIGNED_SHORT */
  69065. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69066. /** INT */
  69067. static readonly TEXTURETYPE_INT: number;
  69068. /** UNSIGNED_INT */
  69069. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69070. /** UNSIGNED_SHORT_4_4_4_4 */
  69071. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69072. /** UNSIGNED_SHORT_5_5_5_1 */
  69073. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69074. /** UNSIGNED_SHORT_5_6_5 */
  69075. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69076. /** UNSIGNED_INT_2_10_10_10_REV */
  69077. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69078. /** UNSIGNED_INT_24_8 */
  69079. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69080. /** UNSIGNED_INT_10F_11F_11F_REV */
  69081. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69082. /** UNSIGNED_INT_5_9_9_9_REV */
  69083. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69084. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69085. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69086. /** nearest is mag = nearest and min = nearest and mip = linear */
  69087. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69088. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69089. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69090. /** Trilinear is mag = linear and min = linear and mip = linear */
  69091. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69092. /** nearest is mag = nearest and min = nearest and mip = linear */
  69093. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69094. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69095. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69096. /** Trilinear is mag = linear and min = linear and mip = linear */
  69097. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69098. /** mag = nearest and min = nearest and mip = nearest */
  69099. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69100. /** mag = nearest and min = linear and mip = nearest */
  69101. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69102. /** mag = nearest and min = linear and mip = linear */
  69103. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69104. /** mag = nearest and min = linear and mip = none */
  69105. static readonly TEXTURE_NEAREST_LINEAR: number;
  69106. /** mag = nearest and min = nearest and mip = none */
  69107. static readonly TEXTURE_NEAREST_NEAREST: number;
  69108. /** mag = linear and min = nearest and mip = nearest */
  69109. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69110. /** mag = linear and min = nearest and mip = linear */
  69111. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69112. /** mag = linear and min = linear and mip = none */
  69113. static readonly TEXTURE_LINEAR_LINEAR: number;
  69114. /** mag = linear and min = nearest and mip = none */
  69115. static readonly TEXTURE_LINEAR_NEAREST: number;
  69116. /** Explicit coordinates mode */
  69117. static readonly TEXTURE_EXPLICIT_MODE: number;
  69118. /** Spherical coordinates mode */
  69119. static readonly TEXTURE_SPHERICAL_MODE: number;
  69120. /** Planar coordinates mode */
  69121. static readonly TEXTURE_PLANAR_MODE: number;
  69122. /** Cubic coordinates mode */
  69123. static readonly TEXTURE_CUBIC_MODE: number;
  69124. /** Projection coordinates mode */
  69125. static readonly TEXTURE_PROJECTION_MODE: number;
  69126. /** Skybox coordinates mode */
  69127. static readonly TEXTURE_SKYBOX_MODE: number;
  69128. /** Inverse Cubic coordinates mode */
  69129. static readonly TEXTURE_INVCUBIC_MODE: number;
  69130. /** Equirectangular coordinates mode */
  69131. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69132. /** Equirectangular Fixed coordinates mode */
  69133. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69134. /** Equirectangular Fixed Mirrored coordinates mode */
  69135. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69136. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69137. static readonly SCALEMODE_FLOOR: number;
  69138. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69139. static readonly SCALEMODE_NEAREST: number;
  69140. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69141. static readonly SCALEMODE_CEILING: number;
  69142. /**
  69143. * The dirty texture flag value
  69144. */
  69145. static readonly MATERIAL_TextureDirtyFlag: number;
  69146. /**
  69147. * The dirty light flag value
  69148. */
  69149. static readonly MATERIAL_LightDirtyFlag: number;
  69150. /**
  69151. * The dirty fresnel flag value
  69152. */
  69153. static readonly MATERIAL_FresnelDirtyFlag: number;
  69154. /**
  69155. * The dirty attribute flag value
  69156. */
  69157. static readonly MATERIAL_AttributesDirtyFlag: number;
  69158. /**
  69159. * The dirty misc flag value
  69160. */
  69161. static readonly MATERIAL_MiscDirtyFlag: number;
  69162. /**
  69163. * The all dirty flag value
  69164. */
  69165. static readonly MATERIAL_AllDirtyFlag: number;
  69166. /**
  69167. * Returns the triangle fill mode
  69168. */
  69169. static readonly MATERIAL_TriangleFillMode: number;
  69170. /**
  69171. * Returns the wireframe mode
  69172. */
  69173. static readonly MATERIAL_WireFrameFillMode: number;
  69174. /**
  69175. * Returns the point fill mode
  69176. */
  69177. static readonly MATERIAL_PointFillMode: number;
  69178. /**
  69179. * Returns the point list draw mode
  69180. */
  69181. static readonly MATERIAL_PointListDrawMode: number;
  69182. /**
  69183. * Returns the line list draw mode
  69184. */
  69185. static readonly MATERIAL_LineListDrawMode: number;
  69186. /**
  69187. * Returns the line loop draw mode
  69188. */
  69189. static readonly MATERIAL_LineLoopDrawMode: number;
  69190. /**
  69191. * Returns the line strip draw mode
  69192. */
  69193. static readonly MATERIAL_LineStripDrawMode: number;
  69194. /**
  69195. * Returns the triangle strip draw mode
  69196. */
  69197. static readonly MATERIAL_TriangleStripDrawMode: number;
  69198. /**
  69199. * Returns the triangle fan draw mode
  69200. */
  69201. static readonly MATERIAL_TriangleFanDrawMode: number;
  69202. /**
  69203. * Stores the clock-wise side orientation
  69204. */
  69205. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69206. /**
  69207. * Stores the counter clock-wise side orientation
  69208. */
  69209. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69210. /**
  69211. * Nothing
  69212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69213. */
  69214. static readonly ACTION_NothingTrigger: number;
  69215. /**
  69216. * On pick
  69217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69218. */
  69219. static readonly ACTION_OnPickTrigger: number;
  69220. /**
  69221. * On left pick
  69222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69223. */
  69224. static readonly ACTION_OnLeftPickTrigger: number;
  69225. /**
  69226. * On right pick
  69227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69228. */
  69229. static readonly ACTION_OnRightPickTrigger: number;
  69230. /**
  69231. * On center pick
  69232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69233. */
  69234. static readonly ACTION_OnCenterPickTrigger: number;
  69235. /**
  69236. * On pick down
  69237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69238. */
  69239. static readonly ACTION_OnPickDownTrigger: number;
  69240. /**
  69241. * On double pick
  69242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69243. */
  69244. static readonly ACTION_OnDoublePickTrigger: number;
  69245. /**
  69246. * On pick up
  69247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69248. */
  69249. static readonly ACTION_OnPickUpTrigger: number;
  69250. /**
  69251. * On pick out.
  69252. * This trigger will only be raised if you also declared a OnPickDown
  69253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69254. */
  69255. static readonly ACTION_OnPickOutTrigger: number;
  69256. /**
  69257. * On long press
  69258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69259. */
  69260. static readonly ACTION_OnLongPressTrigger: number;
  69261. /**
  69262. * On pointer over
  69263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69264. */
  69265. static readonly ACTION_OnPointerOverTrigger: number;
  69266. /**
  69267. * On pointer out
  69268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69269. */
  69270. static readonly ACTION_OnPointerOutTrigger: number;
  69271. /**
  69272. * On every frame
  69273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69274. */
  69275. static readonly ACTION_OnEveryFrameTrigger: number;
  69276. /**
  69277. * On intersection enter
  69278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69279. */
  69280. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69281. /**
  69282. * On intersection exit
  69283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69284. */
  69285. static readonly ACTION_OnIntersectionExitTrigger: number;
  69286. /**
  69287. * On key down
  69288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69289. */
  69290. static readonly ACTION_OnKeyDownTrigger: number;
  69291. /**
  69292. * On key up
  69293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69294. */
  69295. static readonly ACTION_OnKeyUpTrigger: number;
  69296. /**
  69297. * Billboard mode will only apply to Y axis
  69298. */
  69299. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69300. /**
  69301. * Billboard mode will apply to all axes
  69302. */
  69303. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69304. /**
  69305. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69306. */
  69307. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69308. /**
  69309. * Gets or sets base Assets URL
  69310. */
  69311. static PARTICLES_BaseAssetsUrl: string;
  69312. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69313. * Test order :
  69314. * Is the bounding sphere outside the frustum ?
  69315. * If not, are the bounding box vertices outside the frustum ?
  69316. * It not, then the cullable object is in the frustum.
  69317. */
  69318. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69319. /** Culling strategy : Bounding Sphere Only.
  69320. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69321. * It's also less accurate than the standard because some not visible objects can still be selected.
  69322. * Test : is the bounding sphere outside the frustum ?
  69323. * If not, then the cullable object is in the frustum.
  69324. */
  69325. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69326. /** Culling strategy : Optimistic Inclusion.
  69327. * This in an inclusion test first, then the standard exclusion test.
  69328. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69329. * 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.
  69330. * Anyway, it's as accurate as the standard strategy.
  69331. * Test :
  69332. * Is the cullable object bounding sphere center in the frustum ?
  69333. * If not, apply the default culling strategy.
  69334. */
  69335. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69336. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69337. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69338. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69339. * 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.
  69340. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69341. * Test :
  69342. * Is the cullable object bounding sphere center in the frustum ?
  69343. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69344. */
  69345. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69346. /**
  69347. * No logging while loading
  69348. */
  69349. static readonly SCENELOADER_NO_LOGGING: number;
  69350. /**
  69351. * Minimal logging while loading
  69352. */
  69353. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69354. /**
  69355. * Summary logging while loading
  69356. */
  69357. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69358. /**
  69359. * Detailled logging while loading
  69360. */
  69361. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69362. }
  69363. }
  69364. declare module BABYLON {
  69365. /**
  69366. * Class used to store and describe the pipeline context associated with an effect
  69367. */
  69368. export interface IPipelineContext {
  69369. /**
  69370. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69371. */
  69372. isAsync: boolean;
  69373. /**
  69374. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69375. */
  69376. isReady: boolean;
  69377. /** @hidden */
  69378. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69379. }
  69380. }
  69381. declare module BABYLON {
  69382. /** @hidden */
  69383. export interface IShaderProcessor {
  69384. attributeProcessor?: (attribute: string) => string;
  69385. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69386. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69387. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69388. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69389. lineProcessor?: (line: string, isFragment: boolean) => string;
  69390. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69391. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69392. }
  69393. }
  69394. declare module BABYLON {
  69395. /** @hidden */
  69396. export interface ProcessingOptions {
  69397. defines: string[];
  69398. indexParameters: any;
  69399. isFragment: boolean;
  69400. shouldUseHighPrecisionShader: boolean;
  69401. supportsUniformBuffers: boolean;
  69402. shadersRepository: string;
  69403. includesShadersStore: {
  69404. [key: string]: string;
  69405. };
  69406. processor?: IShaderProcessor;
  69407. version: string;
  69408. platformName: string;
  69409. lookForClosingBracketForUniformBuffer?: boolean;
  69410. }
  69411. }
  69412. declare module BABYLON {
  69413. /**
  69414. * Helper to manipulate strings
  69415. */
  69416. export class StringTools {
  69417. /**
  69418. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69419. * @param str Source string
  69420. * @param suffix Suffix to search for in the source string
  69421. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69422. */
  69423. static EndsWith(str: string, suffix: string): boolean;
  69424. /**
  69425. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69426. * @param str Source string
  69427. * @param suffix Suffix to search for in the source string
  69428. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69429. */
  69430. static StartsWith(str: string, suffix: string): boolean;
  69431. }
  69432. }
  69433. declare module BABYLON {
  69434. /** @hidden */
  69435. export class ShaderCodeNode {
  69436. line: string;
  69437. children: ShaderCodeNode[];
  69438. additionalDefineKey?: string;
  69439. additionalDefineValue?: string;
  69440. isValid(preprocessors: {
  69441. [key: string]: string;
  69442. }): boolean;
  69443. process(preprocessors: {
  69444. [key: string]: string;
  69445. }, options: ProcessingOptions): string;
  69446. }
  69447. }
  69448. declare module BABYLON {
  69449. /** @hidden */
  69450. export class ShaderCodeCursor {
  69451. private _lines;
  69452. lineIndex: number;
  69453. readonly currentLine: string;
  69454. readonly canRead: boolean;
  69455. lines: string[];
  69456. }
  69457. }
  69458. declare module BABYLON {
  69459. /** @hidden */
  69460. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69461. process(preprocessors: {
  69462. [key: string]: string;
  69463. }, options: ProcessingOptions): string;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /** @hidden */
  69468. export class ShaderDefineExpression {
  69469. isTrue(preprocessors: {
  69470. [key: string]: string;
  69471. }): boolean;
  69472. }
  69473. }
  69474. declare module BABYLON {
  69475. /** @hidden */
  69476. export class ShaderCodeTestNode extends ShaderCodeNode {
  69477. testExpression: ShaderDefineExpression;
  69478. isValid(preprocessors: {
  69479. [key: string]: string;
  69480. }): boolean;
  69481. }
  69482. }
  69483. declare module BABYLON {
  69484. /** @hidden */
  69485. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69486. define: string;
  69487. not: boolean;
  69488. constructor(define: string, not?: boolean);
  69489. isTrue(preprocessors: {
  69490. [key: string]: string;
  69491. }): boolean;
  69492. }
  69493. }
  69494. declare module BABYLON {
  69495. /** @hidden */
  69496. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69497. leftOperand: ShaderDefineExpression;
  69498. rightOperand: ShaderDefineExpression;
  69499. isTrue(preprocessors: {
  69500. [key: string]: string;
  69501. }): boolean;
  69502. }
  69503. }
  69504. declare module BABYLON {
  69505. /** @hidden */
  69506. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69507. leftOperand: ShaderDefineExpression;
  69508. rightOperand: ShaderDefineExpression;
  69509. isTrue(preprocessors: {
  69510. [key: string]: string;
  69511. }): boolean;
  69512. }
  69513. }
  69514. declare module BABYLON {
  69515. /** @hidden */
  69516. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69517. define: string;
  69518. operand: string;
  69519. testValue: string;
  69520. constructor(define: string, operand: string, testValue: string);
  69521. isTrue(preprocessors: {
  69522. [key: string]: string;
  69523. }): boolean;
  69524. }
  69525. }
  69526. declare module BABYLON {
  69527. /**
  69528. * @ignore
  69529. * Application error to support additional information when loading a file
  69530. */
  69531. export class LoadFileError extends Error {
  69532. /** defines the optional web request */
  69533. request?: WebRequest | undefined;
  69534. private static _setPrototypeOf;
  69535. /**
  69536. * Creates a new LoadFileError
  69537. * @param message defines the message of the error
  69538. * @param request defines the optional web request
  69539. */
  69540. constructor(message: string,
  69541. /** defines the optional web request */
  69542. request?: WebRequest | undefined);
  69543. }
  69544. }
  69545. declare module BABYLON {
  69546. /**
  69547. * Class used to enable access to offline support
  69548. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69549. */
  69550. export interface IOfflineProvider {
  69551. /**
  69552. * Gets a boolean indicating if scene must be saved in the database
  69553. */
  69554. enableSceneOffline: boolean;
  69555. /**
  69556. * Gets a boolean indicating if textures must be saved in the database
  69557. */
  69558. enableTexturesOffline: boolean;
  69559. /**
  69560. * Open the offline support and make it available
  69561. * @param successCallback defines the callback to call on success
  69562. * @param errorCallback defines the callback to call on error
  69563. */
  69564. open(successCallback: () => void, errorCallback: () => void): void;
  69565. /**
  69566. * Loads an image from the offline support
  69567. * @param url defines the url to load from
  69568. * @param image defines the target DOM image
  69569. */
  69570. loadImage(url: string, image: HTMLImageElement): void;
  69571. /**
  69572. * Loads a file from offline support
  69573. * @param url defines the URL to load from
  69574. * @param sceneLoaded defines a callback to call on success
  69575. * @param progressCallBack defines a callback to call when progress changed
  69576. * @param errorCallback defines a callback to call on error
  69577. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69578. */
  69579. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69580. }
  69581. }
  69582. declare module BABYLON {
  69583. /**
  69584. * Class used to help managing file picking and drag'n'drop
  69585. * File Storage
  69586. */
  69587. export class FilesInputStore {
  69588. /**
  69589. * List of files ready to be loaded
  69590. */
  69591. static FilesToLoad: {
  69592. [key: string]: File;
  69593. };
  69594. }
  69595. }
  69596. declare module BABYLON {
  69597. /**
  69598. * Class used to define a retry strategy when error happens while loading assets
  69599. */
  69600. export class RetryStrategy {
  69601. /**
  69602. * Function used to defines an exponential back off strategy
  69603. * @param maxRetries defines the maximum number of retries (3 by default)
  69604. * @param baseInterval defines the interval between retries
  69605. * @returns the strategy function to use
  69606. */
  69607. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69608. }
  69609. }
  69610. declare module BABYLON {
  69611. /**
  69612. * @hidden
  69613. */
  69614. export class FileTools {
  69615. /**
  69616. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69617. */
  69618. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69619. /**
  69620. * Gets or sets the base URL to use to load assets
  69621. */
  69622. static BaseUrl: string;
  69623. /**
  69624. * Default behaviour for cors in the application.
  69625. * It can be a string if the expected behavior is identical in the entire app.
  69626. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69627. */
  69628. static CorsBehavior: string | ((url: string | string[]) => string);
  69629. /**
  69630. * Gets or sets a function used to pre-process url before using them to load assets
  69631. */
  69632. static PreprocessUrl: (url: string) => string;
  69633. /**
  69634. * Removes unwanted characters from an url
  69635. * @param url defines the url to clean
  69636. * @returns the cleaned url
  69637. */
  69638. private static _CleanUrl;
  69639. /**
  69640. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69641. * @param url define the url we are trying
  69642. * @param element define the dom element where to configure the cors policy
  69643. */
  69644. static SetCorsBehavior(url: string | string[], element: {
  69645. crossOrigin: string | null;
  69646. }): void;
  69647. /**
  69648. * Loads an image as an HTMLImageElement.
  69649. * @param input url string, ArrayBuffer, or Blob to load
  69650. * @param onLoad callback called when the image successfully loads
  69651. * @param onError callback called when the image fails to load
  69652. * @param offlineProvider offline provider for caching
  69653. * @returns the HTMLImageElement of the loaded image
  69654. */
  69655. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69656. /**
  69657. * Loads a file
  69658. * @param fileToLoad defines the file to load
  69659. * @param callback defines the callback to call when data is loaded
  69660. * @param progressCallBack defines the callback to call during loading process
  69661. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69662. * @returns a file request object
  69663. */
  69664. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69665. /**
  69666. * Loads a file
  69667. * @param url url string, ArrayBuffer, or Blob to load
  69668. * @param onSuccess callback called when the file successfully loads
  69669. * @param onProgress callback called while file is loading (if the server supports this mode)
  69670. * @param offlineProvider defines the offline provider for caching
  69671. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69672. * @param onError callback called when the file fails to load
  69673. * @returns a file request object
  69674. */
  69675. 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;
  69676. /**
  69677. * Checks if the loaded document was accessed via `file:`-Protocol.
  69678. * @returns boolean
  69679. */
  69680. static IsFileURL(): boolean;
  69681. }
  69682. }
  69683. declare module BABYLON {
  69684. /** @hidden */
  69685. export class ShaderProcessor {
  69686. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69687. private static _ProcessPrecision;
  69688. private static _ExtractOperation;
  69689. private static _BuildSubExpression;
  69690. private static _BuildExpression;
  69691. private static _MoveCursorWithinIf;
  69692. private static _MoveCursor;
  69693. private static _EvaluatePreProcessors;
  69694. private static _PreparePreProcessors;
  69695. private static _ProcessShaderConversion;
  69696. private static _ProcessIncludes;
  69697. }
  69698. }
  69699. declare module BABYLON {
  69700. /**
  69701. * Class used to hold a RBG color
  69702. */
  69703. export class Color3 {
  69704. /**
  69705. * Defines the red component (between 0 and 1, default is 0)
  69706. */
  69707. r: number;
  69708. /**
  69709. * Defines the green component (between 0 and 1, default is 0)
  69710. */
  69711. g: number;
  69712. /**
  69713. * Defines the blue component (between 0 and 1, default is 0)
  69714. */
  69715. b: number;
  69716. /**
  69717. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69718. * @param r defines the red component (between 0 and 1, default is 0)
  69719. * @param g defines the green component (between 0 and 1, default is 0)
  69720. * @param b defines the blue component (between 0 and 1, default is 0)
  69721. */
  69722. constructor(
  69723. /**
  69724. * Defines the red component (between 0 and 1, default is 0)
  69725. */
  69726. r?: number,
  69727. /**
  69728. * Defines the green component (between 0 and 1, default is 0)
  69729. */
  69730. g?: number,
  69731. /**
  69732. * Defines the blue component (between 0 and 1, default is 0)
  69733. */
  69734. b?: number);
  69735. /**
  69736. * Creates a string with the Color3 current values
  69737. * @returns the string representation of the Color3 object
  69738. */
  69739. toString(): string;
  69740. /**
  69741. * Returns the string "Color3"
  69742. * @returns "Color3"
  69743. */
  69744. getClassName(): string;
  69745. /**
  69746. * Compute the Color3 hash code
  69747. * @returns an unique number that can be used to hash Color3 objects
  69748. */
  69749. getHashCode(): number;
  69750. /**
  69751. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69752. * @param array defines the array where to store the r,g,b components
  69753. * @param index defines an optional index in the target array to define where to start storing values
  69754. * @returns the current Color3 object
  69755. */
  69756. toArray(array: FloatArray, index?: number): Color3;
  69757. /**
  69758. * Returns a new Color4 object from the current Color3 and the given alpha
  69759. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69760. * @returns a new Color4 object
  69761. */
  69762. toColor4(alpha?: number): Color4;
  69763. /**
  69764. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69765. * @returns the new array
  69766. */
  69767. asArray(): number[];
  69768. /**
  69769. * Returns the luminance value
  69770. * @returns a float value
  69771. */
  69772. toLuminance(): number;
  69773. /**
  69774. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69775. * @param otherColor defines the second operand
  69776. * @returns the new Color3 object
  69777. */
  69778. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69779. /**
  69780. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69781. * @param otherColor defines the second operand
  69782. * @param result defines the Color3 object where to store the result
  69783. * @returns the current Color3
  69784. */
  69785. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69786. /**
  69787. * Determines equality between Color3 objects
  69788. * @param otherColor defines the second operand
  69789. * @returns true if the rgb values are equal to the given ones
  69790. */
  69791. equals(otherColor: DeepImmutable<Color3>): boolean;
  69792. /**
  69793. * Determines equality between the current Color3 object and a set of r,b,g values
  69794. * @param r defines the red component to check
  69795. * @param g defines the green component to check
  69796. * @param b defines the blue component to check
  69797. * @returns true if the rgb values are equal to the given ones
  69798. */
  69799. equalsFloats(r: number, g: number, b: number): boolean;
  69800. /**
  69801. * Multiplies in place each rgb value by scale
  69802. * @param scale defines the scaling factor
  69803. * @returns the updated Color3
  69804. */
  69805. scale(scale: number): Color3;
  69806. /**
  69807. * Multiplies the rgb values by scale and stores the result into "result"
  69808. * @param scale defines the scaling factor
  69809. * @param result defines the Color3 object where to store the result
  69810. * @returns the unmodified current Color3
  69811. */
  69812. scaleToRef(scale: number, result: Color3): Color3;
  69813. /**
  69814. * Scale the current Color3 values by a factor and add the result to a given Color3
  69815. * @param scale defines the scale factor
  69816. * @param result defines color to store the result into
  69817. * @returns the unmodified current Color3
  69818. */
  69819. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69820. /**
  69821. * Clamps the rgb values by the min and max values and stores the result into "result"
  69822. * @param min defines minimum clamping value (default is 0)
  69823. * @param max defines maximum clamping value (default is 1)
  69824. * @param result defines color to store the result into
  69825. * @returns the original Color3
  69826. */
  69827. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69828. /**
  69829. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69830. * @param otherColor defines the second operand
  69831. * @returns the new Color3
  69832. */
  69833. add(otherColor: DeepImmutable<Color3>): Color3;
  69834. /**
  69835. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69836. * @param otherColor defines the second operand
  69837. * @param result defines Color3 object to store the result into
  69838. * @returns the unmodified current Color3
  69839. */
  69840. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69841. /**
  69842. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69843. * @param otherColor defines the second operand
  69844. * @returns the new Color3
  69845. */
  69846. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69847. /**
  69848. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69849. * @param otherColor defines the second operand
  69850. * @param result defines Color3 object to store the result into
  69851. * @returns the unmodified current Color3
  69852. */
  69853. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69854. /**
  69855. * Copy the current object
  69856. * @returns a new Color3 copied the current one
  69857. */
  69858. clone(): Color3;
  69859. /**
  69860. * Copies the rgb values from the source in the current Color3
  69861. * @param source defines the source Color3 object
  69862. * @returns the updated Color3 object
  69863. */
  69864. copyFrom(source: DeepImmutable<Color3>): Color3;
  69865. /**
  69866. * Updates the Color3 rgb values from the given floats
  69867. * @param r defines the red component to read from
  69868. * @param g defines the green component to read from
  69869. * @param b defines the blue component to read from
  69870. * @returns the current Color3 object
  69871. */
  69872. copyFromFloats(r: number, g: number, b: number): Color3;
  69873. /**
  69874. * Updates the Color3 rgb values from the given floats
  69875. * @param r defines the red component to read from
  69876. * @param g defines the green component to read from
  69877. * @param b defines the blue component to read from
  69878. * @returns the current Color3 object
  69879. */
  69880. set(r: number, g: number, b: number): Color3;
  69881. /**
  69882. * Compute the Color3 hexadecimal code as a string
  69883. * @returns a string containing the hexadecimal representation of the Color3 object
  69884. */
  69885. toHexString(): string;
  69886. /**
  69887. * Computes a new Color3 converted from the current one to linear space
  69888. * @returns a new Color3 object
  69889. */
  69890. toLinearSpace(): Color3;
  69891. /**
  69892. * Converts current color in rgb space to HSV values
  69893. * @returns a new color3 representing the HSV values
  69894. */
  69895. toHSV(): Color3;
  69896. /**
  69897. * Converts current color in rgb space to HSV values
  69898. * @param result defines the Color3 where to store the HSV values
  69899. */
  69900. toHSVToRef(result: Color3): void;
  69901. /**
  69902. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69903. * @param convertedColor defines the Color3 object where to store the linear space version
  69904. * @returns the unmodified Color3
  69905. */
  69906. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69907. /**
  69908. * Computes a new Color3 converted from the current one to gamma space
  69909. * @returns a new Color3 object
  69910. */
  69911. toGammaSpace(): Color3;
  69912. /**
  69913. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69914. * @param convertedColor defines the Color3 object where to store the gamma space version
  69915. * @returns the unmodified Color3
  69916. */
  69917. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69918. private static _BlackReadOnly;
  69919. /**
  69920. * Convert Hue, saturation and value to a Color3 (RGB)
  69921. * @param hue defines the hue
  69922. * @param saturation defines the saturation
  69923. * @param value defines the value
  69924. * @param result defines the Color3 where to store the RGB values
  69925. */
  69926. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69927. /**
  69928. * Creates a new Color3 from the string containing valid hexadecimal values
  69929. * @param hex defines a string containing valid hexadecimal values
  69930. * @returns a new Color3 object
  69931. */
  69932. static FromHexString(hex: string): Color3;
  69933. /**
  69934. * Creates a new Color3 from the starting index of the given array
  69935. * @param array defines the source array
  69936. * @param offset defines an offset in the source array
  69937. * @returns a new Color3 object
  69938. */
  69939. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69940. /**
  69941. * Creates a new Color3 from integer values (< 256)
  69942. * @param r defines the red component to read from (value between 0 and 255)
  69943. * @param g defines the green component to read from (value between 0 and 255)
  69944. * @param b defines the blue component to read from (value between 0 and 255)
  69945. * @returns a new Color3 object
  69946. */
  69947. static FromInts(r: number, g: number, b: number): Color3;
  69948. /**
  69949. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69950. * @param start defines the start Color3 value
  69951. * @param end defines the end Color3 value
  69952. * @param amount defines the gradient value between start and end
  69953. * @returns a new Color3 object
  69954. */
  69955. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69956. /**
  69957. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69958. * @param left defines the start value
  69959. * @param right defines the end value
  69960. * @param amount defines the gradient factor
  69961. * @param result defines the Color3 object where to store the result
  69962. */
  69963. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69964. /**
  69965. * Returns a Color3 value containing a red color
  69966. * @returns a new Color3 object
  69967. */
  69968. static Red(): Color3;
  69969. /**
  69970. * Returns a Color3 value containing a green color
  69971. * @returns a new Color3 object
  69972. */
  69973. static Green(): Color3;
  69974. /**
  69975. * Returns a Color3 value containing a blue color
  69976. * @returns a new Color3 object
  69977. */
  69978. static Blue(): Color3;
  69979. /**
  69980. * Returns a Color3 value containing a black color
  69981. * @returns a new Color3 object
  69982. */
  69983. static Black(): Color3;
  69984. /**
  69985. * Gets a Color3 value containing a black color that must not be updated
  69986. */
  69987. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69988. /**
  69989. * Returns a Color3 value containing a white color
  69990. * @returns a new Color3 object
  69991. */
  69992. static White(): Color3;
  69993. /**
  69994. * Returns a Color3 value containing a purple color
  69995. * @returns a new Color3 object
  69996. */
  69997. static Purple(): Color3;
  69998. /**
  69999. * Returns a Color3 value containing a magenta color
  70000. * @returns a new Color3 object
  70001. */
  70002. static Magenta(): Color3;
  70003. /**
  70004. * Returns a Color3 value containing a yellow color
  70005. * @returns a new Color3 object
  70006. */
  70007. static Yellow(): Color3;
  70008. /**
  70009. * Returns a Color3 value containing a gray color
  70010. * @returns a new Color3 object
  70011. */
  70012. static Gray(): Color3;
  70013. /**
  70014. * Returns a Color3 value containing a teal color
  70015. * @returns a new Color3 object
  70016. */
  70017. static Teal(): Color3;
  70018. /**
  70019. * Returns a Color3 value containing a random color
  70020. * @returns a new Color3 object
  70021. */
  70022. static Random(): Color3;
  70023. }
  70024. /**
  70025. * Class used to hold a RBGA color
  70026. */
  70027. export class Color4 {
  70028. /**
  70029. * Defines the red component (between 0 and 1, default is 0)
  70030. */
  70031. r: number;
  70032. /**
  70033. * Defines the green component (between 0 and 1, default is 0)
  70034. */
  70035. g: number;
  70036. /**
  70037. * Defines the blue component (between 0 and 1, default is 0)
  70038. */
  70039. b: number;
  70040. /**
  70041. * Defines the alpha component (between 0 and 1, default is 1)
  70042. */
  70043. a: number;
  70044. /**
  70045. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70046. * @param r defines the red component (between 0 and 1, default is 0)
  70047. * @param g defines the green component (between 0 and 1, default is 0)
  70048. * @param b defines the blue component (between 0 and 1, default is 0)
  70049. * @param a defines the alpha component (between 0 and 1, default is 1)
  70050. */
  70051. constructor(
  70052. /**
  70053. * Defines the red component (between 0 and 1, default is 0)
  70054. */
  70055. r?: number,
  70056. /**
  70057. * Defines the green component (between 0 and 1, default is 0)
  70058. */
  70059. g?: number,
  70060. /**
  70061. * Defines the blue component (between 0 and 1, default is 0)
  70062. */
  70063. b?: number,
  70064. /**
  70065. * Defines the alpha component (between 0 and 1, default is 1)
  70066. */
  70067. a?: number);
  70068. /**
  70069. * Adds in place the given Color4 values to the current Color4 object
  70070. * @param right defines the second operand
  70071. * @returns the current updated Color4 object
  70072. */
  70073. addInPlace(right: DeepImmutable<Color4>): Color4;
  70074. /**
  70075. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70076. * @returns the new array
  70077. */
  70078. asArray(): number[];
  70079. /**
  70080. * Stores from the starting index in the given array the Color4 successive values
  70081. * @param array defines the array where to store the r,g,b components
  70082. * @param index defines an optional index in the target array to define where to start storing values
  70083. * @returns the current Color4 object
  70084. */
  70085. toArray(array: number[], index?: number): Color4;
  70086. /**
  70087. * Determines equality between Color4 objects
  70088. * @param otherColor defines the second operand
  70089. * @returns true if the rgba values are equal to the given ones
  70090. */
  70091. equals(otherColor: DeepImmutable<Color4>): boolean;
  70092. /**
  70093. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70094. * @param right defines the second operand
  70095. * @returns a new Color4 object
  70096. */
  70097. add(right: DeepImmutable<Color4>): Color4;
  70098. /**
  70099. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70100. * @param right defines the second operand
  70101. * @returns a new Color4 object
  70102. */
  70103. subtract(right: DeepImmutable<Color4>): Color4;
  70104. /**
  70105. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70106. * @param right defines the second operand
  70107. * @param result defines the Color4 object where to store the result
  70108. * @returns the current Color4 object
  70109. */
  70110. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70111. /**
  70112. * Creates a new Color4 with the current Color4 values multiplied by scale
  70113. * @param scale defines the scaling factor to apply
  70114. * @returns a new Color4 object
  70115. */
  70116. scale(scale: number): Color4;
  70117. /**
  70118. * Multiplies the current Color4 values by scale and stores the result in "result"
  70119. * @param scale defines the scaling factor to apply
  70120. * @param result defines the Color4 object where to store the result
  70121. * @returns the current unmodified Color4
  70122. */
  70123. scaleToRef(scale: number, result: Color4): Color4;
  70124. /**
  70125. * Scale the current Color4 values by a factor and add the result to a given Color4
  70126. * @param scale defines the scale factor
  70127. * @param result defines the Color4 object where to store the result
  70128. * @returns the unmodified current Color4
  70129. */
  70130. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70131. /**
  70132. * Clamps the rgb values by the min and max values and stores the result into "result"
  70133. * @param min defines minimum clamping value (default is 0)
  70134. * @param max defines maximum clamping value (default is 1)
  70135. * @param result defines color to store the result into.
  70136. * @returns the cuurent Color4
  70137. */
  70138. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70139. /**
  70140. * Multipy an Color4 value by another and return a new Color4 object
  70141. * @param color defines the Color4 value to multiply by
  70142. * @returns a new Color4 object
  70143. */
  70144. multiply(color: Color4): Color4;
  70145. /**
  70146. * Multipy a Color4 value by another and push the result in a reference value
  70147. * @param color defines the Color4 value to multiply by
  70148. * @param result defines the Color4 to fill the result in
  70149. * @returns the result Color4
  70150. */
  70151. multiplyToRef(color: Color4, result: Color4): Color4;
  70152. /**
  70153. * Creates a string with the Color4 current values
  70154. * @returns the string representation of the Color4 object
  70155. */
  70156. toString(): string;
  70157. /**
  70158. * Returns the string "Color4"
  70159. * @returns "Color4"
  70160. */
  70161. getClassName(): string;
  70162. /**
  70163. * Compute the Color4 hash code
  70164. * @returns an unique number that can be used to hash Color4 objects
  70165. */
  70166. getHashCode(): number;
  70167. /**
  70168. * Creates a new Color4 copied from the current one
  70169. * @returns a new Color4 object
  70170. */
  70171. clone(): Color4;
  70172. /**
  70173. * Copies the given Color4 values into the current one
  70174. * @param source defines the source Color4 object
  70175. * @returns the current updated Color4 object
  70176. */
  70177. copyFrom(source: Color4): Color4;
  70178. /**
  70179. * Copies the given float values into the current one
  70180. * @param r defines the red component to read from
  70181. * @param g defines the green component to read from
  70182. * @param b defines the blue component to read from
  70183. * @param a defines the alpha component to read from
  70184. * @returns the current updated Color4 object
  70185. */
  70186. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70187. /**
  70188. * Copies the given float values into the current one
  70189. * @param r defines the red component to read from
  70190. * @param g defines the green component to read from
  70191. * @param b defines the blue component to read from
  70192. * @param a defines the alpha component to read from
  70193. * @returns the current updated Color4 object
  70194. */
  70195. set(r: number, g: number, b: number, a: number): Color4;
  70196. /**
  70197. * Compute the Color4 hexadecimal code as a string
  70198. * @returns a string containing the hexadecimal representation of the Color4 object
  70199. */
  70200. toHexString(): string;
  70201. /**
  70202. * Computes a new Color4 converted from the current one to linear space
  70203. * @returns a new Color4 object
  70204. */
  70205. toLinearSpace(): Color4;
  70206. /**
  70207. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70208. * @param convertedColor defines the Color4 object where to store the linear space version
  70209. * @returns the unmodified Color4
  70210. */
  70211. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70212. /**
  70213. * Computes a new Color4 converted from the current one to gamma space
  70214. * @returns a new Color4 object
  70215. */
  70216. toGammaSpace(): Color4;
  70217. /**
  70218. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70219. * @param convertedColor defines the Color4 object where to store the gamma space version
  70220. * @returns the unmodified Color4
  70221. */
  70222. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70223. /**
  70224. * Creates a new Color4 from the string containing valid hexadecimal values
  70225. * @param hex defines a string containing valid hexadecimal values
  70226. * @returns a new Color4 object
  70227. */
  70228. static FromHexString(hex: string): Color4;
  70229. /**
  70230. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70231. * @param left defines the start value
  70232. * @param right defines the end value
  70233. * @param amount defines the gradient factor
  70234. * @returns a new Color4 object
  70235. */
  70236. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70237. /**
  70238. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70239. * @param left defines the start value
  70240. * @param right defines the end value
  70241. * @param amount defines the gradient factor
  70242. * @param result defines the Color4 object where to store data
  70243. */
  70244. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70245. /**
  70246. * Creates a new Color4 from a Color3 and an alpha value
  70247. * @param color3 defines the source Color3 to read from
  70248. * @param alpha defines the alpha component (1.0 by default)
  70249. * @returns a new Color4 object
  70250. */
  70251. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70252. /**
  70253. * Creates a new Color4 from the starting index element of the given array
  70254. * @param array defines the source array to read from
  70255. * @param offset defines the offset in the source array
  70256. * @returns a new Color4 object
  70257. */
  70258. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70259. /**
  70260. * Creates a new Color3 from integer values (< 256)
  70261. * @param r defines the red component to read from (value between 0 and 255)
  70262. * @param g defines the green component to read from (value between 0 and 255)
  70263. * @param b defines the blue component to read from (value between 0 and 255)
  70264. * @param a defines the alpha component to read from (value between 0 and 255)
  70265. * @returns a new Color3 object
  70266. */
  70267. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70268. /**
  70269. * Check the content of a given array and convert it to an array containing RGBA data
  70270. * If the original array was already containing count * 4 values then it is returned directly
  70271. * @param colors defines the array to check
  70272. * @param count defines the number of RGBA data to expect
  70273. * @returns an array containing count * 4 values (RGBA)
  70274. */
  70275. static CheckColors4(colors: number[], count: number): number[];
  70276. }
  70277. /**
  70278. * @hidden
  70279. */
  70280. export class TmpColors {
  70281. static Color3: Color3[];
  70282. static Color4: Color4[];
  70283. }
  70284. }
  70285. declare module BABYLON {
  70286. /**
  70287. * Class representing spherical harmonics coefficients to the 3rd degree
  70288. */
  70289. export class SphericalHarmonics {
  70290. /**
  70291. * Defines whether or not the harmonics have been prescaled for rendering.
  70292. */
  70293. preScaled: boolean;
  70294. /**
  70295. * The l0,0 coefficients of the spherical harmonics
  70296. */
  70297. l00: Vector3;
  70298. /**
  70299. * The l1,-1 coefficients of the spherical harmonics
  70300. */
  70301. l1_1: Vector3;
  70302. /**
  70303. * The l1,0 coefficients of the spherical harmonics
  70304. */
  70305. l10: Vector3;
  70306. /**
  70307. * The l1,1 coefficients of the spherical harmonics
  70308. */
  70309. l11: Vector3;
  70310. /**
  70311. * The l2,-2 coefficients of the spherical harmonics
  70312. */
  70313. l2_2: Vector3;
  70314. /**
  70315. * The l2,-1 coefficients of the spherical harmonics
  70316. */
  70317. l2_1: Vector3;
  70318. /**
  70319. * The l2,0 coefficients of the spherical harmonics
  70320. */
  70321. l20: Vector3;
  70322. /**
  70323. * The l2,1 coefficients of the spherical harmonics
  70324. */
  70325. l21: Vector3;
  70326. /**
  70327. * The l2,2 coefficients of the spherical harmonics
  70328. */
  70329. l22: Vector3;
  70330. /**
  70331. * Adds a light to the spherical harmonics
  70332. * @param direction the direction of the light
  70333. * @param color the color of the light
  70334. * @param deltaSolidAngle the delta solid angle of the light
  70335. */
  70336. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70337. /**
  70338. * Scales the spherical harmonics by the given amount
  70339. * @param scale the amount to scale
  70340. */
  70341. scaleInPlace(scale: number): void;
  70342. /**
  70343. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70344. *
  70345. * ```
  70346. * E_lm = A_l * L_lm
  70347. * ```
  70348. *
  70349. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70350. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70351. * the scaling factors are given in equation 9.
  70352. */
  70353. convertIncidentRadianceToIrradiance(): void;
  70354. /**
  70355. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70356. *
  70357. * ```
  70358. * L = (1/pi) * E * rho
  70359. * ```
  70360. *
  70361. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70362. */
  70363. convertIrradianceToLambertianRadiance(): void;
  70364. /**
  70365. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70366. * required operations at run time.
  70367. *
  70368. * This is simply done by scaling back the SH with Ylm constants parameter.
  70369. * The trigonometric part being applied by the shader at run time.
  70370. */
  70371. preScaleForRendering(): void;
  70372. /**
  70373. * Constructs a spherical harmonics from an array.
  70374. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70375. * @returns the spherical harmonics
  70376. */
  70377. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70378. /**
  70379. * Gets the spherical harmonics from polynomial
  70380. * @param polynomial the spherical polynomial
  70381. * @returns the spherical harmonics
  70382. */
  70383. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70384. }
  70385. /**
  70386. * Class representing spherical polynomial coefficients to the 3rd degree
  70387. */
  70388. export class SphericalPolynomial {
  70389. private _harmonics;
  70390. /**
  70391. * The spherical harmonics used to create the polynomials.
  70392. */
  70393. readonly preScaledHarmonics: SphericalHarmonics;
  70394. /**
  70395. * The x coefficients of the spherical polynomial
  70396. */
  70397. x: Vector3;
  70398. /**
  70399. * The y coefficients of the spherical polynomial
  70400. */
  70401. y: Vector3;
  70402. /**
  70403. * The z coefficients of the spherical polynomial
  70404. */
  70405. z: Vector3;
  70406. /**
  70407. * The xx coefficients of the spherical polynomial
  70408. */
  70409. xx: Vector3;
  70410. /**
  70411. * The yy coefficients of the spherical polynomial
  70412. */
  70413. yy: Vector3;
  70414. /**
  70415. * The zz coefficients of the spherical polynomial
  70416. */
  70417. zz: Vector3;
  70418. /**
  70419. * The xy coefficients of the spherical polynomial
  70420. */
  70421. xy: Vector3;
  70422. /**
  70423. * The yz coefficients of the spherical polynomial
  70424. */
  70425. yz: Vector3;
  70426. /**
  70427. * The zx coefficients of the spherical polynomial
  70428. */
  70429. zx: Vector3;
  70430. /**
  70431. * Adds an ambient color to the spherical polynomial
  70432. * @param color the color to add
  70433. */
  70434. addAmbient(color: Color3): void;
  70435. /**
  70436. * Scales the spherical polynomial by the given amount
  70437. * @param scale the amount to scale
  70438. */
  70439. scaleInPlace(scale: number): void;
  70440. /**
  70441. * Gets the spherical polynomial from harmonics
  70442. * @param harmonics the spherical harmonics
  70443. * @returns the spherical polynomial
  70444. */
  70445. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70446. /**
  70447. * Constructs a spherical polynomial from an array.
  70448. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70449. * @returns the spherical polynomial
  70450. */
  70451. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70452. }
  70453. }
  70454. declare module BABYLON {
  70455. /**
  70456. * Define options used to create a render target texture
  70457. */
  70458. export class RenderTargetCreationOptions {
  70459. /**
  70460. * Specifies is mipmaps must be generated
  70461. */
  70462. generateMipMaps?: boolean;
  70463. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70464. generateDepthBuffer?: boolean;
  70465. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70466. generateStencilBuffer?: boolean;
  70467. /** Defines texture type (int by default) */
  70468. type?: number;
  70469. /** Defines sampling mode (trilinear by default) */
  70470. samplingMode?: number;
  70471. /** Defines format (RGBA by default) */
  70472. format?: number;
  70473. }
  70474. }
  70475. declare module BABYLON {
  70476. /**
  70477. * @hidden
  70478. **/
  70479. export class _AlphaState {
  70480. private _isAlphaBlendDirty;
  70481. private _isBlendFunctionParametersDirty;
  70482. private _isBlendEquationParametersDirty;
  70483. private _isBlendConstantsDirty;
  70484. private _alphaBlend;
  70485. private _blendFunctionParameters;
  70486. private _blendEquationParameters;
  70487. private _blendConstants;
  70488. /**
  70489. * Initializes the state.
  70490. */
  70491. constructor();
  70492. readonly isDirty: boolean;
  70493. alphaBlend: boolean;
  70494. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70495. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70496. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70497. reset(): void;
  70498. apply(gl: WebGLRenderingContext): void;
  70499. }
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * @hidden
  70504. **/
  70505. export class _DepthCullingState {
  70506. private _isDepthTestDirty;
  70507. private _isDepthMaskDirty;
  70508. private _isDepthFuncDirty;
  70509. private _isCullFaceDirty;
  70510. private _isCullDirty;
  70511. private _isZOffsetDirty;
  70512. private _isFrontFaceDirty;
  70513. private _depthTest;
  70514. private _depthMask;
  70515. private _depthFunc;
  70516. private _cull;
  70517. private _cullFace;
  70518. private _zOffset;
  70519. private _frontFace;
  70520. /**
  70521. * Initializes the state.
  70522. */
  70523. constructor();
  70524. readonly isDirty: boolean;
  70525. zOffset: number;
  70526. cullFace: Nullable<number>;
  70527. cull: Nullable<boolean>;
  70528. depthFunc: Nullable<number>;
  70529. depthMask: boolean;
  70530. depthTest: boolean;
  70531. frontFace: Nullable<number>;
  70532. reset(): void;
  70533. apply(gl: WebGLRenderingContext): void;
  70534. }
  70535. }
  70536. declare module BABYLON {
  70537. /**
  70538. * @hidden
  70539. **/
  70540. export class _StencilState {
  70541. /** 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 */
  70542. static readonly ALWAYS: number;
  70543. /** Passed to stencilOperation to specify that stencil value must be kept */
  70544. static readonly KEEP: number;
  70545. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70546. static readonly REPLACE: number;
  70547. private _isStencilTestDirty;
  70548. private _isStencilMaskDirty;
  70549. private _isStencilFuncDirty;
  70550. private _isStencilOpDirty;
  70551. private _stencilTest;
  70552. private _stencilMask;
  70553. private _stencilFunc;
  70554. private _stencilFuncRef;
  70555. private _stencilFuncMask;
  70556. private _stencilOpStencilFail;
  70557. private _stencilOpDepthFail;
  70558. private _stencilOpStencilDepthPass;
  70559. readonly isDirty: boolean;
  70560. stencilFunc: number;
  70561. stencilFuncRef: number;
  70562. stencilFuncMask: number;
  70563. stencilOpStencilFail: number;
  70564. stencilOpDepthFail: number;
  70565. stencilOpStencilDepthPass: number;
  70566. stencilMask: number;
  70567. stencilTest: boolean;
  70568. constructor();
  70569. reset(): void;
  70570. apply(gl: WebGLRenderingContext): void;
  70571. }
  70572. }
  70573. declare module BABYLON {
  70574. /**
  70575. * @hidden
  70576. **/
  70577. export class _TimeToken {
  70578. _startTimeQuery: Nullable<WebGLQuery>;
  70579. _endTimeQuery: Nullable<WebGLQuery>;
  70580. _timeElapsedQuery: Nullable<WebGLQuery>;
  70581. _timeElapsedQueryEnded: boolean;
  70582. }
  70583. }
  70584. declare module BABYLON {
  70585. /**
  70586. * Class used to evalaute queries containing `and` and `or` operators
  70587. */
  70588. export class AndOrNotEvaluator {
  70589. /**
  70590. * Evaluate a query
  70591. * @param query defines the query to evaluate
  70592. * @param evaluateCallback defines the callback used to filter result
  70593. * @returns true if the query matches
  70594. */
  70595. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70596. private static _HandleParenthesisContent;
  70597. private static _SimplifyNegation;
  70598. }
  70599. }
  70600. declare module BABYLON {
  70601. /**
  70602. * Class used to store custom tags
  70603. */
  70604. export class Tags {
  70605. /**
  70606. * Adds support for tags on the given object
  70607. * @param obj defines the object to use
  70608. */
  70609. static EnableFor(obj: any): void;
  70610. /**
  70611. * Removes tags support
  70612. * @param obj defines the object to use
  70613. */
  70614. static DisableFor(obj: any): void;
  70615. /**
  70616. * Gets a boolean indicating if the given object has tags
  70617. * @param obj defines the object to use
  70618. * @returns a boolean
  70619. */
  70620. static HasTags(obj: any): boolean;
  70621. /**
  70622. * Gets the tags available on a given object
  70623. * @param obj defines the object to use
  70624. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70625. * @returns the tags
  70626. */
  70627. static GetTags(obj: any, asString?: boolean): any;
  70628. /**
  70629. * Adds tags to an object
  70630. * @param obj defines the object to use
  70631. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70632. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70633. */
  70634. static AddTagsTo(obj: any, tagsString: string): void;
  70635. /**
  70636. * @hidden
  70637. */
  70638. static _AddTagTo(obj: any, tag: string): void;
  70639. /**
  70640. * Removes specific tags from a specific object
  70641. * @param obj defines the object to use
  70642. * @param tagsString defines the tags to remove
  70643. */
  70644. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70645. /**
  70646. * @hidden
  70647. */
  70648. static _RemoveTagFrom(obj: any, tag: string): void;
  70649. /**
  70650. * Defines if tags hosted on an object match a given query
  70651. * @param obj defines the object to use
  70652. * @param tagsQuery defines the tag query
  70653. * @returns a boolean
  70654. */
  70655. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70656. }
  70657. }
  70658. declare module BABYLON {
  70659. /**
  70660. * Defines potential orientation for back face culling
  70661. */
  70662. export enum Orientation {
  70663. /**
  70664. * Clockwise
  70665. */
  70666. CW = 0,
  70667. /** Counter clockwise */
  70668. CCW = 1
  70669. }
  70670. /** Class used to represent a Bezier curve */
  70671. export class BezierCurve {
  70672. /**
  70673. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70674. * @param t defines the time
  70675. * @param x1 defines the left coordinate on X axis
  70676. * @param y1 defines the left coordinate on Y axis
  70677. * @param x2 defines the right coordinate on X axis
  70678. * @param y2 defines the right coordinate on Y axis
  70679. * @returns the interpolated value
  70680. */
  70681. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70682. }
  70683. /**
  70684. * Defines angle representation
  70685. */
  70686. export class Angle {
  70687. private _radians;
  70688. /**
  70689. * Creates an Angle object of "radians" radians (float).
  70690. * @param radians the angle in radians
  70691. */
  70692. constructor(radians: number);
  70693. /**
  70694. * Get value in degrees
  70695. * @returns the Angle value in degrees (float)
  70696. */
  70697. degrees(): number;
  70698. /**
  70699. * Get value in radians
  70700. * @returns the Angle value in radians (float)
  70701. */
  70702. radians(): number;
  70703. /**
  70704. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70705. * @param a defines first vector
  70706. * @param b defines second vector
  70707. * @returns a new Angle
  70708. */
  70709. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70710. /**
  70711. * Gets a new Angle object from the given float in radians
  70712. * @param radians defines the angle value in radians
  70713. * @returns a new Angle
  70714. */
  70715. static FromRadians(radians: number): Angle;
  70716. /**
  70717. * Gets a new Angle object from the given float in degrees
  70718. * @param degrees defines the angle value in degrees
  70719. * @returns a new Angle
  70720. */
  70721. static FromDegrees(degrees: number): Angle;
  70722. }
  70723. /**
  70724. * This represents an arc in a 2d space.
  70725. */
  70726. export class Arc2 {
  70727. /** Defines the start point of the arc */
  70728. startPoint: Vector2;
  70729. /** Defines the mid point of the arc */
  70730. midPoint: Vector2;
  70731. /** Defines the end point of the arc */
  70732. endPoint: Vector2;
  70733. /**
  70734. * Defines the center point of the arc.
  70735. */
  70736. centerPoint: Vector2;
  70737. /**
  70738. * Defines the radius of the arc.
  70739. */
  70740. radius: number;
  70741. /**
  70742. * Defines the angle of the arc (from mid point to end point).
  70743. */
  70744. angle: Angle;
  70745. /**
  70746. * Defines the start angle of the arc (from start point to middle point).
  70747. */
  70748. startAngle: Angle;
  70749. /**
  70750. * Defines the orientation of the arc (clock wise/counter clock wise).
  70751. */
  70752. orientation: Orientation;
  70753. /**
  70754. * Creates an Arc object from the three given points : start, middle and end.
  70755. * @param startPoint Defines the start point of the arc
  70756. * @param midPoint Defines the midlle point of the arc
  70757. * @param endPoint Defines the end point of the arc
  70758. */
  70759. constructor(
  70760. /** Defines the start point of the arc */
  70761. startPoint: Vector2,
  70762. /** Defines the mid point of the arc */
  70763. midPoint: Vector2,
  70764. /** Defines the end point of the arc */
  70765. endPoint: Vector2);
  70766. }
  70767. /**
  70768. * Represents a 2D path made up of multiple 2D points
  70769. */
  70770. export class Path2 {
  70771. private _points;
  70772. private _length;
  70773. /**
  70774. * If the path start and end point are the same
  70775. */
  70776. closed: boolean;
  70777. /**
  70778. * Creates a Path2 object from the starting 2D coordinates x and y.
  70779. * @param x the starting points x value
  70780. * @param y the starting points y value
  70781. */
  70782. constructor(x: number, y: number);
  70783. /**
  70784. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70785. * @param x the added points x value
  70786. * @param y the added points y value
  70787. * @returns the updated Path2.
  70788. */
  70789. addLineTo(x: number, y: number): Path2;
  70790. /**
  70791. * 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.
  70792. * @param midX middle point x value
  70793. * @param midY middle point y value
  70794. * @param endX end point x value
  70795. * @param endY end point y value
  70796. * @param numberOfSegments (default: 36)
  70797. * @returns the updated Path2.
  70798. */
  70799. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70800. /**
  70801. * Closes the Path2.
  70802. * @returns the Path2.
  70803. */
  70804. close(): Path2;
  70805. /**
  70806. * Gets the sum of the distance between each sequential point in the path
  70807. * @returns the Path2 total length (float).
  70808. */
  70809. length(): number;
  70810. /**
  70811. * Gets the points which construct the path
  70812. * @returns the Path2 internal array of points.
  70813. */
  70814. getPoints(): Vector2[];
  70815. /**
  70816. * Retreives the point at the distance aways from the starting point
  70817. * @param normalizedLengthPosition the length along the path to retreive the point from
  70818. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70819. */
  70820. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70821. /**
  70822. * Creates a new path starting from an x and y position
  70823. * @param x starting x value
  70824. * @param y starting y value
  70825. * @returns a new Path2 starting at the coordinates (x, y).
  70826. */
  70827. static StartingAt(x: number, y: number): Path2;
  70828. }
  70829. /**
  70830. * Represents a 3D path made up of multiple 3D points
  70831. */
  70832. export class Path3D {
  70833. /**
  70834. * an array of Vector3, the curve axis of the Path3D
  70835. */
  70836. path: Vector3[];
  70837. private _curve;
  70838. private _distances;
  70839. private _tangents;
  70840. private _normals;
  70841. private _binormals;
  70842. private _raw;
  70843. /**
  70844. * new Path3D(path, normal, raw)
  70845. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70846. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70847. * @param path an array of Vector3, the curve axis of the Path3D
  70848. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70849. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70850. */
  70851. constructor(
  70852. /**
  70853. * an array of Vector3, the curve axis of the Path3D
  70854. */
  70855. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70856. /**
  70857. * Returns the Path3D array of successive Vector3 designing its curve.
  70858. * @returns the Path3D array of successive Vector3 designing its curve.
  70859. */
  70860. getCurve(): Vector3[];
  70861. /**
  70862. * Returns an array populated with tangent vectors on each Path3D curve point.
  70863. * @returns an array populated with tangent vectors on each Path3D curve point.
  70864. */
  70865. getTangents(): Vector3[];
  70866. /**
  70867. * Returns an array populated with normal vectors on each Path3D curve point.
  70868. * @returns an array populated with normal vectors on each Path3D curve point.
  70869. */
  70870. getNormals(): Vector3[];
  70871. /**
  70872. * Returns an array populated with binormal vectors on each Path3D curve point.
  70873. * @returns an array populated with binormal vectors on each Path3D curve point.
  70874. */
  70875. getBinormals(): Vector3[];
  70876. /**
  70877. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70878. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70879. */
  70880. getDistances(): number[];
  70881. /**
  70882. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70883. * @param path path which all values are copied into the curves points
  70884. * @param firstNormal which should be projected onto the curve
  70885. * @returns the same object updated.
  70886. */
  70887. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70888. private _compute;
  70889. private _getFirstNonNullVector;
  70890. private _getLastNonNullVector;
  70891. private _normalVector;
  70892. }
  70893. /**
  70894. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70895. * A Curve3 is designed from a series of successive Vector3.
  70896. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70897. */
  70898. export class Curve3 {
  70899. private _points;
  70900. private _length;
  70901. /**
  70902. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70903. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70904. * @param v1 (Vector3) the control point
  70905. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70906. * @param nbPoints (integer) the wanted number of points in the curve
  70907. * @returns the created Curve3
  70908. */
  70909. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70910. /**
  70911. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70912. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70913. * @param v1 (Vector3) the first control point
  70914. * @param v2 (Vector3) the second control point
  70915. * @param v3 (Vector3) the end point of the Cubic Bezier
  70916. * @param nbPoints (integer) the wanted number of points in the curve
  70917. * @returns the created Curve3
  70918. */
  70919. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70920. /**
  70921. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70922. * @param p1 (Vector3) the origin point of the Hermite Spline
  70923. * @param t1 (Vector3) the tangent vector at the origin point
  70924. * @param p2 (Vector3) the end point of the Hermite Spline
  70925. * @param t2 (Vector3) the tangent vector at the end point
  70926. * @param nbPoints (integer) the wanted number of points in the curve
  70927. * @returns the created Curve3
  70928. */
  70929. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70930. /**
  70931. * Returns a Curve3 object along a CatmullRom Spline curve :
  70932. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70933. * @param nbPoints (integer) the wanted number of points between each curve control points
  70934. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70935. * @returns the created Curve3
  70936. */
  70937. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70938. /**
  70939. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70940. * A Curve3 is designed from a series of successive Vector3.
  70941. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70942. * @param points points which make up the curve
  70943. */
  70944. constructor(points: Vector3[]);
  70945. /**
  70946. * @returns the Curve3 stored array of successive Vector3
  70947. */
  70948. getPoints(): Vector3[];
  70949. /**
  70950. * @returns the computed length (float) of the curve.
  70951. */
  70952. length(): number;
  70953. /**
  70954. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70955. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70956. * curveA and curveB keep unchanged.
  70957. * @param curve the curve to continue from this curve
  70958. * @returns the newly constructed curve
  70959. */
  70960. continue(curve: DeepImmutable<Curve3>): Curve3;
  70961. private _computeLength;
  70962. }
  70963. }
  70964. declare module BABYLON {
  70965. /**
  70966. * This represents the main contract an easing function should follow.
  70967. * Easing functions are used throughout the animation system.
  70968. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70969. */
  70970. export interface IEasingFunction {
  70971. /**
  70972. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70973. * of the easing function.
  70974. * The link below provides some of the most common examples of easing functions.
  70975. * @see https://easings.net/
  70976. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70977. * @returns the corresponding value on the curve defined by the easing function
  70978. */
  70979. ease(gradient: number): number;
  70980. }
  70981. /**
  70982. * Base class used for every default easing function.
  70983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70984. */
  70985. export class EasingFunction implements IEasingFunction {
  70986. /**
  70987. * Interpolation follows the mathematical formula associated with the easing function.
  70988. */
  70989. static readonly EASINGMODE_EASEIN: number;
  70990. /**
  70991. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70992. */
  70993. static readonly EASINGMODE_EASEOUT: number;
  70994. /**
  70995. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70996. */
  70997. static readonly EASINGMODE_EASEINOUT: number;
  70998. private _easingMode;
  70999. /**
  71000. * Sets the easing mode of the current function.
  71001. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71002. */
  71003. setEasingMode(easingMode: number): void;
  71004. /**
  71005. * Gets the current easing mode.
  71006. * @returns the easing mode
  71007. */
  71008. getEasingMode(): number;
  71009. /**
  71010. * @hidden
  71011. */
  71012. easeInCore(gradient: number): number;
  71013. /**
  71014. * Given an input gradient between 0 and 1, this returns the corresponding value
  71015. * of the easing function.
  71016. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71017. * @returns the corresponding value on the curve defined by the easing function
  71018. */
  71019. ease(gradient: number): number;
  71020. }
  71021. /**
  71022. * Easing function with a circle shape (see link below).
  71023. * @see https://easings.net/#easeInCirc
  71024. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71025. */
  71026. export class CircleEase extends EasingFunction implements IEasingFunction {
  71027. /** @hidden */
  71028. easeInCore(gradient: number): number;
  71029. }
  71030. /**
  71031. * Easing function with a ease back shape (see link below).
  71032. * @see https://easings.net/#easeInBack
  71033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71034. */
  71035. export class BackEase extends EasingFunction implements IEasingFunction {
  71036. /** Defines the amplitude of the function */
  71037. amplitude: number;
  71038. /**
  71039. * Instantiates a back ease easing
  71040. * @see https://easings.net/#easeInBack
  71041. * @param amplitude Defines the amplitude of the function
  71042. */
  71043. constructor(
  71044. /** Defines the amplitude of the function */
  71045. amplitude?: number);
  71046. /** @hidden */
  71047. easeInCore(gradient: number): number;
  71048. }
  71049. /**
  71050. * Easing function with a bouncing shape (see link below).
  71051. * @see https://easings.net/#easeInBounce
  71052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71053. */
  71054. export class BounceEase extends EasingFunction implements IEasingFunction {
  71055. /** Defines the number of bounces */
  71056. bounces: number;
  71057. /** Defines the amplitude of the bounce */
  71058. bounciness: number;
  71059. /**
  71060. * Instantiates a bounce easing
  71061. * @see https://easings.net/#easeInBounce
  71062. * @param bounces Defines the number of bounces
  71063. * @param bounciness Defines the amplitude of the bounce
  71064. */
  71065. constructor(
  71066. /** Defines the number of bounces */
  71067. bounces?: number,
  71068. /** Defines the amplitude of the bounce */
  71069. bounciness?: number);
  71070. /** @hidden */
  71071. easeInCore(gradient: number): number;
  71072. }
  71073. /**
  71074. * Easing function with a power of 3 shape (see link below).
  71075. * @see https://easings.net/#easeInCubic
  71076. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71077. */
  71078. export class CubicEase extends EasingFunction implements IEasingFunction {
  71079. /** @hidden */
  71080. easeInCore(gradient: number): number;
  71081. }
  71082. /**
  71083. * Easing function with an elastic shape (see link below).
  71084. * @see https://easings.net/#easeInElastic
  71085. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71086. */
  71087. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71088. /** Defines the number of oscillations*/
  71089. oscillations: number;
  71090. /** Defines the amplitude of the oscillations*/
  71091. springiness: number;
  71092. /**
  71093. * Instantiates an elastic easing function
  71094. * @see https://easings.net/#easeInElastic
  71095. * @param oscillations Defines the number of oscillations
  71096. * @param springiness Defines the amplitude of the oscillations
  71097. */
  71098. constructor(
  71099. /** Defines the number of oscillations*/
  71100. oscillations?: number,
  71101. /** Defines the amplitude of the oscillations*/
  71102. springiness?: number);
  71103. /** @hidden */
  71104. easeInCore(gradient: number): number;
  71105. }
  71106. /**
  71107. * Easing function with an exponential shape (see link below).
  71108. * @see https://easings.net/#easeInExpo
  71109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71110. */
  71111. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71112. /** Defines the exponent of the function */
  71113. exponent: number;
  71114. /**
  71115. * Instantiates an exponential easing function
  71116. * @see https://easings.net/#easeInExpo
  71117. * @param exponent Defines the exponent of the function
  71118. */
  71119. constructor(
  71120. /** Defines the exponent of the function */
  71121. exponent?: number);
  71122. /** @hidden */
  71123. easeInCore(gradient: number): number;
  71124. }
  71125. /**
  71126. * Easing function with a power shape (see link below).
  71127. * @see https://easings.net/#easeInQuad
  71128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71129. */
  71130. export class PowerEase extends EasingFunction implements IEasingFunction {
  71131. /** Defines the power of the function */
  71132. power: number;
  71133. /**
  71134. * Instantiates an power base easing function
  71135. * @see https://easings.net/#easeInQuad
  71136. * @param power Defines the power of the function
  71137. */
  71138. constructor(
  71139. /** Defines the power of the function */
  71140. power?: number);
  71141. /** @hidden */
  71142. easeInCore(gradient: number): number;
  71143. }
  71144. /**
  71145. * Easing function with a power of 2 shape (see link below).
  71146. * @see https://easings.net/#easeInQuad
  71147. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71148. */
  71149. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71150. /** @hidden */
  71151. easeInCore(gradient: number): number;
  71152. }
  71153. /**
  71154. * Easing function with a power of 4 shape (see link below).
  71155. * @see https://easings.net/#easeInQuart
  71156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71157. */
  71158. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71159. /** @hidden */
  71160. easeInCore(gradient: number): number;
  71161. }
  71162. /**
  71163. * Easing function with a power of 5 shape (see link below).
  71164. * @see https://easings.net/#easeInQuint
  71165. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71166. */
  71167. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71168. /** @hidden */
  71169. easeInCore(gradient: number): number;
  71170. }
  71171. /**
  71172. * Easing function with a sin shape (see link below).
  71173. * @see https://easings.net/#easeInSine
  71174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71175. */
  71176. export class SineEase extends EasingFunction implements IEasingFunction {
  71177. /** @hidden */
  71178. easeInCore(gradient: number): number;
  71179. }
  71180. /**
  71181. * Easing function with a bezier shape (see link below).
  71182. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71184. */
  71185. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71186. /** Defines the x component of the start tangent in the bezier curve */
  71187. x1: number;
  71188. /** Defines the y component of the start tangent in the bezier curve */
  71189. y1: number;
  71190. /** Defines the x component of the end tangent in the bezier curve */
  71191. x2: number;
  71192. /** Defines the y component of the end tangent in the bezier curve */
  71193. y2: number;
  71194. /**
  71195. * Instantiates a bezier function
  71196. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71197. * @param x1 Defines the x component of the start tangent in the bezier curve
  71198. * @param y1 Defines the y component of the start tangent in the bezier curve
  71199. * @param x2 Defines the x component of the end tangent in the bezier curve
  71200. * @param y2 Defines the y component of the end tangent in the bezier curve
  71201. */
  71202. constructor(
  71203. /** Defines the x component of the start tangent in the bezier curve */
  71204. x1?: number,
  71205. /** Defines the y component of the start tangent in the bezier curve */
  71206. y1?: number,
  71207. /** Defines the x component of the end tangent in the bezier curve */
  71208. x2?: number,
  71209. /** Defines the y component of the end tangent in the bezier curve */
  71210. y2?: number);
  71211. /** @hidden */
  71212. easeInCore(gradient: number): number;
  71213. }
  71214. }
  71215. declare module BABYLON {
  71216. /**
  71217. * Defines an interface which represents an animation key frame
  71218. */
  71219. export interface IAnimationKey {
  71220. /**
  71221. * Frame of the key frame
  71222. */
  71223. frame: number;
  71224. /**
  71225. * Value at the specifies key frame
  71226. */
  71227. value: any;
  71228. /**
  71229. * The input tangent for the cubic hermite spline
  71230. */
  71231. inTangent?: any;
  71232. /**
  71233. * The output tangent for the cubic hermite spline
  71234. */
  71235. outTangent?: any;
  71236. /**
  71237. * The animation interpolation type
  71238. */
  71239. interpolation?: AnimationKeyInterpolation;
  71240. }
  71241. /**
  71242. * Enum for the animation key frame interpolation type
  71243. */
  71244. export enum AnimationKeyInterpolation {
  71245. /**
  71246. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71247. */
  71248. STEP = 1
  71249. }
  71250. }
  71251. declare module BABYLON {
  71252. /**
  71253. * Represents the range of an animation
  71254. */
  71255. export class AnimationRange {
  71256. /**The name of the animation range**/
  71257. name: string;
  71258. /**The starting frame of the animation */
  71259. from: number;
  71260. /**The ending frame of the animation*/
  71261. to: number;
  71262. /**
  71263. * Initializes the range of an animation
  71264. * @param name The name of the animation range
  71265. * @param from The starting frame of the animation
  71266. * @param to The ending frame of the animation
  71267. */
  71268. constructor(
  71269. /**The name of the animation range**/
  71270. name: string,
  71271. /**The starting frame of the animation */
  71272. from: number,
  71273. /**The ending frame of the animation*/
  71274. to: number);
  71275. /**
  71276. * Makes a copy of the animation range
  71277. * @returns A copy of the animation range
  71278. */
  71279. clone(): AnimationRange;
  71280. }
  71281. }
  71282. declare module BABYLON {
  71283. /**
  71284. * Composed of a frame, and an action function
  71285. */
  71286. export class AnimationEvent {
  71287. /** The frame for which the event is triggered **/
  71288. frame: number;
  71289. /** The event to perform when triggered **/
  71290. action: (currentFrame: number) => void;
  71291. /** Specifies if the event should be triggered only once**/
  71292. onlyOnce?: boolean | undefined;
  71293. /**
  71294. * Specifies if the animation event is done
  71295. */
  71296. isDone: boolean;
  71297. /**
  71298. * Initializes the animation event
  71299. * @param frame The frame for which the event is triggered
  71300. * @param action The event to perform when triggered
  71301. * @param onlyOnce Specifies if the event should be triggered only once
  71302. */
  71303. constructor(
  71304. /** The frame for which the event is triggered **/
  71305. frame: number,
  71306. /** The event to perform when triggered **/
  71307. action: (currentFrame: number) => void,
  71308. /** Specifies if the event should be triggered only once**/
  71309. onlyOnce?: boolean | undefined);
  71310. /** @hidden */
  71311. _clone(): AnimationEvent;
  71312. }
  71313. }
  71314. declare module BABYLON {
  71315. /**
  71316. * Interface used to define a behavior
  71317. */
  71318. export interface Behavior<T> {
  71319. /** gets or sets behavior's name */
  71320. name: string;
  71321. /**
  71322. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71323. */
  71324. init(): void;
  71325. /**
  71326. * Called when the behavior is attached to a target
  71327. * @param target defines the target where the behavior is attached to
  71328. */
  71329. attach(target: T): void;
  71330. /**
  71331. * Called when the behavior is detached from its target
  71332. */
  71333. detach(): void;
  71334. }
  71335. /**
  71336. * Interface implemented by classes supporting behaviors
  71337. */
  71338. export interface IBehaviorAware<T> {
  71339. /**
  71340. * Attach a behavior
  71341. * @param behavior defines the behavior to attach
  71342. * @returns the current host
  71343. */
  71344. addBehavior(behavior: Behavior<T>): T;
  71345. /**
  71346. * Remove a behavior from the current object
  71347. * @param behavior defines the behavior to detach
  71348. * @returns the current host
  71349. */
  71350. removeBehavior(behavior: Behavior<T>): T;
  71351. /**
  71352. * Gets a behavior using its name to search
  71353. * @param name defines the name to search
  71354. * @returns the behavior or null if not found
  71355. */
  71356. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71357. }
  71358. }
  71359. declare module BABYLON {
  71360. /**
  71361. * Defines an array and its length.
  71362. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71363. */
  71364. export interface ISmartArrayLike<T> {
  71365. /**
  71366. * The data of the array.
  71367. */
  71368. data: Array<T>;
  71369. /**
  71370. * The active length of the array.
  71371. */
  71372. length: number;
  71373. }
  71374. /**
  71375. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71376. */
  71377. export class SmartArray<T> implements ISmartArrayLike<T> {
  71378. /**
  71379. * The full set of data from the array.
  71380. */
  71381. data: Array<T>;
  71382. /**
  71383. * The active length of the array.
  71384. */
  71385. length: number;
  71386. protected _id: number;
  71387. /**
  71388. * Instantiates a Smart Array.
  71389. * @param capacity defines the default capacity of the array.
  71390. */
  71391. constructor(capacity: number);
  71392. /**
  71393. * Pushes a value at the end of the active data.
  71394. * @param value defines the object to push in the array.
  71395. */
  71396. push(value: T): void;
  71397. /**
  71398. * Iterates over the active data and apply the lambda to them.
  71399. * @param func defines the action to apply on each value.
  71400. */
  71401. forEach(func: (content: T) => void): void;
  71402. /**
  71403. * Sorts the full sets of data.
  71404. * @param compareFn defines the comparison function to apply.
  71405. */
  71406. sort(compareFn: (a: T, b: T) => number): void;
  71407. /**
  71408. * Resets the active data to an empty array.
  71409. */
  71410. reset(): void;
  71411. /**
  71412. * Releases all the data from the array as well as the array.
  71413. */
  71414. dispose(): void;
  71415. /**
  71416. * Concats the active data with a given array.
  71417. * @param array defines the data to concatenate with.
  71418. */
  71419. concat(array: any): void;
  71420. /**
  71421. * Returns the position of a value in the active data.
  71422. * @param value defines the value to find the index for
  71423. * @returns the index if found in the active data otherwise -1
  71424. */
  71425. indexOf(value: T): number;
  71426. /**
  71427. * Returns whether an element is part of the active data.
  71428. * @param value defines the value to look for
  71429. * @returns true if found in the active data otherwise false
  71430. */
  71431. contains(value: T): boolean;
  71432. private static _GlobalId;
  71433. }
  71434. /**
  71435. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71436. * The data in this array can only be present once
  71437. */
  71438. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71439. private _duplicateId;
  71440. /**
  71441. * Pushes a value at the end of the active data.
  71442. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71443. * @param value defines the object to push in the array.
  71444. */
  71445. push(value: T): void;
  71446. /**
  71447. * Pushes a value at the end of the active data.
  71448. * If the data is already present, it won t be added again
  71449. * @param value defines the object to push in the array.
  71450. * @returns true if added false if it was already present
  71451. */
  71452. pushNoDuplicate(value: T): boolean;
  71453. /**
  71454. * Resets the active data to an empty array.
  71455. */
  71456. reset(): void;
  71457. /**
  71458. * Concats the active data with a given array.
  71459. * This ensures no dupplicate will be present in the result.
  71460. * @param array defines the data to concatenate with.
  71461. */
  71462. concatWithNoDuplicate(array: any): void;
  71463. }
  71464. }
  71465. declare module BABYLON {
  71466. /**
  71467. * @ignore
  71468. * This is a list of all the different input types that are available in the application.
  71469. * Fo instance: ArcRotateCameraGamepadInput...
  71470. */
  71471. export var CameraInputTypes: {};
  71472. /**
  71473. * This is the contract to implement in order to create a new input class.
  71474. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71475. */
  71476. export interface ICameraInput<TCamera extends Camera> {
  71477. /**
  71478. * Defines the camera the input is attached to.
  71479. */
  71480. camera: Nullable<TCamera>;
  71481. /**
  71482. * Gets the class name of the current intput.
  71483. * @returns the class name
  71484. */
  71485. getClassName(): string;
  71486. /**
  71487. * Get the friendly name associated with the input class.
  71488. * @returns the input friendly name
  71489. */
  71490. getSimpleName(): string;
  71491. /**
  71492. * Attach the input controls to a specific dom element to get the input from.
  71493. * @param element Defines the element the controls should be listened from
  71494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71495. */
  71496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71497. /**
  71498. * Detach the current controls from the specified dom element.
  71499. * @param element Defines the element to stop listening the inputs from
  71500. */
  71501. detachControl(element: Nullable<HTMLElement>): void;
  71502. /**
  71503. * Update the current camera state depending on the inputs that have been used this frame.
  71504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71505. */
  71506. checkInputs?: () => void;
  71507. }
  71508. /**
  71509. * Represents a map of input types to input instance or input index to input instance.
  71510. */
  71511. export interface CameraInputsMap<TCamera extends Camera> {
  71512. /**
  71513. * Accessor to the input by input type.
  71514. */
  71515. [name: string]: ICameraInput<TCamera>;
  71516. /**
  71517. * Accessor to the input by input index.
  71518. */
  71519. [idx: number]: ICameraInput<TCamera>;
  71520. }
  71521. /**
  71522. * This represents the input manager used within a camera.
  71523. * It helps dealing with all the different kind of input attached to a camera.
  71524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71525. */
  71526. export class CameraInputsManager<TCamera extends Camera> {
  71527. /**
  71528. * Defines the list of inputs attahed to the camera.
  71529. */
  71530. attached: CameraInputsMap<TCamera>;
  71531. /**
  71532. * Defines the dom element the camera is collecting inputs from.
  71533. * This is null if the controls have not been attached.
  71534. */
  71535. attachedElement: Nullable<HTMLElement>;
  71536. /**
  71537. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71538. */
  71539. noPreventDefault: boolean;
  71540. /**
  71541. * Defined the camera the input manager belongs to.
  71542. */
  71543. camera: TCamera;
  71544. /**
  71545. * Update the current camera state depending on the inputs that have been used this frame.
  71546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71547. */
  71548. checkInputs: () => void;
  71549. /**
  71550. * Instantiate a new Camera Input Manager.
  71551. * @param camera Defines the camera the input manager blongs to
  71552. */
  71553. constructor(camera: TCamera);
  71554. /**
  71555. * Add an input method to a camera
  71556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71557. * @param input camera input method
  71558. */
  71559. add(input: ICameraInput<TCamera>): void;
  71560. /**
  71561. * Remove a specific input method from a camera
  71562. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71563. * @param inputToRemove camera input method
  71564. */
  71565. remove(inputToRemove: ICameraInput<TCamera>): void;
  71566. /**
  71567. * Remove a specific input type from a camera
  71568. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71569. * @param inputType the type of the input to remove
  71570. */
  71571. removeByType(inputType: string): void;
  71572. private _addCheckInputs;
  71573. /**
  71574. * Attach the input controls to the currently attached dom element to listen the events from.
  71575. * @param input Defines the input to attach
  71576. */
  71577. attachInput(input: ICameraInput<TCamera>): void;
  71578. /**
  71579. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71580. * @param element Defines the dom element to collect the events from
  71581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71582. */
  71583. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71584. /**
  71585. * Detach the current manager inputs controls from a specific dom element.
  71586. * @param element Defines the dom element to collect the events from
  71587. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71588. */
  71589. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71590. /**
  71591. * Rebuild the dynamic inputCheck function from the current list of
  71592. * defined inputs in the manager.
  71593. */
  71594. rebuildInputCheck(): void;
  71595. /**
  71596. * Remove all attached input methods from a camera
  71597. */
  71598. clear(): void;
  71599. /**
  71600. * Serialize the current input manager attached to a camera.
  71601. * This ensures than once parsed,
  71602. * the input associated to the camera will be identical to the current ones
  71603. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71604. */
  71605. serialize(serializedCamera: any): void;
  71606. /**
  71607. * Parses an input manager serialized JSON to restore the previous list of inputs
  71608. * and states associated to a camera.
  71609. * @param parsedCamera Defines the JSON to parse
  71610. */
  71611. parse(parsedCamera: any): void;
  71612. }
  71613. }
  71614. declare module BABYLON {
  71615. /**
  71616. * @hidden
  71617. */
  71618. export class IntersectionInfo {
  71619. bu: Nullable<number>;
  71620. bv: Nullable<number>;
  71621. distance: number;
  71622. faceId: number;
  71623. subMeshId: number;
  71624. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71625. }
  71626. }
  71627. declare module BABYLON {
  71628. /**
  71629. * Represens a plane by the equation ax + by + cz + d = 0
  71630. */
  71631. export class Plane {
  71632. private static _TmpMatrix;
  71633. /**
  71634. * Normal of the plane (a,b,c)
  71635. */
  71636. normal: Vector3;
  71637. /**
  71638. * d component of the plane
  71639. */
  71640. d: number;
  71641. /**
  71642. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71643. * @param a a component of the plane
  71644. * @param b b component of the plane
  71645. * @param c c component of the plane
  71646. * @param d d component of the plane
  71647. */
  71648. constructor(a: number, b: number, c: number, d: number);
  71649. /**
  71650. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71651. */
  71652. asArray(): number[];
  71653. /**
  71654. * @returns a new plane copied from the current Plane.
  71655. */
  71656. clone(): Plane;
  71657. /**
  71658. * @returns the string "Plane".
  71659. */
  71660. getClassName(): string;
  71661. /**
  71662. * @returns the Plane hash code.
  71663. */
  71664. getHashCode(): number;
  71665. /**
  71666. * Normalize the current Plane in place.
  71667. * @returns the updated Plane.
  71668. */
  71669. normalize(): Plane;
  71670. /**
  71671. * Applies a transformation the plane and returns the result
  71672. * @param transformation the transformation matrix to be applied to the plane
  71673. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71674. */
  71675. transform(transformation: DeepImmutable<Matrix>): Plane;
  71676. /**
  71677. * Calcualtte the dot product between the point and the plane normal
  71678. * @param point point to calculate the dot product with
  71679. * @returns the dot product (float) of the point coordinates and the plane normal.
  71680. */
  71681. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71682. /**
  71683. * Updates the current Plane from the plane defined by the three given points.
  71684. * @param point1 one of the points used to contruct the plane
  71685. * @param point2 one of the points used to contruct the plane
  71686. * @param point3 one of the points used to contruct the plane
  71687. * @returns the updated Plane.
  71688. */
  71689. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71690. /**
  71691. * Checks if the plane is facing a given direction
  71692. * @param direction the direction to check if the plane is facing
  71693. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71694. * @returns True is the vector "direction" is the same side than the plane normal.
  71695. */
  71696. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71697. /**
  71698. * Calculates the distance to a point
  71699. * @param point point to calculate distance to
  71700. * @returns the signed distance (float) from the given point to the Plane.
  71701. */
  71702. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71703. /**
  71704. * Creates a plane from an array
  71705. * @param array the array to create a plane from
  71706. * @returns a new Plane from the given array.
  71707. */
  71708. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71709. /**
  71710. * Creates a plane from three points
  71711. * @param point1 point used to create the plane
  71712. * @param point2 point used to create the plane
  71713. * @param point3 point used to create the plane
  71714. * @returns a new Plane defined by the three given points.
  71715. */
  71716. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71717. /**
  71718. * Creates a plane from an origin point and a normal
  71719. * @param origin origin of the plane to be constructed
  71720. * @param normal normal of the plane to be constructed
  71721. * @returns a new Plane the normal vector to this plane at the given origin point.
  71722. * Note : the vector "normal" is updated because normalized.
  71723. */
  71724. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71725. /**
  71726. * Calculates the distance from a plane and a point
  71727. * @param origin origin of the plane to be constructed
  71728. * @param normal normal of the plane to be constructed
  71729. * @param point point to calculate distance to
  71730. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71731. */
  71732. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71733. }
  71734. }
  71735. declare module BABYLON {
  71736. /**
  71737. * Class used to store bounding sphere information
  71738. */
  71739. export class BoundingSphere {
  71740. /**
  71741. * Gets the center of the bounding sphere in local space
  71742. */
  71743. readonly center: Vector3;
  71744. /**
  71745. * Radius of the bounding sphere in local space
  71746. */
  71747. radius: number;
  71748. /**
  71749. * Gets the center of the bounding sphere in world space
  71750. */
  71751. readonly centerWorld: Vector3;
  71752. /**
  71753. * Radius of the bounding sphere in world space
  71754. */
  71755. radiusWorld: number;
  71756. /**
  71757. * Gets the minimum vector in local space
  71758. */
  71759. readonly minimum: Vector3;
  71760. /**
  71761. * Gets the maximum vector in local space
  71762. */
  71763. readonly maximum: Vector3;
  71764. private _worldMatrix;
  71765. private static readonly TmpVector3;
  71766. /**
  71767. * Creates a new bounding sphere
  71768. * @param min defines the minimum vector (in local space)
  71769. * @param max defines the maximum vector (in local space)
  71770. * @param worldMatrix defines the new world matrix
  71771. */
  71772. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71773. /**
  71774. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71775. * @param min defines the new minimum vector (in local space)
  71776. * @param max defines the new maximum vector (in local space)
  71777. * @param worldMatrix defines the new world matrix
  71778. */
  71779. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71780. /**
  71781. * Scale the current bounding sphere by applying a scale factor
  71782. * @param factor defines the scale factor to apply
  71783. * @returns the current bounding box
  71784. */
  71785. scale(factor: number): BoundingSphere;
  71786. /**
  71787. * Gets the world matrix of the bounding box
  71788. * @returns a matrix
  71789. */
  71790. getWorldMatrix(): DeepImmutable<Matrix>;
  71791. /** @hidden */
  71792. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71793. /**
  71794. * Tests if the bounding sphere is intersecting the frustum planes
  71795. * @param frustumPlanes defines the frustum planes to test
  71796. * @returns true if there is an intersection
  71797. */
  71798. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71799. /**
  71800. * Tests if the bounding sphere center is in between the frustum planes.
  71801. * Used for optimistic fast inclusion.
  71802. * @param frustumPlanes defines the frustum planes to test
  71803. * @returns true if the sphere center is in between the frustum planes
  71804. */
  71805. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71806. /**
  71807. * Tests if a point is inside the bounding sphere
  71808. * @param point defines the point to test
  71809. * @returns true if the point is inside the bounding sphere
  71810. */
  71811. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71812. /**
  71813. * Checks if two sphere intersct
  71814. * @param sphere0 sphere 0
  71815. * @param sphere1 sphere 1
  71816. * @returns true if the speres intersect
  71817. */
  71818. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71819. }
  71820. }
  71821. declare module BABYLON {
  71822. /**
  71823. * Class used to store bounding box information
  71824. */
  71825. export class BoundingBox implements ICullable {
  71826. /**
  71827. * Gets the 8 vectors representing the bounding box in local space
  71828. */
  71829. readonly vectors: Vector3[];
  71830. /**
  71831. * Gets the center of the bounding box in local space
  71832. */
  71833. readonly center: Vector3;
  71834. /**
  71835. * Gets the center of the bounding box in world space
  71836. */
  71837. readonly centerWorld: Vector3;
  71838. /**
  71839. * Gets the extend size in local space
  71840. */
  71841. readonly extendSize: Vector3;
  71842. /**
  71843. * Gets the extend size in world space
  71844. */
  71845. readonly extendSizeWorld: Vector3;
  71846. /**
  71847. * Gets the OBB (object bounding box) directions
  71848. */
  71849. readonly directions: Vector3[];
  71850. /**
  71851. * Gets the 8 vectors representing the bounding box in world space
  71852. */
  71853. readonly vectorsWorld: Vector3[];
  71854. /**
  71855. * Gets the minimum vector in world space
  71856. */
  71857. readonly minimumWorld: Vector3;
  71858. /**
  71859. * Gets the maximum vector in world space
  71860. */
  71861. readonly maximumWorld: Vector3;
  71862. /**
  71863. * Gets the minimum vector in local space
  71864. */
  71865. readonly minimum: Vector3;
  71866. /**
  71867. * Gets the maximum vector in local space
  71868. */
  71869. readonly maximum: Vector3;
  71870. private _worldMatrix;
  71871. private static readonly TmpVector3;
  71872. /**
  71873. * @hidden
  71874. */
  71875. _tag: number;
  71876. /**
  71877. * Creates a new bounding box
  71878. * @param min defines the minimum vector (in local space)
  71879. * @param max defines the maximum vector (in local space)
  71880. * @param worldMatrix defines the new world matrix
  71881. */
  71882. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71883. /**
  71884. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71885. * @param min defines the new minimum vector (in local space)
  71886. * @param max defines the new maximum vector (in local space)
  71887. * @param worldMatrix defines the new world matrix
  71888. */
  71889. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71890. /**
  71891. * Scale the current bounding box by applying a scale factor
  71892. * @param factor defines the scale factor to apply
  71893. * @returns the current bounding box
  71894. */
  71895. scale(factor: number): BoundingBox;
  71896. /**
  71897. * Gets the world matrix of the bounding box
  71898. * @returns a matrix
  71899. */
  71900. getWorldMatrix(): DeepImmutable<Matrix>;
  71901. /** @hidden */
  71902. _update(world: DeepImmutable<Matrix>): void;
  71903. /**
  71904. * Tests if the bounding box is intersecting the frustum planes
  71905. * @param frustumPlanes defines the frustum planes to test
  71906. * @returns true if there is an intersection
  71907. */
  71908. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71909. /**
  71910. * Tests if the bounding box is entirely inside the frustum planes
  71911. * @param frustumPlanes defines the frustum planes to test
  71912. * @returns true if there is an inclusion
  71913. */
  71914. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71915. /**
  71916. * Tests if a point is inside the bounding box
  71917. * @param point defines the point to test
  71918. * @returns true if the point is inside the bounding box
  71919. */
  71920. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71921. /**
  71922. * Tests if the bounding box intersects with a bounding sphere
  71923. * @param sphere defines the sphere to test
  71924. * @returns true if there is an intersection
  71925. */
  71926. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71927. /**
  71928. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71929. * @param min defines the min vector to use
  71930. * @param max defines the max vector to use
  71931. * @returns true if there is an intersection
  71932. */
  71933. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71934. /**
  71935. * Tests if two bounding boxes are intersections
  71936. * @param box0 defines the first box to test
  71937. * @param box1 defines the second box to test
  71938. * @returns true if there is an intersection
  71939. */
  71940. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71941. /**
  71942. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71943. * @param minPoint defines the minimum vector of the bounding box
  71944. * @param maxPoint defines the maximum vector of the bounding box
  71945. * @param sphereCenter defines the sphere center
  71946. * @param sphereRadius defines the sphere radius
  71947. * @returns true if there is an intersection
  71948. */
  71949. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71950. /**
  71951. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71952. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71953. * @param frustumPlanes defines the frustum planes to test
  71954. * @return true if there is an inclusion
  71955. */
  71956. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71957. /**
  71958. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71959. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71960. * @param frustumPlanes defines the frustum planes to test
  71961. * @return true if there is an intersection
  71962. */
  71963. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71964. }
  71965. }
  71966. declare module BABYLON {
  71967. /** @hidden */
  71968. export class Collider {
  71969. /** Define if a collision was found */
  71970. collisionFound: boolean;
  71971. /**
  71972. * Define last intersection point in local space
  71973. */
  71974. intersectionPoint: Vector3;
  71975. /**
  71976. * Define last collided mesh
  71977. */
  71978. collidedMesh: Nullable<AbstractMesh>;
  71979. private _collisionPoint;
  71980. private _planeIntersectionPoint;
  71981. private _tempVector;
  71982. private _tempVector2;
  71983. private _tempVector3;
  71984. private _tempVector4;
  71985. private _edge;
  71986. private _baseToVertex;
  71987. private _destinationPoint;
  71988. private _slidePlaneNormal;
  71989. private _displacementVector;
  71990. /** @hidden */
  71991. _radius: Vector3;
  71992. /** @hidden */
  71993. _retry: number;
  71994. private _velocity;
  71995. private _basePoint;
  71996. private _epsilon;
  71997. /** @hidden */
  71998. _velocityWorldLength: number;
  71999. /** @hidden */
  72000. _basePointWorld: Vector3;
  72001. private _velocityWorld;
  72002. private _normalizedVelocity;
  72003. /** @hidden */
  72004. _initialVelocity: Vector3;
  72005. /** @hidden */
  72006. _initialPosition: Vector3;
  72007. private _nearestDistance;
  72008. private _collisionMask;
  72009. collisionMask: number;
  72010. /**
  72011. * Gets the plane normal used to compute the sliding response (in local space)
  72012. */
  72013. readonly slidePlaneNormal: Vector3;
  72014. /** @hidden */
  72015. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72016. /** @hidden */
  72017. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72018. /** @hidden */
  72019. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72020. /** @hidden */
  72021. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72022. /** @hidden */
  72023. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72024. /** @hidden */
  72025. _getResponse(pos: Vector3, vel: Vector3): void;
  72026. }
  72027. }
  72028. declare module BABYLON {
  72029. /**
  72030. * Interface for cullable objects
  72031. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72032. */
  72033. export interface ICullable {
  72034. /**
  72035. * Checks if the object or part of the object is in the frustum
  72036. * @param frustumPlanes Camera near/planes
  72037. * @returns true if the object is in frustum otherwise false
  72038. */
  72039. isInFrustum(frustumPlanes: Plane[]): boolean;
  72040. /**
  72041. * Checks if a cullable object (mesh...) is in the camera frustum
  72042. * Unlike isInFrustum this cheks the full bounding box
  72043. * @param frustumPlanes Camera near/planes
  72044. * @returns true if the object is in frustum otherwise false
  72045. */
  72046. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72047. }
  72048. /**
  72049. * Info for a bounding data of a mesh
  72050. */
  72051. export class BoundingInfo implements ICullable {
  72052. /**
  72053. * Bounding box for the mesh
  72054. */
  72055. readonly boundingBox: BoundingBox;
  72056. /**
  72057. * Bounding sphere for the mesh
  72058. */
  72059. readonly boundingSphere: BoundingSphere;
  72060. private _isLocked;
  72061. private static readonly TmpVector3;
  72062. /**
  72063. * Constructs bounding info
  72064. * @param minimum min vector of the bounding box/sphere
  72065. * @param maximum max vector of the bounding box/sphere
  72066. * @param worldMatrix defines the new world matrix
  72067. */
  72068. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72069. /**
  72070. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72071. * @param min defines the new minimum vector (in local space)
  72072. * @param max defines the new maximum vector (in local space)
  72073. * @param worldMatrix defines the new world matrix
  72074. */
  72075. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72076. /**
  72077. * min vector of the bounding box/sphere
  72078. */
  72079. readonly minimum: Vector3;
  72080. /**
  72081. * max vector of the bounding box/sphere
  72082. */
  72083. readonly maximum: Vector3;
  72084. /**
  72085. * If the info is locked and won't be updated to avoid perf overhead
  72086. */
  72087. isLocked: boolean;
  72088. /**
  72089. * Updates the bounding sphere and box
  72090. * @param world world matrix to be used to update
  72091. */
  72092. update(world: DeepImmutable<Matrix>): void;
  72093. /**
  72094. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72095. * @param center New center of the bounding info
  72096. * @param extend New extend of the bounding info
  72097. * @returns the current bounding info
  72098. */
  72099. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72100. /**
  72101. * Scale the current bounding info by applying a scale factor
  72102. * @param factor defines the scale factor to apply
  72103. * @returns the current bounding info
  72104. */
  72105. scale(factor: number): BoundingInfo;
  72106. /**
  72107. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72108. * @param frustumPlanes defines the frustum to test
  72109. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72110. * @returns true if the bounding info is in the frustum planes
  72111. */
  72112. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72113. /**
  72114. * Gets the world distance between the min and max points of the bounding box
  72115. */
  72116. readonly diagonalLength: number;
  72117. /**
  72118. * Checks if a cullable object (mesh...) is in the camera frustum
  72119. * Unlike isInFrustum this cheks the full bounding box
  72120. * @param frustumPlanes Camera near/planes
  72121. * @returns true if the object is in frustum otherwise false
  72122. */
  72123. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72124. /** @hidden */
  72125. _checkCollision(collider: Collider): boolean;
  72126. /**
  72127. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72128. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72129. * @param point the point to check intersection with
  72130. * @returns if the point intersects
  72131. */
  72132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72133. /**
  72134. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72135. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72136. * @param boundingInfo the bounding info to check intersection with
  72137. * @param precise if the intersection should be done using OBB
  72138. * @returns if the bounding info intersects
  72139. */
  72140. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72141. }
  72142. }
  72143. declare module BABYLON {
  72144. /**
  72145. * Extracts minimum and maximum values from a list of indexed positions
  72146. * @param positions defines the positions to use
  72147. * @param indices defines the indices to the positions
  72148. * @param indexStart defines the start index
  72149. * @param indexCount defines the end index
  72150. * @param bias defines bias value to add to the result
  72151. * @return minimum and maximum values
  72152. */
  72153. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72154. minimum: Vector3;
  72155. maximum: Vector3;
  72156. };
  72157. /**
  72158. * Extracts minimum and maximum values from a list of positions
  72159. * @param positions defines the positions to use
  72160. * @param start defines the start index in the positions array
  72161. * @param count defines the number of positions to handle
  72162. * @param bias defines bias value to add to the result
  72163. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72164. * @return minimum and maximum values
  72165. */
  72166. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72167. minimum: Vector3;
  72168. maximum: Vector3;
  72169. };
  72170. }
  72171. declare module BABYLON {
  72172. /**
  72173. * Enum that determines the text-wrapping mode to use.
  72174. */
  72175. export enum InspectableType {
  72176. /**
  72177. * Checkbox for booleans
  72178. */
  72179. Checkbox = 0,
  72180. /**
  72181. * Sliders for numbers
  72182. */
  72183. Slider = 1,
  72184. /**
  72185. * Vector3
  72186. */
  72187. Vector3 = 2,
  72188. /**
  72189. * Quaternions
  72190. */
  72191. Quaternion = 3,
  72192. /**
  72193. * Color3
  72194. */
  72195. Color3 = 4,
  72196. /**
  72197. * String
  72198. */
  72199. String = 5
  72200. }
  72201. /**
  72202. * Interface used to define custom inspectable properties.
  72203. * This interface is used by the inspector to display custom property grids
  72204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72205. */
  72206. export interface IInspectable {
  72207. /**
  72208. * Gets the label to display
  72209. */
  72210. label: string;
  72211. /**
  72212. * Gets the name of the property to edit
  72213. */
  72214. propertyName: string;
  72215. /**
  72216. * Gets the type of the editor to use
  72217. */
  72218. type: InspectableType;
  72219. /**
  72220. * Gets the minimum value of the property when using in "slider" mode
  72221. */
  72222. min?: number;
  72223. /**
  72224. * Gets the maximum value of the property when using in "slider" mode
  72225. */
  72226. max?: number;
  72227. /**
  72228. * Gets the setp to use when using in "slider" mode
  72229. */
  72230. step?: number;
  72231. }
  72232. }
  72233. declare module BABYLON {
  72234. /**
  72235. * Class used to provide helper for timing
  72236. */
  72237. export class TimingTools {
  72238. /**
  72239. * Polyfill for setImmediate
  72240. * @param action defines the action to execute after the current execution block
  72241. */
  72242. static SetImmediate(action: () => void): void;
  72243. }
  72244. }
  72245. declare module BABYLON {
  72246. /**
  72247. * Class used to enable instatition of objects by class name
  72248. */
  72249. export class InstantiationTools {
  72250. /**
  72251. * Use this object to register external classes like custom textures or material
  72252. * to allow the laoders to instantiate them
  72253. */
  72254. static RegisteredExternalClasses: {
  72255. [key: string]: Object;
  72256. };
  72257. /**
  72258. * Tries to instantiate a new object from a given class name
  72259. * @param className defines the class name to instantiate
  72260. * @returns the new object or null if the system was not able to do the instantiation
  72261. */
  72262. static Instantiate(className: string): any;
  72263. }
  72264. }
  72265. declare module BABYLON {
  72266. /**
  72267. * This represents the required contract to create a new type of texture loader.
  72268. */
  72269. export interface IInternalTextureLoader {
  72270. /**
  72271. * Defines wether the loader supports cascade loading the different faces.
  72272. */
  72273. supportCascades: boolean;
  72274. /**
  72275. * This returns if the loader support the current file information.
  72276. * @param extension defines the file extension of the file being loaded
  72277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72278. * @param fallback defines the fallback internal texture if any
  72279. * @param isBase64 defines whether the texture is encoded as a base64
  72280. * @param isBuffer defines whether the texture data are stored as a buffer
  72281. * @returns true if the loader can load the specified file
  72282. */
  72283. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72284. /**
  72285. * Transform the url before loading if required.
  72286. * @param rootUrl the url of the texture
  72287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72288. * @returns the transformed texture
  72289. */
  72290. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72291. /**
  72292. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72293. * @param rootUrl the url of the texture
  72294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72295. * @returns the fallback texture
  72296. */
  72297. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72298. /**
  72299. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72300. * @param data contains the texture data
  72301. * @param texture defines the BabylonJS internal texture
  72302. * @param createPolynomials will be true if polynomials have been requested
  72303. * @param onLoad defines the callback to trigger once the texture is ready
  72304. * @param onError defines the callback to trigger in case of error
  72305. */
  72306. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72307. /**
  72308. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72309. * @param data contains the texture data
  72310. * @param texture defines the BabylonJS internal texture
  72311. * @param callback defines the method to call once ready to upload
  72312. */
  72313. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72314. }
  72315. }
  72316. declare module BABYLON {
  72317. interface Engine {
  72318. /**
  72319. * Creates a depth stencil cube texture.
  72320. * This is only available in WebGL 2.
  72321. * @param size The size of face edge in the cube texture.
  72322. * @param options The options defining the cube texture.
  72323. * @returns The cube texture
  72324. */
  72325. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72326. /**
  72327. * Creates a cube texture
  72328. * @param rootUrl defines the url where the files to load is located
  72329. * @param scene defines the current scene
  72330. * @param files defines the list of files to load (1 per face)
  72331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72332. * @param onLoad defines an optional callback raised when the texture is loaded
  72333. * @param onError defines an optional callback raised if there is an issue to load the texture
  72334. * @param format defines the format of the data
  72335. * @param forcedExtension defines the extension to use to pick the right loader
  72336. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72337. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72338. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72339. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72340. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72341. * @returns the cube texture as an InternalTexture
  72342. */
  72343. 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;
  72344. /**
  72345. * Creates a cube texture
  72346. * @param rootUrl defines the url where the files to load is located
  72347. * @param scene defines the current scene
  72348. * @param files defines the list of files to load (1 per face)
  72349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72350. * @param onLoad defines an optional callback raised when the texture is loaded
  72351. * @param onError defines an optional callback raised if there is an issue to load the texture
  72352. * @param format defines the format of the data
  72353. * @param forcedExtension defines the extension to use to pick the right loader
  72354. * @returns the cube texture as an InternalTexture
  72355. */
  72356. 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;
  72357. /**
  72358. * Creates a cube texture
  72359. * @param rootUrl defines the url where the files to load is located
  72360. * @param scene defines the current scene
  72361. * @param files defines the list of files to load (1 per face)
  72362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72363. * @param onLoad defines an optional callback raised when the texture is loaded
  72364. * @param onError defines an optional callback raised if there is an issue to load the texture
  72365. * @param format defines the format of the data
  72366. * @param forcedExtension defines the extension to use to pick the right loader
  72367. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72368. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72369. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72370. * @returns the cube texture as an InternalTexture
  72371. */
  72372. 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;
  72373. /** @hidden */
  72374. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72375. /** @hidden */
  72376. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72377. /** @hidden */
  72378. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72379. /** @hidden */
  72380. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72381. }
  72382. }
  72383. declare module BABYLON {
  72384. /**
  72385. * Class for creating a cube texture
  72386. */
  72387. export class CubeTexture extends BaseTexture {
  72388. private _delayedOnLoad;
  72389. /**
  72390. * The url of the texture
  72391. */
  72392. url: string;
  72393. /**
  72394. * Gets or sets the center of the bounding box associated with the cube texture.
  72395. * It must define where the camera used to render the texture was set
  72396. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72397. */
  72398. boundingBoxPosition: Vector3;
  72399. private _boundingBoxSize;
  72400. /**
  72401. * Gets or sets the size of the bounding box associated with the cube texture
  72402. * When defined, the cubemap will switch to local mode
  72403. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72404. * @example https://www.babylonjs-playground.com/#RNASML
  72405. */
  72406. /**
  72407. * Returns the bounding box size
  72408. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72409. */
  72410. boundingBoxSize: Vector3;
  72411. protected _rotationY: number;
  72412. /**
  72413. * Sets texture matrix rotation angle around Y axis in radians.
  72414. */
  72415. /**
  72416. * Gets texture matrix rotation angle around Y axis radians.
  72417. */
  72418. rotationY: number;
  72419. /**
  72420. * Are mip maps generated for this texture or not.
  72421. */
  72422. readonly noMipmap: boolean;
  72423. private _noMipmap;
  72424. private _files;
  72425. private _extensions;
  72426. private _textureMatrix;
  72427. private _format;
  72428. private _createPolynomials;
  72429. /** @hidden */
  72430. _prefiltered: boolean;
  72431. /**
  72432. * Creates a cube texture from an array of image urls
  72433. * @param files defines an array of image urls
  72434. * @param scene defines the hosting scene
  72435. * @param noMipmap specifies if mip maps are not used
  72436. * @returns a cube texture
  72437. */
  72438. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72439. /**
  72440. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72441. * @param url defines the url of the prefiltered texture
  72442. * @param scene defines the scene the texture is attached to
  72443. * @param forcedExtension defines the extension of the file if different from the url
  72444. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72445. * @return the prefiltered texture
  72446. */
  72447. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72448. /**
  72449. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72450. * as prefiltered data.
  72451. * @param rootUrl defines the url of the texture or the root name of the six images
  72452. * @param scene defines the scene the texture is attached to
  72453. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72454. * @param noMipmap defines if mipmaps should be created or not
  72455. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72456. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72457. * @param onError defines a callback triggered in case of error during load
  72458. * @param format defines the internal format to use for the texture once loaded
  72459. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72460. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72461. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72462. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72463. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72464. * @return the cube texture
  72465. */
  72466. 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);
  72467. /**
  72468. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72469. */
  72470. readonly isPrefiltered: boolean;
  72471. /**
  72472. * Get the current class name of the texture useful for serialization or dynamic coding.
  72473. * @returns "CubeTexture"
  72474. */
  72475. getClassName(): string;
  72476. /**
  72477. * Update the url (and optional buffer) of this texture if url was null during construction.
  72478. * @param url the url of the texture
  72479. * @param forcedExtension defines the extension to use
  72480. * @param onLoad callback called when the texture is loaded (defaults to null)
  72481. */
  72482. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72483. /**
  72484. * Delays loading of the cube texture
  72485. * @param forcedExtension defines the extension to use
  72486. */
  72487. delayLoad(forcedExtension?: string): void;
  72488. /**
  72489. * Returns the reflection texture matrix
  72490. * @returns the reflection texture matrix
  72491. */
  72492. getReflectionTextureMatrix(): Matrix;
  72493. /**
  72494. * Sets the reflection texture matrix
  72495. * @param value Reflection texture matrix
  72496. */
  72497. setReflectionTextureMatrix(value: Matrix): void;
  72498. /**
  72499. * Parses text to create a cube texture
  72500. * @param parsedTexture define the serialized text to read from
  72501. * @param scene defines the hosting scene
  72502. * @param rootUrl defines the root url of the cube texture
  72503. * @returns a cube texture
  72504. */
  72505. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72506. /**
  72507. * Makes a clone, or deep copy, of the cube texture
  72508. * @returns a new cube texture
  72509. */
  72510. clone(): CubeTexture;
  72511. }
  72512. }
  72513. declare module BABYLON {
  72514. /**
  72515. * Manages the defines for the Material
  72516. */
  72517. export class MaterialDefines {
  72518. /** @hidden */
  72519. protected _keys: string[];
  72520. private _isDirty;
  72521. /** @hidden */
  72522. _renderId: number;
  72523. /** @hidden */
  72524. _areLightsDirty: boolean;
  72525. /** @hidden */
  72526. _areAttributesDirty: boolean;
  72527. /** @hidden */
  72528. _areTexturesDirty: boolean;
  72529. /** @hidden */
  72530. _areFresnelDirty: boolean;
  72531. /** @hidden */
  72532. _areMiscDirty: boolean;
  72533. /** @hidden */
  72534. _areImageProcessingDirty: boolean;
  72535. /** @hidden */
  72536. _normals: boolean;
  72537. /** @hidden */
  72538. _uvs: boolean;
  72539. /** @hidden */
  72540. _needNormals: boolean;
  72541. /** @hidden */
  72542. _needUVs: boolean;
  72543. [id: string]: any;
  72544. /**
  72545. * Specifies if the material needs to be re-calculated
  72546. */
  72547. readonly isDirty: boolean;
  72548. /**
  72549. * Marks the material to indicate that it has been re-calculated
  72550. */
  72551. markAsProcessed(): void;
  72552. /**
  72553. * Marks the material to indicate that it needs to be re-calculated
  72554. */
  72555. markAsUnprocessed(): void;
  72556. /**
  72557. * Marks the material to indicate all of its defines need to be re-calculated
  72558. */
  72559. markAllAsDirty(): void;
  72560. /**
  72561. * Marks the material to indicate that image processing needs to be re-calculated
  72562. */
  72563. markAsImageProcessingDirty(): void;
  72564. /**
  72565. * Marks the material to indicate the lights need to be re-calculated
  72566. */
  72567. markAsLightDirty(): void;
  72568. /**
  72569. * Marks the attribute state as changed
  72570. */
  72571. markAsAttributesDirty(): void;
  72572. /**
  72573. * Marks the texture state as changed
  72574. */
  72575. markAsTexturesDirty(): void;
  72576. /**
  72577. * Marks the fresnel state as changed
  72578. */
  72579. markAsFresnelDirty(): void;
  72580. /**
  72581. * Marks the misc state as changed
  72582. */
  72583. markAsMiscDirty(): void;
  72584. /**
  72585. * Rebuilds the material defines
  72586. */
  72587. rebuild(): void;
  72588. /**
  72589. * Specifies if two material defines are equal
  72590. * @param other - A material define instance to compare to
  72591. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72592. */
  72593. isEqual(other: MaterialDefines): boolean;
  72594. /**
  72595. * Clones this instance's defines to another instance
  72596. * @param other - material defines to clone values to
  72597. */
  72598. cloneTo(other: MaterialDefines): void;
  72599. /**
  72600. * Resets the material define values
  72601. */
  72602. reset(): void;
  72603. /**
  72604. * Converts the material define values to a string
  72605. * @returns - String of material define information
  72606. */
  72607. toString(): string;
  72608. }
  72609. }
  72610. declare module BABYLON {
  72611. /**
  72612. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72613. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72614. * 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;
  72615. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72616. */
  72617. export class ColorCurves {
  72618. private _dirty;
  72619. private _tempColor;
  72620. private _globalCurve;
  72621. private _highlightsCurve;
  72622. private _midtonesCurve;
  72623. private _shadowsCurve;
  72624. private _positiveCurve;
  72625. private _negativeCurve;
  72626. private _globalHue;
  72627. private _globalDensity;
  72628. private _globalSaturation;
  72629. private _globalExposure;
  72630. /**
  72631. * Gets the global Hue value.
  72632. * 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).
  72633. */
  72634. /**
  72635. * Sets the global Hue value.
  72636. * 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).
  72637. */
  72638. globalHue: number;
  72639. /**
  72640. * Gets the global Density value.
  72641. * 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.
  72642. * Values less than zero provide a filter of opposite hue.
  72643. */
  72644. /**
  72645. * Sets the global Density value.
  72646. * 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.
  72647. * Values less than zero provide a filter of opposite hue.
  72648. */
  72649. globalDensity: number;
  72650. /**
  72651. * Gets the global Saturation value.
  72652. * 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.
  72653. */
  72654. /**
  72655. * Sets the global Saturation value.
  72656. * 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.
  72657. */
  72658. globalSaturation: number;
  72659. /**
  72660. * Gets the global Exposure value.
  72661. * 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.
  72662. */
  72663. /**
  72664. * Sets the global Exposure value.
  72665. * 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.
  72666. */
  72667. globalExposure: number;
  72668. private _highlightsHue;
  72669. private _highlightsDensity;
  72670. private _highlightsSaturation;
  72671. private _highlightsExposure;
  72672. /**
  72673. * Gets the highlights Hue value.
  72674. * 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).
  72675. */
  72676. /**
  72677. * Sets the highlights Hue value.
  72678. * 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).
  72679. */
  72680. highlightsHue: number;
  72681. /**
  72682. * Gets the highlights Density value.
  72683. * 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.
  72684. * Values less than zero provide a filter of opposite hue.
  72685. */
  72686. /**
  72687. * Sets the highlights Density value.
  72688. * 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.
  72689. * Values less than zero provide a filter of opposite hue.
  72690. */
  72691. highlightsDensity: number;
  72692. /**
  72693. * Gets the highlights Saturation value.
  72694. * 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.
  72695. */
  72696. /**
  72697. * Sets the highlights Saturation value.
  72698. * 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.
  72699. */
  72700. highlightsSaturation: number;
  72701. /**
  72702. * Gets the highlights Exposure value.
  72703. * 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.
  72704. */
  72705. /**
  72706. * Sets the highlights Exposure value.
  72707. * 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.
  72708. */
  72709. highlightsExposure: number;
  72710. private _midtonesHue;
  72711. private _midtonesDensity;
  72712. private _midtonesSaturation;
  72713. private _midtonesExposure;
  72714. /**
  72715. * Gets the midtones Hue value.
  72716. * 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).
  72717. */
  72718. /**
  72719. * Sets the midtones Hue value.
  72720. * 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).
  72721. */
  72722. midtonesHue: number;
  72723. /**
  72724. * Gets the midtones Density value.
  72725. * 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.
  72726. * Values less than zero provide a filter of opposite hue.
  72727. */
  72728. /**
  72729. * Sets the midtones Density value.
  72730. * 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.
  72731. * Values less than zero provide a filter of opposite hue.
  72732. */
  72733. midtonesDensity: number;
  72734. /**
  72735. * Gets the midtones Saturation value.
  72736. * 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.
  72737. */
  72738. /**
  72739. * Sets the midtones Saturation value.
  72740. * 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.
  72741. */
  72742. midtonesSaturation: number;
  72743. /**
  72744. * Gets the midtones Exposure value.
  72745. * 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.
  72746. */
  72747. /**
  72748. * Sets the midtones Exposure value.
  72749. * 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.
  72750. */
  72751. midtonesExposure: number;
  72752. private _shadowsHue;
  72753. private _shadowsDensity;
  72754. private _shadowsSaturation;
  72755. private _shadowsExposure;
  72756. /**
  72757. * Gets the shadows Hue value.
  72758. * 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).
  72759. */
  72760. /**
  72761. * Sets the shadows Hue value.
  72762. * 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).
  72763. */
  72764. shadowsHue: number;
  72765. /**
  72766. * Gets the shadows Density value.
  72767. * 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.
  72768. * Values less than zero provide a filter of opposite hue.
  72769. */
  72770. /**
  72771. * Sets the shadows Density value.
  72772. * 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.
  72773. * Values less than zero provide a filter of opposite hue.
  72774. */
  72775. shadowsDensity: number;
  72776. /**
  72777. * Gets the shadows Saturation value.
  72778. * 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.
  72779. */
  72780. /**
  72781. * Sets the shadows Saturation value.
  72782. * 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.
  72783. */
  72784. shadowsSaturation: number;
  72785. /**
  72786. * Gets the shadows Exposure value.
  72787. * 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.
  72788. */
  72789. /**
  72790. * Sets the shadows Exposure value.
  72791. * 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.
  72792. */
  72793. shadowsExposure: number;
  72794. /**
  72795. * Returns the class name
  72796. * @returns The class name
  72797. */
  72798. getClassName(): string;
  72799. /**
  72800. * Binds the color curves to the shader.
  72801. * @param colorCurves The color curve to bind
  72802. * @param effect The effect to bind to
  72803. * @param positiveUniform The positive uniform shader parameter
  72804. * @param neutralUniform The neutral uniform shader parameter
  72805. * @param negativeUniform The negative uniform shader parameter
  72806. */
  72807. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72808. /**
  72809. * Prepare the list of uniforms associated with the ColorCurves effects.
  72810. * @param uniformsList The list of uniforms used in the effect
  72811. */
  72812. static PrepareUniforms(uniformsList: string[]): void;
  72813. /**
  72814. * Returns color grading data based on a hue, density, saturation and exposure value.
  72815. * @param filterHue The hue of the color filter.
  72816. * @param filterDensity The density of the color filter.
  72817. * @param saturation The saturation.
  72818. * @param exposure The exposure.
  72819. * @param result The result data container.
  72820. */
  72821. private getColorGradingDataToRef;
  72822. /**
  72823. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72824. * @param value The input slider value in range [-100,100].
  72825. * @returns Adjusted value.
  72826. */
  72827. private static applyColorGradingSliderNonlinear;
  72828. /**
  72829. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72830. * @param hue The hue (H) input.
  72831. * @param saturation The saturation (S) input.
  72832. * @param brightness The brightness (B) input.
  72833. * @result An RGBA color represented as Vector4.
  72834. */
  72835. private static fromHSBToRef;
  72836. /**
  72837. * Returns a value clamped between min and max
  72838. * @param value The value to clamp
  72839. * @param min The minimum of value
  72840. * @param max The maximum of value
  72841. * @returns The clamped value.
  72842. */
  72843. private static clamp;
  72844. /**
  72845. * Clones the current color curve instance.
  72846. * @return The cloned curves
  72847. */
  72848. clone(): ColorCurves;
  72849. /**
  72850. * Serializes the current color curve instance to a json representation.
  72851. * @return a JSON representation
  72852. */
  72853. serialize(): any;
  72854. /**
  72855. * Parses the color curve from a json representation.
  72856. * @param source the JSON source to parse
  72857. * @return The parsed curves
  72858. */
  72859. static Parse(source: any): ColorCurves;
  72860. }
  72861. }
  72862. declare module BABYLON {
  72863. /**
  72864. * Interface to follow in your material defines to integrate easily the
  72865. * Image proccessing functions.
  72866. * @hidden
  72867. */
  72868. export interface IImageProcessingConfigurationDefines {
  72869. IMAGEPROCESSING: boolean;
  72870. VIGNETTE: boolean;
  72871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72872. VIGNETTEBLENDMODEOPAQUE: boolean;
  72873. TONEMAPPING: boolean;
  72874. TONEMAPPING_ACES: boolean;
  72875. CONTRAST: boolean;
  72876. EXPOSURE: boolean;
  72877. COLORCURVES: boolean;
  72878. COLORGRADING: boolean;
  72879. COLORGRADING3D: boolean;
  72880. SAMPLER3DGREENDEPTH: boolean;
  72881. SAMPLER3DBGRMAP: boolean;
  72882. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72883. }
  72884. /**
  72885. * @hidden
  72886. */
  72887. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72888. IMAGEPROCESSING: boolean;
  72889. VIGNETTE: boolean;
  72890. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72891. VIGNETTEBLENDMODEOPAQUE: boolean;
  72892. TONEMAPPING: boolean;
  72893. TONEMAPPING_ACES: boolean;
  72894. CONTRAST: boolean;
  72895. COLORCURVES: boolean;
  72896. COLORGRADING: boolean;
  72897. COLORGRADING3D: boolean;
  72898. SAMPLER3DGREENDEPTH: boolean;
  72899. SAMPLER3DBGRMAP: boolean;
  72900. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72901. EXPOSURE: boolean;
  72902. constructor();
  72903. }
  72904. /**
  72905. * This groups together the common properties used for image processing either in direct forward pass
  72906. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72907. * or not.
  72908. */
  72909. export class ImageProcessingConfiguration {
  72910. /**
  72911. * Default tone mapping applied in BabylonJS.
  72912. */
  72913. static readonly TONEMAPPING_STANDARD: number;
  72914. /**
  72915. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72916. * to other engines rendering to increase portability.
  72917. */
  72918. static readonly TONEMAPPING_ACES: number;
  72919. /**
  72920. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72921. */
  72922. colorCurves: Nullable<ColorCurves>;
  72923. private _colorCurvesEnabled;
  72924. /**
  72925. * Gets wether the color curves effect is enabled.
  72926. */
  72927. /**
  72928. * Sets wether the color curves effect is enabled.
  72929. */
  72930. colorCurvesEnabled: boolean;
  72931. private _colorGradingTexture;
  72932. /**
  72933. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72934. */
  72935. /**
  72936. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72937. */
  72938. colorGradingTexture: Nullable<BaseTexture>;
  72939. private _colorGradingEnabled;
  72940. /**
  72941. * Gets wether the color grading effect is enabled.
  72942. */
  72943. /**
  72944. * Sets wether the color grading effect is enabled.
  72945. */
  72946. colorGradingEnabled: boolean;
  72947. private _colorGradingWithGreenDepth;
  72948. /**
  72949. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72950. */
  72951. /**
  72952. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72953. */
  72954. colorGradingWithGreenDepth: boolean;
  72955. private _colorGradingBGR;
  72956. /**
  72957. * Gets wether the color grading texture contains BGR values.
  72958. */
  72959. /**
  72960. * Sets wether the color grading texture contains BGR values.
  72961. */
  72962. colorGradingBGR: boolean;
  72963. /** @hidden */
  72964. _exposure: number;
  72965. /**
  72966. * Gets the Exposure used in the effect.
  72967. */
  72968. /**
  72969. * Sets the Exposure used in the effect.
  72970. */
  72971. exposure: number;
  72972. private _toneMappingEnabled;
  72973. /**
  72974. * Gets wether the tone mapping effect is enabled.
  72975. */
  72976. /**
  72977. * Sets wether the tone mapping effect is enabled.
  72978. */
  72979. toneMappingEnabled: boolean;
  72980. private _toneMappingType;
  72981. /**
  72982. * Gets the type of tone mapping effect.
  72983. */
  72984. /**
  72985. * Sets the type of tone mapping effect used in BabylonJS.
  72986. */
  72987. toneMappingType: number;
  72988. protected _contrast: number;
  72989. /**
  72990. * Gets the contrast used in the effect.
  72991. */
  72992. /**
  72993. * Sets the contrast used in the effect.
  72994. */
  72995. contrast: number;
  72996. /**
  72997. * Vignette stretch size.
  72998. */
  72999. vignetteStretch: number;
  73000. /**
  73001. * Vignette centre X Offset.
  73002. */
  73003. vignetteCentreX: number;
  73004. /**
  73005. * Vignette centre Y Offset.
  73006. */
  73007. vignetteCentreY: number;
  73008. /**
  73009. * Vignette weight or intensity of the vignette effect.
  73010. */
  73011. vignetteWeight: number;
  73012. /**
  73013. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73014. * if vignetteEnabled is set to true.
  73015. */
  73016. vignetteColor: Color4;
  73017. /**
  73018. * Camera field of view used by the Vignette effect.
  73019. */
  73020. vignetteCameraFov: number;
  73021. private _vignetteBlendMode;
  73022. /**
  73023. * Gets the vignette blend mode allowing different kind of effect.
  73024. */
  73025. /**
  73026. * Sets the vignette blend mode allowing different kind of effect.
  73027. */
  73028. vignetteBlendMode: number;
  73029. private _vignetteEnabled;
  73030. /**
  73031. * Gets wether the vignette effect is enabled.
  73032. */
  73033. /**
  73034. * Sets wether the vignette effect is enabled.
  73035. */
  73036. vignetteEnabled: boolean;
  73037. private _applyByPostProcess;
  73038. /**
  73039. * Gets wether the image processing is applied through a post process or not.
  73040. */
  73041. /**
  73042. * Sets wether the image processing is applied through a post process or not.
  73043. */
  73044. applyByPostProcess: boolean;
  73045. private _isEnabled;
  73046. /**
  73047. * Gets wether the image processing is enabled or not.
  73048. */
  73049. /**
  73050. * Sets wether the image processing is enabled or not.
  73051. */
  73052. isEnabled: boolean;
  73053. /**
  73054. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73055. */
  73056. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73057. /**
  73058. * Method called each time the image processing information changes requires to recompile the effect.
  73059. */
  73060. protected _updateParameters(): void;
  73061. /**
  73062. * Gets the current class name.
  73063. * @return "ImageProcessingConfiguration"
  73064. */
  73065. getClassName(): string;
  73066. /**
  73067. * Prepare the list of uniforms associated with the Image Processing effects.
  73068. * @param uniforms The list of uniforms used in the effect
  73069. * @param defines the list of defines currently in use
  73070. */
  73071. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73072. /**
  73073. * Prepare the list of samplers associated with the Image Processing effects.
  73074. * @param samplersList The list of uniforms used in the effect
  73075. * @param defines the list of defines currently in use
  73076. */
  73077. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73078. /**
  73079. * Prepare the list of defines associated to the shader.
  73080. * @param defines the list of defines to complete
  73081. * @param forPostProcess Define if we are currently in post process mode or not
  73082. */
  73083. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73084. /**
  73085. * Returns true if all the image processing information are ready.
  73086. * @returns True if ready, otherwise, false
  73087. */
  73088. isReady(): boolean;
  73089. /**
  73090. * Binds the image processing to the shader.
  73091. * @param effect The effect to bind to
  73092. * @param aspectRatio Define the current aspect ratio of the effect
  73093. */
  73094. bind(effect: Effect, aspectRatio?: number): void;
  73095. /**
  73096. * Clones the current image processing instance.
  73097. * @return The cloned image processing
  73098. */
  73099. clone(): ImageProcessingConfiguration;
  73100. /**
  73101. * Serializes the current image processing instance to a json representation.
  73102. * @return a JSON representation
  73103. */
  73104. serialize(): any;
  73105. /**
  73106. * Parses the image processing from a json representation.
  73107. * @param source the JSON source to parse
  73108. * @return The parsed image processing
  73109. */
  73110. static Parse(source: any): ImageProcessingConfiguration;
  73111. private static _VIGNETTEMODE_MULTIPLY;
  73112. private static _VIGNETTEMODE_OPAQUE;
  73113. /**
  73114. * Used to apply the vignette as a mix with the pixel color.
  73115. */
  73116. static readonly VIGNETTEMODE_MULTIPLY: number;
  73117. /**
  73118. * Used to apply the vignette as a replacement of the pixel color.
  73119. */
  73120. static readonly VIGNETTEMODE_OPAQUE: number;
  73121. }
  73122. }
  73123. declare module BABYLON {
  73124. /** @hidden */
  73125. export var postprocessVertexShader: {
  73126. name: string;
  73127. shader: string;
  73128. };
  73129. }
  73130. declare module BABYLON {
  73131. /** Defines supported spaces */
  73132. export enum Space {
  73133. /** Local (object) space */
  73134. LOCAL = 0,
  73135. /** World space */
  73136. WORLD = 1,
  73137. /** Bone space */
  73138. BONE = 2
  73139. }
  73140. /** Defines the 3 main axes */
  73141. export class Axis {
  73142. /** X axis */
  73143. static X: Vector3;
  73144. /** Y axis */
  73145. static Y: Vector3;
  73146. /** Z axis */
  73147. static Z: Vector3;
  73148. }
  73149. }
  73150. declare module BABYLON {
  73151. /**
  73152. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73153. * This is the base of the follow, arc rotate cameras and Free camera
  73154. * @see http://doc.babylonjs.com/features/cameras
  73155. */
  73156. export class TargetCamera extends Camera {
  73157. private static _RigCamTransformMatrix;
  73158. private static _TargetTransformMatrix;
  73159. private static _TargetFocalPoint;
  73160. /**
  73161. * Define the current direction the camera is moving to
  73162. */
  73163. cameraDirection: Vector3;
  73164. /**
  73165. * Define the current rotation the camera is rotating to
  73166. */
  73167. cameraRotation: Vector2;
  73168. /**
  73169. * When set, the up vector of the camera will be updated by the rotation of the camera
  73170. */
  73171. updateUpVectorFromRotation: boolean;
  73172. private _tmpQuaternion;
  73173. /**
  73174. * Define the current rotation of the camera
  73175. */
  73176. rotation: Vector3;
  73177. /**
  73178. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73179. */
  73180. rotationQuaternion: Quaternion;
  73181. /**
  73182. * Define the current speed of the camera
  73183. */
  73184. speed: number;
  73185. /**
  73186. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73187. * around all axis.
  73188. */
  73189. noRotationConstraint: boolean;
  73190. /**
  73191. * Define the current target of the camera as an object or a position.
  73192. */
  73193. lockedTarget: any;
  73194. /** @hidden */
  73195. _currentTarget: Vector3;
  73196. /** @hidden */
  73197. _initialFocalDistance: number;
  73198. /** @hidden */
  73199. _viewMatrix: Matrix;
  73200. /** @hidden */
  73201. _camMatrix: Matrix;
  73202. /** @hidden */
  73203. _cameraTransformMatrix: Matrix;
  73204. /** @hidden */
  73205. _cameraRotationMatrix: Matrix;
  73206. /** @hidden */
  73207. _referencePoint: Vector3;
  73208. /** @hidden */
  73209. _transformedReferencePoint: Vector3;
  73210. protected _globalCurrentTarget: Vector3;
  73211. protected _globalCurrentUpVector: Vector3;
  73212. /** @hidden */
  73213. _reset: () => void;
  73214. private _defaultUp;
  73215. /**
  73216. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73217. * This is the base of the follow, arc rotate cameras and Free camera
  73218. * @see http://doc.babylonjs.com/features/cameras
  73219. * @param name Defines the name of the camera in the scene
  73220. * @param position Defines the start position of the camera in the scene
  73221. * @param scene Defines the scene the camera belongs to
  73222. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73223. */
  73224. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73225. /**
  73226. * Gets the position in front of the camera at a given distance.
  73227. * @param distance The distance from the camera we want the position to be
  73228. * @returns the position
  73229. */
  73230. getFrontPosition(distance: number): Vector3;
  73231. /** @hidden */
  73232. _getLockedTargetPosition(): Nullable<Vector3>;
  73233. private _storedPosition;
  73234. private _storedRotation;
  73235. private _storedRotationQuaternion;
  73236. /**
  73237. * Store current camera state of the camera (fov, position, rotation, etc..)
  73238. * @returns the camera
  73239. */
  73240. storeState(): Camera;
  73241. /**
  73242. * Restored camera state. You must call storeState() first
  73243. * @returns whether it was successful or not
  73244. * @hidden
  73245. */
  73246. _restoreStateValues(): boolean;
  73247. /** @hidden */
  73248. _initCache(): void;
  73249. /** @hidden */
  73250. _updateCache(ignoreParentClass?: boolean): void;
  73251. /** @hidden */
  73252. _isSynchronizedViewMatrix(): boolean;
  73253. /** @hidden */
  73254. _computeLocalCameraSpeed(): number;
  73255. /**
  73256. * Defines the target the camera should look at.
  73257. * @param target Defines the new target as a Vector or a mesh
  73258. */
  73259. setTarget(target: Vector3): void;
  73260. /**
  73261. * Return the current target position of the camera. This value is expressed in local space.
  73262. * @returns the target position
  73263. */
  73264. getTarget(): Vector3;
  73265. /** @hidden */
  73266. _decideIfNeedsToMove(): boolean;
  73267. /** @hidden */
  73268. _updatePosition(): void;
  73269. /** @hidden */
  73270. _checkInputs(): void;
  73271. protected _updateCameraRotationMatrix(): void;
  73272. /**
  73273. * 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)
  73274. * @returns the current camera
  73275. */
  73276. private _rotateUpVectorWithCameraRotationMatrix;
  73277. private _cachedRotationZ;
  73278. private _cachedQuaternionRotationZ;
  73279. /** @hidden */
  73280. _getViewMatrix(): Matrix;
  73281. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73282. /**
  73283. * @hidden
  73284. */
  73285. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73286. /**
  73287. * @hidden
  73288. */
  73289. _updateRigCameras(): void;
  73290. private _getRigCamPositionAndTarget;
  73291. /**
  73292. * Gets the current object class name.
  73293. * @return the class name
  73294. */
  73295. getClassName(): string;
  73296. }
  73297. }
  73298. declare module BABYLON {
  73299. /**
  73300. * Gather the list of keyboard event types as constants.
  73301. */
  73302. export class KeyboardEventTypes {
  73303. /**
  73304. * The keydown event is fired when a key becomes active (pressed).
  73305. */
  73306. static readonly KEYDOWN: number;
  73307. /**
  73308. * The keyup event is fired when a key has been released.
  73309. */
  73310. static readonly KEYUP: number;
  73311. }
  73312. /**
  73313. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73314. */
  73315. export class KeyboardInfo {
  73316. /**
  73317. * Defines the type of event (KeyboardEventTypes)
  73318. */
  73319. type: number;
  73320. /**
  73321. * Defines the related dom event
  73322. */
  73323. event: KeyboardEvent;
  73324. /**
  73325. * Instantiates a new keyboard info.
  73326. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73327. * @param type Defines the type of event (KeyboardEventTypes)
  73328. * @param event Defines the related dom event
  73329. */
  73330. constructor(
  73331. /**
  73332. * Defines the type of event (KeyboardEventTypes)
  73333. */
  73334. type: number,
  73335. /**
  73336. * Defines the related dom event
  73337. */
  73338. event: KeyboardEvent);
  73339. }
  73340. /**
  73341. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73342. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73343. */
  73344. export class KeyboardInfoPre extends KeyboardInfo {
  73345. /**
  73346. * Defines the type of event (KeyboardEventTypes)
  73347. */
  73348. type: number;
  73349. /**
  73350. * Defines the related dom event
  73351. */
  73352. event: KeyboardEvent;
  73353. /**
  73354. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73355. */
  73356. skipOnPointerObservable: boolean;
  73357. /**
  73358. * Instantiates a new keyboard pre info.
  73359. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73360. * @param type Defines the type of event (KeyboardEventTypes)
  73361. * @param event Defines the related dom event
  73362. */
  73363. constructor(
  73364. /**
  73365. * Defines the type of event (KeyboardEventTypes)
  73366. */
  73367. type: number,
  73368. /**
  73369. * Defines the related dom event
  73370. */
  73371. event: KeyboardEvent);
  73372. }
  73373. }
  73374. declare module BABYLON {
  73375. /**
  73376. * Manage the keyboard inputs to control the movement of a free camera.
  73377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73378. */
  73379. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73380. /**
  73381. * Defines the camera the input is attached to.
  73382. */
  73383. camera: FreeCamera;
  73384. /**
  73385. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73386. */
  73387. keysUp: number[];
  73388. /**
  73389. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73390. */
  73391. keysDown: number[];
  73392. /**
  73393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73394. */
  73395. keysLeft: number[];
  73396. /**
  73397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73398. */
  73399. keysRight: number[];
  73400. private _keys;
  73401. private _onCanvasBlurObserver;
  73402. private _onKeyboardObserver;
  73403. private _engine;
  73404. private _scene;
  73405. /**
  73406. * Attach the input controls to a specific dom element to get the input from.
  73407. * @param element Defines the element the controls should be listened from
  73408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73409. */
  73410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73411. /**
  73412. * Detach the current controls from the specified dom element.
  73413. * @param element Defines the element to stop listening the inputs from
  73414. */
  73415. detachControl(element: Nullable<HTMLElement>): void;
  73416. /**
  73417. * Update the current camera state depending on the inputs that have been used this frame.
  73418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73419. */
  73420. checkInputs(): void;
  73421. /**
  73422. * Gets the class name of the current intput.
  73423. * @returns the class name
  73424. */
  73425. getClassName(): string;
  73426. /** @hidden */
  73427. _onLostFocus(): void;
  73428. /**
  73429. * Get the friendly name associated with the input class.
  73430. * @returns the input friendly name
  73431. */
  73432. getSimpleName(): string;
  73433. }
  73434. }
  73435. declare module BABYLON {
  73436. /**
  73437. * Interface describing all the common properties and methods a shadow light needs to implement.
  73438. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73439. * as well as binding the different shadow properties to the effects.
  73440. */
  73441. export interface IShadowLight extends Light {
  73442. /**
  73443. * The light id in the scene (used in scene.findLighById for instance)
  73444. */
  73445. id: string;
  73446. /**
  73447. * The position the shdow will be casted from.
  73448. */
  73449. position: Vector3;
  73450. /**
  73451. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73452. */
  73453. direction: Vector3;
  73454. /**
  73455. * The transformed position. Position of the light in world space taking parenting in account.
  73456. */
  73457. transformedPosition: Vector3;
  73458. /**
  73459. * The transformed direction. Direction of the light in world space taking parenting in account.
  73460. */
  73461. transformedDirection: Vector3;
  73462. /**
  73463. * The friendly name of the light in the scene.
  73464. */
  73465. name: string;
  73466. /**
  73467. * Defines the shadow projection clipping minimum z value.
  73468. */
  73469. shadowMinZ: number;
  73470. /**
  73471. * Defines the shadow projection clipping maximum z value.
  73472. */
  73473. shadowMaxZ: number;
  73474. /**
  73475. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73476. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73477. */
  73478. computeTransformedInformation(): boolean;
  73479. /**
  73480. * Gets the scene the light belongs to.
  73481. * @returns The scene
  73482. */
  73483. getScene(): Scene;
  73484. /**
  73485. * Callback defining a custom Projection Matrix Builder.
  73486. * This can be used to override the default projection matrix computation.
  73487. */
  73488. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73489. /**
  73490. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73491. * @param matrix The materix to updated with the projection information
  73492. * @param viewMatrix The transform matrix of the light
  73493. * @param renderList The list of mesh to render in the map
  73494. * @returns The current light
  73495. */
  73496. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73497. /**
  73498. * Gets the current depth scale used in ESM.
  73499. * @returns The scale
  73500. */
  73501. getDepthScale(): number;
  73502. /**
  73503. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73504. * @returns true if a cube texture needs to be use
  73505. */
  73506. needCube(): boolean;
  73507. /**
  73508. * Detects if the projection matrix requires to be recomputed this frame.
  73509. * @returns true if it requires to be recomputed otherwise, false.
  73510. */
  73511. needProjectionMatrixCompute(): boolean;
  73512. /**
  73513. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73514. */
  73515. forceProjectionMatrixCompute(): void;
  73516. /**
  73517. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73518. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73519. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73520. */
  73521. getShadowDirection(faceIndex?: number): Vector3;
  73522. /**
  73523. * Gets the minZ used for shadow according to both the scene and the light.
  73524. * @param activeCamera The camera we are returning the min for
  73525. * @returns the depth min z
  73526. */
  73527. getDepthMinZ(activeCamera: Camera): number;
  73528. /**
  73529. * Gets the maxZ used for shadow according to both the scene and the light.
  73530. * @param activeCamera The camera we are returning the max for
  73531. * @returns the depth max z
  73532. */
  73533. getDepthMaxZ(activeCamera: Camera): number;
  73534. }
  73535. /**
  73536. * Base implementation IShadowLight
  73537. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73538. */
  73539. export abstract class ShadowLight extends Light implements IShadowLight {
  73540. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73541. protected _position: Vector3;
  73542. protected _setPosition(value: Vector3): void;
  73543. /**
  73544. * Sets the position the shadow will be casted from. Also use as the light position for both
  73545. * point and spot lights.
  73546. */
  73547. /**
  73548. * Sets the position the shadow will be casted from. Also use as the light position for both
  73549. * point and spot lights.
  73550. */
  73551. position: Vector3;
  73552. protected _direction: Vector3;
  73553. protected _setDirection(value: Vector3): void;
  73554. /**
  73555. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73556. * Also use as the light direction on spot and directional lights.
  73557. */
  73558. /**
  73559. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73560. * Also use as the light direction on spot and directional lights.
  73561. */
  73562. direction: Vector3;
  73563. private _shadowMinZ;
  73564. /**
  73565. * Gets the shadow projection clipping minimum z value.
  73566. */
  73567. /**
  73568. * Sets the shadow projection clipping minimum z value.
  73569. */
  73570. shadowMinZ: number;
  73571. private _shadowMaxZ;
  73572. /**
  73573. * Sets the shadow projection clipping maximum z value.
  73574. */
  73575. /**
  73576. * Gets the shadow projection clipping maximum z value.
  73577. */
  73578. shadowMaxZ: number;
  73579. /**
  73580. * Callback defining a custom Projection Matrix Builder.
  73581. * This can be used to override the default projection matrix computation.
  73582. */
  73583. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73584. /**
  73585. * The transformed position. Position of the light in world space taking parenting in account.
  73586. */
  73587. transformedPosition: Vector3;
  73588. /**
  73589. * The transformed direction. Direction of the light in world space taking parenting in account.
  73590. */
  73591. transformedDirection: Vector3;
  73592. private _needProjectionMatrixCompute;
  73593. /**
  73594. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73595. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73596. */
  73597. computeTransformedInformation(): boolean;
  73598. /**
  73599. * Return the depth scale used for the shadow map.
  73600. * @returns the depth scale.
  73601. */
  73602. getDepthScale(): number;
  73603. /**
  73604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73607. */
  73608. getShadowDirection(faceIndex?: number): Vector3;
  73609. /**
  73610. * Returns the ShadowLight absolute position in the World.
  73611. * @returns the position vector in world space
  73612. */
  73613. getAbsolutePosition(): Vector3;
  73614. /**
  73615. * Sets the ShadowLight direction toward the passed target.
  73616. * @param target The point to target in local space
  73617. * @returns the updated ShadowLight direction
  73618. */
  73619. setDirectionToTarget(target: Vector3): Vector3;
  73620. /**
  73621. * Returns the light rotation in euler definition.
  73622. * @returns the x y z rotation in local space.
  73623. */
  73624. getRotation(): Vector3;
  73625. /**
  73626. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73627. * @returns true if a cube texture needs to be use
  73628. */
  73629. needCube(): boolean;
  73630. /**
  73631. * Detects if the projection matrix requires to be recomputed this frame.
  73632. * @returns true if it requires to be recomputed otherwise, false.
  73633. */
  73634. needProjectionMatrixCompute(): boolean;
  73635. /**
  73636. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73637. */
  73638. forceProjectionMatrixCompute(): void;
  73639. /** @hidden */
  73640. _initCache(): void;
  73641. /** @hidden */
  73642. _isSynchronized(): boolean;
  73643. /**
  73644. * Computes the world matrix of the node
  73645. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73646. * @returns the world matrix
  73647. */
  73648. computeWorldMatrix(force?: boolean): Matrix;
  73649. /**
  73650. * Gets the minZ used for shadow according to both the scene and the light.
  73651. * @param activeCamera The camera we are returning the min for
  73652. * @returns the depth min z
  73653. */
  73654. getDepthMinZ(activeCamera: Camera): number;
  73655. /**
  73656. * Gets the maxZ used for shadow according to both the scene and the light.
  73657. * @param activeCamera The camera we are returning the max for
  73658. * @returns the depth max z
  73659. */
  73660. getDepthMaxZ(activeCamera: Camera): number;
  73661. /**
  73662. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73663. * @param matrix The materix to updated with the projection information
  73664. * @param viewMatrix The transform matrix of the light
  73665. * @param renderList The list of mesh to render in the map
  73666. * @returns The current light
  73667. */
  73668. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73669. }
  73670. }
  73671. declare module BABYLON {
  73672. /**
  73673. * "Static Class" containing the most commonly used helper while dealing with material for
  73674. * rendering purpose.
  73675. *
  73676. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73677. *
  73678. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73679. */
  73680. export class MaterialHelper {
  73681. /**
  73682. * Bind the current view position to an effect.
  73683. * @param effect The effect to be bound
  73684. * @param scene The scene the eyes position is used from
  73685. */
  73686. static BindEyePosition(effect: Effect, scene: Scene): void;
  73687. /**
  73688. * Helps preparing the defines values about the UVs in used in the effect.
  73689. * UVs are shared as much as we can accross channels in the shaders.
  73690. * @param texture The texture we are preparing the UVs for
  73691. * @param defines The defines to update
  73692. * @param key The channel key "diffuse", "specular"... used in the shader
  73693. */
  73694. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73695. /**
  73696. * Binds a texture matrix value to its corrsponding uniform
  73697. * @param texture The texture to bind the matrix for
  73698. * @param uniformBuffer The uniform buffer receivin the data
  73699. * @param key The channel key "diffuse", "specular"... used in the shader
  73700. */
  73701. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73702. /**
  73703. * Gets the current status of the fog (should it be enabled?)
  73704. * @param mesh defines the mesh to evaluate for fog support
  73705. * @param scene defines the hosting scene
  73706. * @returns true if fog must be enabled
  73707. */
  73708. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73709. /**
  73710. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73711. * @param mesh defines the current mesh
  73712. * @param scene defines the current scene
  73713. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73714. * @param pointsCloud defines if point cloud rendering has to be turned on
  73715. * @param fogEnabled defines if fog has to be turned on
  73716. * @param alphaTest defines if alpha testing has to be turned on
  73717. * @param defines defines the current list of defines
  73718. */
  73719. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73720. /**
  73721. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73722. * @param scene defines the current scene
  73723. * @param engine defines the current engine
  73724. * @param defines specifies the list of active defines
  73725. * @param useInstances defines if instances have to be turned on
  73726. * @param useClipPlane defines if clip plane have to be turned on
  73727. */
  73728. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73729. /**
  73730. * Prepares the defines for bones
  73731. * @param mesh The mesh containing the geometry data we will draw
  73732. * @param defines The defines to update
  73733. */
  73734. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73735. /**
  73736. * Prepares the defines for morph targets
  73737. * @param mesh The mesh containing the geometry data we will draw
  73738. * @param defines The defines to update
  73739. */
  73740. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73741. /**
  73742. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73743. * @param mesh The mesh containing the geometry data we will draw
  73744. * @param defines The defines to update
  73745. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73746. * @param useBones Precise whether bones should be used or not (override mesh info)
  73747. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73748. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73749. * @returns false if defines are considered not dirty and have not been checked
  73750. */
  73751. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73752. /**
  73753. * Prepares the defines related to multiview
  73754. * @param scene The scene we are intending to draw
  73755. * @param defines The defines to update
  73756. */
  73757. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73758. /**
  73759. * Prepares the defines related to the light information passed in parameter
  73760. * @param scene The scene we are intending to draw
  73761. * @param mesh The mesh the effect is compiling for
  73762. * @param light The light the effect is compiling for
  73763. * @param lightIndex The index of the light
  73764. * @param defines The defines to update
  73765. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73766. * @param state Defines the current state regarding what is needed (normals, etc...)
  73767. */
  73768. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73769. needNormals: boolean;
  73770. needRebuild: boolean;
  73771. shadowEnabled: boolean;
  73772. specularEnabled: boolean;
  73773. lightmapMode: boolean;
  73774. }): void;
  73775. /**
  73776. * Prepares the defines related to the light information passed in parameter
  73777. * @param scene The scene we are intending to draw
  73778. * @param mesh The mesh the effect is compiling for
  73779. * @param defines The defines to update
  73780. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73781. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73782. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73783. * @returns true if normals will be required for the rest of the effect
  73784. */
  73785. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73786. /**
  73787. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73788. * @param lightIndex defines the light index
  73789. * @param uniformsList The uniform list
  73790. * @param samplersList The sampler list
  73791. * @param projectedLightTexture defines if projected texture must be used
  73792. * @param uniformBuffersList defines an optional list of uniform buffers
  73793. */
  73794. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73795. /**
  73796. * Prepares the uniforms and samplers list to be used in the effect
  73797. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73798. * @param samplersList The sampler list
  73799. * @param defines The defines helping in the list generation
  73800. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73801. */
  73802. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73803. /**
  73804. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73805. * @param defines The defines to update while falling back
  73806. * @param fallbacks The authorized effect fallbacks
  73807. * @param maxSimultaneousLights The maximum number of lights allowed
  73808. * @param rank the current rank of the Effect
  73809. * @returns The newly affected rank
  73810. */
  73811. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73812. private static _TmpMorphInfluencers;
  73813. /**
  73814. * Prepares the list of attributes required for morph targets according to the effect defines.
  73815. * @param attribs The current list of supported attribs
  73816. * @param mesh The mesh to prepare the morph targets attributes for
  73817. * @param influencers The number of influencers
  73818. */
  73819. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73820. /**
  73821. * Prepares the list of attributes required for morph targets according to the effect defines.
  73822. * @param attribs The current list of supported attribs
  73823. * @param mesh The mesh to prepare the morph targets attributes for
  73824. * @param defines The current Defines of the effect
  73825. */
  73826. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73827. /**
  73828. * Prepares the list of attributes required for bones according to the effect defines.
  73829. * @param attribs The current list of supported attribs
  73830. * @param mesh The mesh to prepare the bones attributes for
  73831. * @param defines The current Defines of the effect
  73832. * @param fallbacks The current efffect fallback strategy
  73833. */
  73834. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73835. /**
  73836. * Check and prepare the list of attributes required for instances according to the effect defines.
  73837. * @param attribs The current list of supported attribs
  73838. * @param defines The current MaterialDefines of the effect
  73839. */
  73840. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73841. /**
  73842. * Add the list of attributes required for instances to the attribs array.
  73843. * @param attribs The current list of supported attribs
  73844. */
  73845. static PushAttributesForInstances(attribs: string[]): void;
  73846. /**
  73847. * Binds the light shadow information to the effect for the given mesh.
  73848. * @param light The light containing the generator
  73849. * @param scene The scene the lights belongs to
  73850. * @param mesh The mesh we are binding the information to render
  73851. * @param lightIndex The light index in the effect used to render the mesh
  73852. * @param effect The effect we are binding the data to
  73853. */
  73854. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73855. /**
  73856. * Binds the light information to the effect.
  73857. * @param light The light containing the generator
  73858. * @param effect The effect we are binding the data to
  73859. * @param lightIndex The light index in the effect used to render
  73860. */
  73861. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73862. /**
  73863. * Binds the lights information from the scene to the effect for the given mesh.
  73864. * @param light Light to bind
  73865. * @param lightIndex Light index
  73866. * @param scene The scene where the light belongs to
  73867. * @param mesh The mesh we are binding the information to render
  73868. * @param effect The effect we are binding the data to
  73869. * @param useSpecular Defines if specular is supported
  73870. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73871. */
  73872. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73873. /**
  73874. * Binds the lights information from the scene to the effect for the given mesh.
  73875. * @param scene The scene the lights belongs to
  73876. * @param mesh The mesh we are binding the information to render
  73877. * @param effect The effect we are binding the data to
  73878. * @param defines The generated defines for the effect
  73879. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73880. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73881. */
  73882. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73883. private static _tempFogColor;
  73884. /**
  73885. * Binds the fog information from the scene to the effect for the given mesh.
  73886. * @param scene The scene the lights belongs to
  73887. * @param mesh The mesh we are binding the information to render
  73888. * @param effect The effect we are binding the data to
  73889. * @param linearSpace Defines if the fog effect is applied in linear space
  73890. */
  73891. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73892. /**
  73893. * Binds the bones information from the mesh to the effect.
  73894. * @param mesh The mesh we are binding the information to render
  73895. * @param effect The effect we are binding the data to
  73896. */
  73897. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73898. /**
  73899. * Binds the morph targets information from the mesh to the effect.
  73900. * @param abstractMesh The mesh we are binding the information to render
  73901. * @param effect The effect we are binding the data to
  73902. */
  73903. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73904. /**
  73905. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73906. * @param defines The generated defines used in the effect
  73907. * @param effect The effect we are binding the data to
  73908. * @param scene The scene we are willing to render with logarithmic scale for
  73909. */
  73910. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73911. /**
  73912. * Binds the clip plane information from the scene to the effect.
  73913. * @param scene The scene the clip plane information are extracted from
  73914. * @param effect The effect we are binding the data to
  73915. */
  73916. static BindClipPlane(effect: Effect, scene: Scene): void;
  73917. }
  73918. }
  73919. declare module BABYLON {
  73920. /** @hidden */
  73921. export var packingFunctions: {
  73922. name: string;
  73923. shader: string;
  73924. };
  73925. }
  73926. declare module BABYLON {
  73927. /** @hidden */
  73928. export var shadowMapPixelShader: {
  73929. name: string;
  73930. shader: string;
  73931. };
  73932. }
  73933. declare module BABYLON {
  73934. /** @hidden */
  73935. export var bonesDeclaration: {
  73936. name: string;
  73937. shader: string;
  73938. };
  73939. }
  73940. declare module BABYLON {
  73941. /** @hidden */
  73942. export var morphTargetsVertexGlobalDeclaration: {
  73943. name: string;
  73944. shader: string;
  73945. };
  73946. }
  73947. declare module BABYLON {
  73948. /** @hidden */
  73949. export var morphTargetsVertexDeclaration: {
  73950. name: string;
  73951. shader: string;
  73952. };
  73953. }
  73954. declare module BABYLON {
  73955. /** @hidden */
  73956. export var instancesDeclaration: {
  73957. name: string;
  73958. shader: string;
  73959. };
  73960. }
  73961. declare module BABYLON {
  73962. /** @hidden */
  73963. export var helperFunctions: {
  73964. name: string;
  73965. shader: string;
  73966. };
  73967. }
  73968. declare module BABYLON {
  73969. /** @hidden */
  73970. export var morphTargetsVertex: {
  73971. name: string;
  73972. shader: string;
  73973. };
  73974. }
  73975. declare module BABYLON {
  73976. /** @hidden */
  73977. export var instancesVertex: {
  73978. name: string;
  73979. shader: string;
  73980. };
  73981. }
  73982. declare module BABYLON {
  73983. /** @hidden */
  73984. export var bonesVertex: {
  73985. name: string;
  73986. shader: string;
  73987. };
  73988. }
  73989. declare module BABYLON {
  73990. /** @hidden */
  73991. export var shadowMapVertexShader: {
  73992. name: string;
  73993. shader: string;
  73994. };
  73995. }
  73996. declare module BABYLON {
  73997. /** @hidden */
  73998. export var depthBoxBlurPixelShader: {
  73999. name: string;
  74000. shader: string;
  74001. };
  74002. }
  74003. declare module BABYLON {
  74004. /**
  74005. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74006. */
  74007. export interface ICustomShaderOptions {
  74008. /**
  74009. * Gets or sets the custom shader name to use
  74010. */
  74011. shaderName: string;
  74012. /**
  74013. * The list of attribute names used in the shader
  74014. */
  74015. attributes?: string[];
  74016. /**
  74017. * The list of unifrom names used in the shader
  74018. */
  74019. uniforms?: string[];
  74020. /**
  74021. * The list of sampler names used in the shader
  74022. */
  74023. samplers?: string[];
  74024. /**
  74025. * The list of defines used in the shader
  74026. */
  74027. defines?: string[];
  74028. }
  74029. /**
  74030. * Interface to implement to create a shadow generator compatible with BJS.
  74031. */
  74032. export interface IShadowGenerator {
  74033. /**
  74034. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74035. * @returns The render target texture if present otherwise, null
  74036. */
  74037. getShadowMap(): Nullable<RenderTargetTexture>;
  74038. /**
  74039. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74040. * @returns The render target texture if the shadow map is present otherwise, null
  74041. */
  74042. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74043. /**
  74044. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74045. * @param subMesh The submesh we want to render in the shadow map
  74046. * @param useInstances Defines wether will draw in the map using instances
  74047. * @returns true if ready otherwise, false
  74048. */
  74049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74050. /**
  74051. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74052. * @param defines Defines of the material we want to update
  74053. * @param lightIndex Index of the light in the enabled light list of the material
  74054. */
  74055. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74056. /**
  74057. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74058. * defined in the generator but impacting the effect).
  74059. * It implies the unifroms available on the materials are the standard BJS ones.
  74060. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74061. * @param effect The effect we are binfing the information for
  74062. */
  74063. bindShadowLight(lightIndex: string, effect: Effect): void;
  74064. /**
  74065. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74066. * (eq to shadow prjection matrix * light transform matrix)
  74067. * @returns The transform matrix used to create the shadow map
  74068. */
  74069. getTransformMatrix(): Matrix;
  74070. /**
  74071. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74072. * Cube and 2D textures for instance.
  74073. */
  74074. recreateShadowMap(): void;
  74075. /**
  74076. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74077. * @param onCompiled Callback triggered at the and of the effects compilation
  74078. * @param options Sets of optional options forcing the compilation with different modes
  74079. */
  74080. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74081. useInstances: boolean;
  74082. }>): void;
  74083. /**
  74084. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74085. * @param options Sets of optional options forcing the compilation with different modes
  74086. * @returns A promise that resolves when the compilation completes
  74087. */
  74088. forceCompilationAsync(options?: Partial<{
  74089. useInstances: boolean;
  74090. }>): Promise<void>;
  74091. /**
  74092. * Serializes the shadow generator setup to a json object.
  74093. * @returns The serialized JSON object
  74094. */
  74095. serialize(): any;
  74096. /**
  74097. * Disposes the Shadow map and related Textures and effects.
  74098. */
  74099. dispose(): void;
  74100. }
  74101. /**
  74102. * Default implementation IShadowGenerator.
  74103. * This is the main object responsible of generating shadows in the framework.
  74104. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74105. */
  74106. export class ShadowGenerator implements IShadowGenerator {
  74107. /**
  74108. * Shadow generator mode None: no filtering applied.
  74109. */
  74110. static readonly FILTER_NONE: number;
  74111. /**
  74112. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74113. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74114. */
  74115. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74116. /**
  74117. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74118. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74119. */
  74120. static readonly FILTER_POISSONSAMPLING: number;
  74121. /**
  74122. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74123. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74124. */
  74125. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74126. /**
  74127. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74128. * edge artifacts on steep falloff.
  74129. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74130. */
  74131. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74132. /**
  74133. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74134. * edge artifacts on steep falloff.
  74135. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74136. */
  74137. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74138. /**
  74139. * Shadow generator mode PCF: Percentage Closer Filtering
  74140. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74141. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74142. */
  74143. static readonly FILTER_PCF: number;
  74144. /**
  74145. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74146. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74147. * Contact Hardening
  74148. */
  74149. static readonly FILTER_PCSS: number;
  74150. /**
  74151. * Reserved for PCF and PCSS
  74152. * Highest Quality.
  74153. *
  74154. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74155. *
  74156. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74157. */
  74158. static readonly QUALITY_HIGH: number;
  74159. /**
  74160. * Reserved for PCF and PCSS
  74161. * Good tradeoff for quality/perf cross devices
  74162. *
  74163. * Execute PCF on a 3*3 kernel.
  74164. *
  74165. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74166. */
  74167. static readonly QUALITY_MEDIUM: number;
  74168. /**
  74169. * Reserved for PCF and PCSS
  74170. * The lowest quality but the fastest.
  74171. *
  74172. * Execute PCF on a 1*1 kernel.
  74173. *
  74174. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74175. */
  74176. static readonly QUALITY_LOW: number;
  74177. /** Gets or sets the custom shader name to use */
  74178. customShaderOptions: ICustomShaderOptions;
  74179. /**
  74180. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74181. */
  74182. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74183. /**
  74184. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74185. */
  74186. onAfterShadowMapRenderObservable: Observable<Effect>;
  74187. /**
  74188. * Observable triggered before a mesh is rendered in the shadow map.
  74189. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74190. */
  74191. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74192. /**
  74193. * Observable triggered after a mesh is rendered in the shadow map.
  74194. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74195. */
  74196. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74197. private _bias;
  74198. /**
  74199. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74200. */
  74201. /**
  74202. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74203. */
  74204. bias: number;
  74205. private _normalBias;
  74206. /**
  74207. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74208. */
  74209. /**
  74210. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74211. */
  74212. normalBias: number;
  74213. private _blurBoxOffset;
  74214. /**
  74215. * Gets the blur box offset: offset applied during the blur pass.
  74216. * Only useful if useKernelBlur = false
  74217. */
  74218. /**
  74219. * Sets the blur box offset: offset applied during the blur pass.
  74220. * Only useful if useKernelBlur = false
  74221. */
  74222. blurBoxOffset: number;
  74223. private _blurScale;
  74224. /**
  74225. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74226. * 2 means half of the size.
  74227. */
  74228. /**
  74229. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74230. * 2 means half of the size.
  74231. */
  74232. blurScale: number;
  74233. private _blurKernel;
  74234. /**
  74235. * Gets the blur kernel: kernel size of the blur pass.
  74236. * Only useful if useKernelBlur = true
  74237. */
  74238. /**
  74239. * Sets the blur kernel: kernel size of the blur pass.
  74240. * Only useful if useKernelBlur = true
  74241. */
  74242. blurKernel: number;
  74243. private _useKernelBlur;
  74244. /**
  74245. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74246. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74247. */
  74248. /**
  74249. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74250. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74251. */
  74252. useKernelBlur: boolean;
  74253. private _depthScale;
  74254. /**
  74255. * Gets the depth scale used in ESM mode.
  74256. */
  74257. /**
  74258. * Sets the depth scale used in ESM mode.
  74259. * This can override the scale stored on the light.
  74260. */
  74261. depthScale: number;
  74262. private _filter;
  74263. /**
  74264. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74265. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74266. */
  74267. /**
  74268. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74269. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74270. */
  74271. filter: number;
  74272. /**
  74273. * Gets if the current filter is set to Poisson Sampling.
  74274. */
  74275. /**
  74276. * Sets the current filter to Poisson Sampling.
  74277. */
  74278. usePoissonSampling: boolean;
  74279. /**
  74280. * Gets if the current filter is set to ESM.
  74281. */
  74282. /**
  74283. * Sets the current filter is to ESM.
  74284. */
  74285. useExponentialShadowMap: boolean;
  74286. /**
  74287. * Gets if the current filter is set to filtered ESM.
  74288. */
  74289. /**
  74290. * Gets if the current filter is set to filtered ESM.
  74291. */
  74292. useBlurExponentialShadowMap: boolean;
  74293. /**
  74294. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74295. * exponential to prevent steep falloff artifacts).
  74296. */
  74297. /**
  74298. * Sets the current filter to "close ESM" (using the inverse of the
  74299. * exponential to prevent steep falloff artifacts).
  74300. */
  74301. useCloseExponentialShadowMap: boolean;
  74302. /**
  74303. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74304. * exponential to prevent steep falloff artifacts).
  74305. */
  74306. /**
  74307. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74308. * exponential to prevent steep falloff artifacts).
  74309. */
  74310. useBlurCloseExponentialShadowMap: boolean;
  74311. /**
  74312. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74313. */
  74314. /**
  74315. * Sets the current filter to "PCF" (percentage closer filtering).
  74316. */
  74317. usePercentageCloserFiltering: boolean;
  74318. private _filteringQuality;
  74319. /**
  74320. * Gets the PCF or PCSS Quality.
  74321. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74322. */
  74323. /**
  74324. * Sets the PCF or PCSS Quality.
  74325. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74326. */
  74327. filteringQuality: number;
  74328. /**
  74329. * Gets if the current filter is set to "PCSS" (contact hardening).
  74330. */
  74331. /**
  74332. * Sets the current filter to "PCSS" (contact hardening).
  74333. */
  74334. useContactHardeningShadow: boolean;
  74335. private _contactHardeningLightSizeUVRatio;
  74336. /**
  74337. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74338. * Using a ratio helps keeping shape stability independently of the map size.
  74339. *
  74340. * It does not account for the light projection as it was having too much
  74341. * instability during the light setup or during light position changes.
  74342. *
  74343. * Only valid if useContactHardeningShadow is true.
  74344. */
  74345. /**
  74346. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74347. * Using a ratio helps keeping shape stability independently of the map size.
  74348. *
  74349. * It does not account for the light projection as it was having too much
  74350. * instability during the light setup or during light position changes.
  74351. *
  74352. * Only valid if useContactHardeningShadow is true.
  74353. */
  74354. contactHardeningLightSizeUVRatio: number;
  74355. private _darkness;
  74356. /** Gets or sets the actual darkness of a shadow */
  74357. darkness: number;
  74358. /**
  74359. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74360. * 0 means strongest and 1 would means no shadow.
  74361. * @returns the darkness.
  74362. */
  74363. getDarkness(): number;
  74364. /**
  74365. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74366. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74367. * @returns the shadow generator allowing fluent coding.
  74368. */
  74369. setDarkness(darkness: number): ShadowGenerator;
  74370. private _transparencyShadow;
  74371. /** Gets or sets the ability to have transparent shadow */
  74372. transparencyShadow: boolean;
  74373. /**
  74374. * Sets the ability to have transparent shadow (boolean).
  74375. * @param transparent True if transparent else False
  74376. * @returns the shadow generator allowing fluent coding
  74377. */
  74378. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74379. private _shadowMap;
  74380. private _shadowMap2;
  74381. /**
  74382. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74383. * @returns The render target texture if present otherwise, null
  74384. */
  74385. getShadowMap(): Nullable<RenderTargetTexture>;
  74386. /**
  74387. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74388. * @returns The render target texture if the shadow map is present otherwise, null
  74389. */
  74390. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74391. /**
  74392. * Gets the class name of that object
  74393. * @returns "ShadowGenerator"
  74394. */
  74395. getClassName(): string;
  74396. /**
  74397. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74398. * @param mesh Mesh to add
  74399. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74400. * @returns the Shadow Generator itself
  74401. */
  74402. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74403. /**
  74404. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74405. * @param mesh Mesh to remove
  74406. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74407. * @returns the Shadow Generator itself
  74408. */
  74409. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74410. /**
  74411. * Controls the extent to which the shadows fade out at the edge of the frustum
  74412. * Used only by directionals and spots
  74413. */
  74414. frustumEdgeFalloff: number;
  74415. private _light;
  74416. /**
  74417. * Returns the associated light object.
  74418. * @returns the light generating the shadow
  74419. */
  74420. getLight(): IShadowLight;
  74421. /**
  74422. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74423. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74424. * It might on the other hand introduce peter panning.
  74425. */
  74426. forceBackFacesOnly: boolean;
  74427. private _scene;
  74428. private _lightDirection;
  74429. private _effect;
  74430. private _viewMatrix;
  74431. private _projectionMatrix;
  74432. private _transformMatrix;
  74433. private _cachedPosition;
  74434. private _cachedDirection;
  74435. private _cachedDefines;
  74436. private _currentRenderID;
  74437. private _boxBlurPostprocess;
  74438. private _kernelBlurXPostprocess;
  74439. private _kernelBlurYPostprocess;
  74440. private _blurPostProcesses;
  74441. private _mapSize;
  74442. private _currentFaceIndex;
  74443. private _currentFaceIndexCache;
  74444. private _textureType;
  74445. private _defaultTextureMatrix;
  74446. /** @hidden */
  74447. static _SceneComponentInitialization: (scene: Scene) => void;
  74448. /**
  74449. * Creates a ShadowGenerator object.
  74450. * A ShadowGenerator is the required tool to use the shadows.
  74451. * Each light casting shadows needs to use its own ShadowGenerator.
  74452. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74453. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74454. * @param light The light object generating the shadows.
  74455. * @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.
  74456. */
  74457. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74458. private _initializeGenerator;
  74459. private _initializeShadowMap;
  74460. private _initializeBlurRTTAndPostProcesses;
  74461. private _renderForShadowMap;
  74462. private _renderSubMeshForShadowMap;
  74463. private _applyFilterValues;
  74464. /**
  74465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74466. * @param onCompiled Callback triggered at the and of the effects compilation
  74467. * @param options Sets of optional options forcing the compilation with different modes
  74468. */
  74469. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74470. useInstances: boolean;
  74471. }>): void;
  74472. /**
  74473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74474. * @param options Sets of optional options forcing the compilation with different modes
  74475. * @returns A promise that resolves when the compilation completes
  74476. */
  74477. forceCompilationAsync(options?: Partial<{
  74478. useInstances: boolean;
  74479. }>): Promise<void>;
  74480. /**
  74481. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74482. * @param subMesh The submesh we want to render in the shadow map
  74483. * @param useInstances Defines wether will draw in the map using instances
  74484. * @returns true if ready otherwise, false
  74485. */
  74486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74487. /**
  74488. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74489. * @param defines Defines of the material we want to update
  74490. * @param lightIndex Index of the light in the enabled light list of the material
  74491. */
  74492. prepareDefines(defines: any, lightIndex: number): void;
  74493. /**
  74494. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74495. * defined in the generator but impacting the effect).
  74496. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74497. * @param effect The effect we are binfing the information for
  74498. */
  74499. bindShadowLight(lightIndex: string, effect: Effect): void;
  74500. /**
  74501. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74502. * (eq to shadow prjection matrix * light transform matrix)
  74503. * @returns The transform matrix used to create the shadow map
  74504. */
  74505. getTransformMatrix(): Matrix;
  74506. /**
  74507. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74508. * Cube and 2D textures for instance.
  74509. */
  74510. recreateShadowMap(): void;
  74511. private _disposeBlurPostProcesses;
  74512. private _disposeRTTandPostProcesses;
  74513. /**
  74514. * Disposes the ShadowGenerator.
  74515. * Returns nothing.
  74516. */
  74517. dispose(): void;
  74518. /**
  74519. * Serializes the shadow generator setup to a json object.
  74520. * @returns The serialized JSON object
  74521. */
  74522. serialize(): any;
  74523. /**
  74524. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74525. * @param parsedShadowGenerator The JSON object to parse
  74526. * @param scene The scene to create the shadow map for
  74527. * @returns The parsed shadow generator
  74528. */
  74529. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74530. }
  74531. }
  74532. declare module BABYLON {
  74533. /**
  74534. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74535. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74536. * 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.
  74537. */
  74538. export abstract class Light extends Node {
  74539. /**
  74540. * Falloff Default: light is falling off following the material specification:
  74541. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74542. */
  74543. static readonly FALLOFF_DEFAULT: number;
  74544. /**
  74545. * Falloff Physical: light is falling off following the inverse squared distance law.
  74546. */
  74547. static readonly FALLOFF_PHYSICAL: number;
  74548. /**
  74549. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74550. * to enhance interoperability with other engines.
  74551. */
  74552. static readonly FALLOFF_GLTF: number;
  74553. /**
  74554. * Falloff Standard: light is falling off like in the standard material
  74555. * to enhance interoperability with other materials.
  74556. */
  74557. static readonly FALLOFF_STANDARD: number;
  74558. /**
  74559. * If every light affecting the material is in this lightmapMode,
  74560. * material.lightmapTexture adds or multiplies
  74561. * (depends on material.useLightmapAsShadowmap)
  74562. * after every other light calculations.
  74563. */
  74564. static readonly LIGHTMAP_DEFAULT: number;
  74565. /**
  74566. * material.lightmapTexture as only diffuse lighting from this light
  74567. * adds only specular lighting from this light
  74568. * adds dynamic shadows
  74569. */
  74570. static readonly LIGHTMAP_SPECULAR: number;
  74571. /**
  74572. * material.lightmapTexture as only lighting
  74573. * no light calculation from this light
  74574. * only adds dynamic shadows from this light
  74575. */
  74576. static readonly LIGHTMAP_SHADOWSONLY: number;
  74577. /**
  74578. * Each light type uses the default quantity according to its type:
  74579. * point/spot lights use luminous intensity
  74580. * directional lights use illuminance
  74581. */
  74582. static readonly INTENSITYMODE_AUTOMATIC: number;
  74583. /**
  74584. * lumen (lm)
  74585. */
  74586. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74587. /**
  74588. * candela (lm/sr)
  74589. */
  74590. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74591. /**
  74592. * lux (lm/m^2)
  74593. */
  74594. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74595. /**
  74596. * nit (cd/m^2)
  74597. */
  74598. static readonly INTENSITYMODE_LUMINANCE: number;
  74599. /**
  74600. * Light type const id of the point light.
  74601. */
  74602. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74603. /**
  74604. * Light type const id of the directional light.
  74605. */
  74606. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74607. /**
  74608. * Light type const id of the spot light.
  74609. */
  74610. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74611. /**
  74612. * Light type const id of the hemispheric light.
  74613. */
  74614. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74615. /**
  74616. * Diffuse gives the basic color to an object.
  74617. */
  74618. diffuse: Color3;
  74619. /**
  74620. * Specular produces a highlight color on an object.
  74621. * Note: This is note affecting PBR materials.
  74622. */
  74623. specular: Color3;
  74624. /**
  74625. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74626. * falling off base on range or angle.
  74627. * This can be set to any values in Light.FALLOFF_x.
  74628. *
  74629. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74630. * other types of materials.
  74631. */
  74632. falloffType: number;
  74633. /**
  74634. * Strength of the light.
  74635. * Note: By default it is define in the framework own unit.
  74636. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74637. */
  74638. intensity: number;
  74639. private _range;
  74640. protected _inverseSquaredRange: number;
  74641. /**
  74642. * Defines how far from the source the light is impacting in scene units.
  74643. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74644. */
  74645. /**
  74646. * Defines how far from the source the light is impacting in scene units.
  74647. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74648. */
  74649. range: number;
  74650. /**
  74651. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74652. * of light.
  74653. */
  74654. private _photometricScale;
  74655. private _intensityMode;
  74656. /**
  74657. * Gets the photometric scale used to interpret the intensity.
  74658. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74659. */
  74660. /**
  74661. * Sets the photometric scale used to interpret the intensity.
  74662. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74663. */
  74664. intensityMode: number;
  74665. private _radius;
  74666. /**
  74667. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74668. */
  74669. /**
  74670. * sets the light radius used by PBR Materials to simulate soft area lights.
  74671. */
  74672. radius: number;
  74673. private _renderPriority;
  74674. /**
  74675. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74676. * exceeding the number allowed of the materials.
  74677. */
  74678. renderPriority: number;
  74679. private _shadowEnabled;
  74680. /**
  74681. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74682. * the current shadow generator.
  74683. */
  74684. /**
  74685. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74686. * the current shadow generator.
  74687. */
  74688. shadowEnabled: boolean;
  74689. private _includedOnlyMeshes;
  74690. /**
  74691. * Gets the only meshes impacted by this light.
  74692. */
  74693. /**
  74694. * Sets the only meshes impacted by this light.
  74695. */
  74696. includedOnlyMeshes: AbstractMesh[];
  74697. private _excludedMeshes;
  74698. /**
  74699. * Gets the meshes not impacted by this light.
  74700. */
  74701. /**
  74702. * Sets the meshes not impacted by this light.
  74703. */
  74704. excludedMeshes: AbstractMesh[];
  74705. private _excludeWithLayerMask;
  74706. /**
  74707. * Gets the layer id use to find what meshes are not impacted by the light.
  74708. * Inactive if 0
  74709. */
  74710. /**
  74711. * Sets the layer id use to find what meshes are not impacted by the light.
  74712. * Inactive if 0
  74713. */
  74714. excludeWithLayerMask: number;
  74715. private _includeOnlyWithLayerMask;
  74716. /**
  74717. * Gets the layer id use to find what meshes are impacted by the light.
  74718. * Inactive if 0
  74719. */
  74720. /**
  74721. * Sets the layer id use to find what meshes are impacted by the light.
  74722. * Inactive if 0
  74723. */
  74724. includeOnlyWithLayerMask: number;
  74725. private _lightmapMode;
  74726. /**
  74727. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74728. */
  74729. /**
  74730. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74731. */
  74732. lightmapMode: number;
  74733. /**
  74734. * Shadow generator associted to the light.
  74735. * @hidden Internal use only.
  74736. */
  74737. _shadowGenerator: Nullable<IShadowGenerator>;
  74738. /**
  74739. * @hidden Internal use only.
  74740. */
  74741. _excludedMeshesIds: string[];
  74742. /**
  74743. * @hidden Internal use only.
  74744. */
  74745. _includedOnlyMeshesIds: string[];
  74746. /**
  74747. * The current light unifom buffer.
  74748. * @hidden Internal use only.
  74749. */
  74750. _uniformBuffer: UniformBuffer;
  74751. /**
  74752. * Creates a Light object in the scene.
  74753. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74754. * @param name The firendly name of the light
  74755. * @param scene The scene the light belongs too
  74756. */
  74757. constructor(name: string, scene: Scene);
  74758. protected abstract _buildUniformLayout(): void;
  74759. /**
  74760. * Sets the passed Effect "effect" with the Light information.
  74761. * @param effect The effect to update
  74762. * @param lightIndex The index of the light in the effect to update
  74763. * @returns The light
  74764. */
  74765. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74766. /**
  74767. * Returns the string "Light".
  74768. * @returns the class name
  74769. */
  74770. getClassName(): string;
  74771. /** @hidden */
  74772. readonly _isLight: boolean;
  74773. /**
  74774. * Converts the light information to a readable string for debug purpose.
  74775. * @param fullDetails Supports for multiple levels of logging within scene loading
  74776. * @returns the human readable light info
  74777. */
  74778. toString(fullDetails?: boolean): string;
  74779. /** @hidden */
  74780. protected _syncParentEnabledState(): void;
  74781. /**
  74782. * Set the enabled state of this node.
  74783. * @param value - the new enabled state
  74784. */
  74785. setEnabled(value: boolean): void;
  74786. /**
  74787. * Returns the Light associated shadow generator if any.
  74788. * @return the associated shadow generator.
  74789. */
  74790. getShadowGenerator(): Nullable<IShadowGenerator>;
  74791. /**
  74792. * Returns a Vector3, the absolute light position in the World.
  74793. * @returns the world space position of the light
  74794. */
  74795. getAbsolutePosition(): Vector3;
  74796. /**
  74797. * Specifies if the light will affect the passed mesh.
  74798. * @param mesh The mesh to test against the light
  74799. * @return true the mesh is affected otherwise, false.
  74800. */
  74801. canAffectMesh(mesh: AbstractMesh): boolean;
  74802. /**
  74803. * Sort function to order lights for rendering.
  74804. * @param a First Light object to compare to second.
  74805. * @param b Second Light object to compare first.
  74806. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74807. */
  74808. static CompareLightsPriority(a: Light, b: Light): number;
  74809. /**
  74810. * Releases resources associated with this node.
  74811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74813. */
  74814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74815. /**
  74816. * Returns the light type ID (integer).
  74817. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74818. */
  74819. getTypeID(): number;
  74820. /**
  74821. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74822. * @returns the scaled intensity in intensity mode unit
  74823. */
  74824. getScaledIntensity(): number;
  74825. /**
  74826. * Returns a new Light object, named "name", from the current one.
  74827. * @param name The name of the cloned light
  74828. * @returns the new created light
  74829. */
  74830. clone(name: string): Nullable<Light>;
  74831. /**
  74832. * Serializes the current light into a Serialization object.
  74833. * @returns the serialized object.
  74834. */
  74835. serialize(): any;
  74836. /**
  74837. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74838. * This new light is named "name" and added to the passed scene.
  74839. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74840. * @param name The friendly name of the light
  74841. * @param scene The scene the new light will belong to
  74842. * @returns the constructor function
  74843. */
  74844. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74845. /**
  74846. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74847. * @param parsedLight The JSON representation of the light
  74848. * @param scene The scene to create the parsed light in
  74849. * @returns the created light after parsing
  74850. */
  74851. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74852. private _hookArrayForExcluded;
  74853. private _hookArrayForIncludedOnly;
  74854. private _resyncMeshes;
  74855. /**
  74856. * Forces the meshes to update their light related information in their rendering used effects
  74857. * @hidden Internal Use Only
  74858. */
  74859. _markMeshesAsLightDirty(): void;
  74860. /**
  74861. * Recomputes the cached photometric scale if needed.
  74862. */
  74863. private _computePhotometricScale;
  74864. /**
  74865. * Returns the Photometric Scale according to the light type and intensity mode.
  74866. */
  74867. private _getPhotometricScale;
  74868. /**
  74869. * Reorder the light in the scene according to their defined priority.
  74870. * @hidden Internal Use Only
  74871. */
  74872. _reorderLightsInScene(): void;
  74873. /**
  74874. * Prepares the list of defines specific to the light type.
  74875. * @param defines the list of defines
  74876. * @param lightIndex defines the index of the light for the effect
  74877. */
  74878. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74879. }
  74880. }
  74881. declare module BABYLON {
  74882. /**
  74883. * Interface used to define Action
  74884. */
  74885. export interface IAction {
  74886. /**
  74887. * Trigger for the action
  74888. */
  74889. trigger: number;
  74890. /** Options of the trigger */
  74891. triggerOptions: any;
  74892. /**
  74893. * Gets the trigger parameters
  74894. * @returns the trigger parameters
  74895. */
  74896. getTriggerParameter(): any;
  74897. /**
  74898. * Internal only - executes current action event
  74899. * @hidden
  74900. */
  74901. _executeCurrent(evt?: ActionEvent): void;
  74902. /**
  74903. * Serialize placeholder for child classes
  74904. * @param parent of child
  74905. * @returns the serialized object
  74906. */
  74907. serialize(parent: any): any;
  74908. /**
  74909. * Internal only
  74910. * @hidden
  74911. */
  74912. _prepare(): void;
  74913. /**
  74914. * Internal only - manager for action
  74915. * @hidden
  74916. */
  74917. _actionManager: AbstractActionManager;
  74918. /**
  74919. * Adds action to chain of actions, may be a DoNothingAction
  74920. * @param action defines the next action to execute
  74921. * @returns The action passed in
  74922. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74923. */
  74924. then(action: IAction): IAction;
  74925. }
  74926. /**
  74927. * The action to be carried out following a trigger
  74928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74929. */
  74930. export class Action implements IAction {
  74931. /** the trigger, with or without parameters, for the action */
  74932. triggerOptions: any;
  74933. /**
  74934. * Trigger for the action
  74935. */
  74936. trigger: number;
  74937. /**
  74938. * Internal only - manager for action
  74939. * @hidden
  74940. */
  74941. _actionManager: ActionManager;
  74942. private _nextActiveAction;
  74943. private _child;
  74944. private _condition?;
  74945. private _triggerParameter;
  74946. /**
  74947. * An event triggered prior to action being executed.
  74948. */
  74949. onBeforeExecuteObservable: Observable<Action>;
  74950. /**
  74951. * Creates a new Action
  74952. * @param triggerOptions the trigger, with or without parameters, for the action
  74953. * @param condition an optional determinant of action
  74954. */
  74955. constructor(
  74956. /** the trigger, with or without parameters, for the action */
  74957. triggerOptions: any, condition?: Condition);
  74958. /**
  74959. * Internal only
  74960. * @hidden
  74961. */
  74962. _prepare(): void;
  74963. /**
  74964. * Gets the trigger parameters
  74965. * @returns the trigger parameters
  74966. */
  74967. getTriggerParameter(): any;
  74968. /**
  74969. * Internal only - executes current action event
  74970. * @hidden
  74971. */
  74972. _executeCurrent(evt?: ActionEvent): void;
  74973. /**
  74974. * Execute placeholder for child classes
  74975. * @param evt optional action event
  74976. */
  74977. execute(evt?: ActionEvent): void;
  74978. /**
  74979. * Skips to next active action
  74980. */
  74981. skipToNextActiveAction(): void;
  74982. /**
  74983. * Adds action to chain of actions, may be a DoNothingAction
  74984. * @param action defines the next action to execute
  74985. * @returns The action passed in
  74986. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74987. */
  74988. then(action: Action): Action;
  74989. /**
  74990. * Internal only
  74991. * @hidden
  74992. */
  74993. _getProperty(propertyPath: string): string;
  74994. /**
  74995. * Internal only
  74996. * @hidden
  74997. */
  74998. _getEffectiveTarget(target: any, propertyPath: string): any;
  74999. /**
  75000. * Serialize placeholder for child classes
  75001. * @param parent of child
  75002. * @returns the serialized object
  75003. */
  75004. serialize(parent: any): any;
  75005. /**
  75006. * Internal only called by serialize
  75007. * @hidden
  75008. */
  75009. protected _serialize(serializedAction: any, parent?: any): any;
  75010. /**
  75011. * Internal only
  75012. * @hidden
  75013. */
  75014. static _SerializeValueAsString: (value: any) => string;
  75015. /**
  75016. * Internal only
  75017. * @hidden
  75018. */
  75019. static _GetTargetProperty: (target: Node | Scene) => {
  75020. name: string;
  75021. targetType: string;
  75022. value: string;
  75023. };
  75024. }
  75025. }
  75026. declare module BABYLON {
  75027. /**
  75028. * A Condition applied to an Action
  75029. */
  75030. export class Condition {
  75031. /**
  75032. * Internal only - manager for action
  75033. * @hidden
  75034. */
  75035. _actionManager: ActionManager;
  75036. /**
  75037. * Internal only
  75038. * @hidden
  75039. */
  75040. _evaluationId: number;
  75041. /**
  75042. * Internal only
  75043. * @hidden
  75044. */
  75045. _currentResult: boolean;
  75046. /**
  75047. * Creates a new Condition
  75048. * @param actionManager the manager of the action the condition is applied to
  75049. */
  75050. constructor(actionManager: ActionManager);
  75051. /**
  75052. * Check if the current condition is valid
  75053. * @returns a boolean
  75054. */
  75055. isValid(): boolean;
  75056. /**
  75057. * Internal only
  75058. * @hidden
  75059. */
  75060. _getProperty(propertyPath: string): string;
  75061. /**
  75062. * Internal only
  75063. * @hidden
  75064. */
  75065. _getEffectiveTarget(target: any, propertyPath: string): any;
  75066. /**
  75067. * Serialize placeholder for child classes
  75068. * @returns the serialized object
  75069. */
  75070. serialize(): any;
  75071. /**
  75072. * Internal only
  75073. * @hidden
  75074. */
  75075. protected _serialize(serializedCondition: any): any;
  75076. }
  75077. /**
  75078. * Defines specific conditional operators as extensions of Condition
  75079. */
  75080. export class ValueCondition extends Condition {
  75081. /** path to specify the property of the target the conditional operator uses */
  75082. propertyPath: string;
  75083. /** the value compared by the conditional operator against the current value of the property */
  75084. value: any;
  75085. /** the conditional operator, default ValueCondition.IsEqual */
  75086. operator: number;
  75087. /**
  75088. * Internal only
  75089. * @hidden
  75090. */
  75091. private static _IsEqual;
  75092. /**
  75093. * Internal only
  75094. * @hidden
  75095. */
  75096. private static _IsDifferent;
  75097. /**
  75098. * Internal only
  75099. * @hidden
  75100. */
  75101. private static _IsGreater;
  75102. /**
  75103. * Internal only
  75104. * @hidden
  75105. */
  75106. private static _IsLesser;
  75107. /**
  75108. * returns the number for IsEqual
  75109. */
  75110. static readonly IsEqual: number;
  75111. /**
  75112. * Returns the number for IsDifferent
  75113. */
  75114. static readonly IsDifferent: number;
  75115. /**
  75116. * Returns the number for IsGreater
  75117. */
  75118. static readonly IsGreater: number;
  75119. /**
  75120. * Returns the number for IsLesser
  75121. */
  75122. static readonly IsLesser: number;
  75123. /**
  75124. * Internal only The action manager for the condition
  75125. * @hidden
  75126. */
  75127. _actionManager: ActionManager;
  75128. /**
  75129. * Internal only
  75130. * @hidden
  75131. */
  75132. private _target;
  75133. /**
  75134. * Internal only
  75135. * @hidden
  75136. */
  75137. private _effectiveTarget;
  75138. /**
  75139. * Internal only
  75140. * @hidden
  75141. */
  75142. private _property;
  75143. /**
  75144. * Creates a new ValueCondition
  75145. * @param actionManager manager for the action the condition applies to
  75146. * @param target for the action
  75147. * @param propertyPath path to specify the property of the target the conditional operator uses
  75148. * @param value the value compared by the conditional operator against the current value of the property
  75149. * @param operator the conditional operator, default ValueCondition.IsEqual
  75150. */
  75151. constructor(actionManager: ActionManager, target: any,
  75152. /** path to specify the property of the target the conditional operator uses */
  75153. propertyPath: string,
  75154. /** the value compared by the conditional operator against the current value of the property */
  75155. value: any,
  75156. /** the conditional operator, default ValueCondition.IsEqual */
  75157. operator?: number);
  75158. /**
  75159. * Compares the given value with the property value for the specified conditional operator
  75160. * @returns the result of the comparison
  75161. */
  75162. isValid(): boolean;
  75163. /**
  75164. * Serialize the ValueCondition into a JSON compatible object
  75165. * @returns serialization object
  75166. */
  75167. serialize(): any;
  75168. /**
  75169. * Gets the name of the conditional operator for the ValueCondition
  75170. * @param operator the conditional operator
  75171. * @returns the name
  75172. */
  75173. static GetOperatorName(operator: number): string;
  75174. }
  75175. /**
  75176. * Defines a predicate condition as an extension of Condition
  75177. */
  75178. export class PredicateCondition extends Condition {
  75179. /** defines the predicate function used to validate the condition */
  75180. predicate: () => boolean;
  75181. /**
  75182. * Internal only - manager for action
  75183. * @hidden
  75184. */
  75185. _actionManager: ActionManager;
  75186. /**
  75187. * Creates a new PredicateCondition
  75188. * @param actionManager manager for the action the condition applies to
  75189. * @param predicate defines the predicate function used to validate the condition
  75190. */
  75191. constructor(actionManager: ActionManager,
  75192. /** defines the predicate function used to validate the condition */
  75193. predicate: () => boolean);
  75194. /**
  75195. * @returns the validity of the predicate condition
  75196. */
  75197. isValid(): boolean;
  75198. }
  75199. /**
  75200. * Defines a state condition as an extension of Condition
  75201. */
  75202. export class StateCondition extends Condition {
  75203. /** Value to compare with target state */
  75204. value: string;
  75205. /**
  75206. * Internal only - manager for action
  75207. * @hidden
  75208. */
  75209. _actionManager: ActionManager;
  75210. /**
  75211. * Internal only
  75212. * @hidden
  75213. */
  75214. private _target;
  75215. /**
  75216. * Creates a new StateCondition
  75217. * @param actionManager manager for the action the condition applies to
  75218. * @param target of the condition
  75219. * @param value to compare with target state
  75220. */
  75221. constructor(actionManager: ActionManager, target: any,
  75222. /** Value to compare with target state */
  75223. value: string);
  75224. /**
  75225. * Gets a boolean indicating if the current condition is met
  75226. * @returns the validity of the state
  75227. */
  75228. isValid(): boolean;
  75229. /**
  75230. * Serialize the StateCondition into a JSON compatible object
  75231. * @returns serialization object
  75232. */
  75233. serialize(): any;
  75234. }
  75235. }
  75236. declare module BABYLON {
  75237. /**
  75238. * This defines an action responsible to toggle a boolean once triggered.
  75239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75240. */
  75241. export class SwitchBooleanAction extends Action {
  75242. /**
  75243. * The path to the boolean property in the target object
  75244. */
  75245. propertyPath: string;
  75246. private _target;
  75247. private _effectiveTarget;
  75248. private _property;
  75249. /**
  75250. * Instantiate the action
  75251. * @param triggerOptions defines the trigger options
  75252. * @param target defines the object containing the boolean
  75253. * @param propertyPath defines the path to the boolean property in the target object
  75254. * @param condition defines the trigger related conditions
  75255. */
  75256. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75257. /** @hidden */
  75258. _prepare(): void;
  75259. /**
  75260. * Execute the action toggle the boolean value.
  75261. */
  75262. execute(): void;
  75263. /**
  75264. * Serializes the actions and its related information.
  75265. * @param parent defines the object to serialize in
  75266. * @returns the serialized object
  75267. */
  75268. serialize(parent: any): any;
  75269. }
  75270. /**
  75271. * This defines an action responsible to set a the state field of the target
  75272. * to a desired value once triggered.
  75273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75274. */
  75275. export class SetStateAction extends Action {
  75276. /**
  75277. * The value to store in the state field.
  75278. */
  75279. value: string;
  75280. private _target;
  75281. /**
  75282. * Instantiate the action
  75283. * @param triggerOptions defines the trigger options
  75284. * @param target defines the object containing the state property
  75285. * @param value defines the value to store in the state field
  75286. * @param condition defines the trigger related conditions
  75287. */
  75288. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75289. /**
  75290. * Execute the action and store the value on the target state property.
  75291. */
  75292. execute(): void;
  75293. /**
  75294. * Serializes the actions and its related information.
  75295. * @param parent defines the object to serialize in
  75296. * @returns the serialized object
  75297. */
  75298. serialize(parent: any): any;
  75299. }
  75300. /**
  75301. * This defines an action responsible to set a property of the target
  75302. * to a desired value once triggered.
  75303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75304. */
  75305. export class SetValueAction extends Action {
  75306. /**
  75307. * The path of the property to set in the target.
  75308. */
  75309. propertyPath: string;
  75310. /**
  75311. * The value to set in the property
  75312. */
  75313. value: any;
  75314. private _target;
  75315. private _effectiveTarget;
  75316. private _property;
  75317. /**
  75318. * Instantiate the action
  75319. * @param triggerOptions defines the trigger options
  75320. * @param target defines the object containing the property
  75321. * @param propertyPath defines the path of the property to set in the target
  75322. * @param value defines the value to set in the property
  75323. * @param condition defines the trigger related conditions
  75324. */
  75325. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75326. /** @hidden */
  75327. _prepare(): void;
  75328. /**
  75329. * Execute the action and set the targetted property to the desired value.
  75330. */
  75331. execute(): void;
  75332. /**
  75333. * Serializes the actions and its related information.
  75334. * @param parent defines the object to serialize in
  75335. * @returns the serialized object
  75336. */
  75337. serialize(parent: any): any;
  75338. }
  75339. /**
  75340. * This defines an action responsible to increment the target value
  75341. * to a desired value once triggered.
  75342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75343. */
  75344. export class IncrementValueAction extends Action {
  75345. /**
  75346. * The path of the property to increment in the target.
  75347. */
  75348. propertyPath: string;
  75349. /**
  75350. * The value we should increment the property by.
  75351. */
  75352. value: any;
  75353. private _target;
  75354. private _effectiveTarget;
  75355. private _property;
  75356. /**
  75357. * Instantiate the action
  75358. * @param triggerOptions defines the trigger options
  75359. * @param target defines the object containing the property
  75360. * @param propertyPath defines the path of the property to increment in the target
  75361. * @param value defines the value value we should increment the property by
  75362. * @param condition defines the trigger related conditions
  75363. */
  75364. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75365. /** @hidden */
  75366. _prepare(): void;
  75367. /**
  75368. * Execute the action and increment the target of the value amount.
  75369. */
  75370. execute(): void;
  75371. /**
  75372. * Serializes the actions and its related information.
  75373. * @param parent defines the object to serialize in
  75374. * @returns the serialized object
  75375. */
  75376. serialize(parent: any): any;
  75377. }
  75378. /**
  75379. * This defines an action responsible to start an animation once triggered.
  75380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75381. */
  75382. export class PlayAnimationAction extends Action {
  75383. /**
  75384. * Where the animation should start (animation frame)
  75385. */
  75386. from: number;
  75387. /**
  75388. * Where the animation should stop (animation frame)
  75389. */
  75390. to: number;
  75391. /**
  75392. * Define if the animation should loop or stop after the first play.
  75393. */
  75394. loop?: boolean;
  75395. private _target;
  75396. /**
  75397. * Instantiate the action
  75398. * @param triggerOptions defines the trigger options
  75399. * @param target defines the target animation or animation name
  75400. * @param from defines from where the animation should start (animation frame)
  75401. * @param end defines where the animation should stop (animation frame)
  75402. * @param loop defines if the animation should loop or stop after the first play
  75403. * @param condition defines the trigger related conditions
  75404. */
  75405. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75406. /** @hidden */
  75407. _prepare(): void;
  75408. /**
  75409. * Execute the action and play the animation.
  75410. */
  75411. execute(): void;
  75412. /**
  75413. * Serializes the actions and its related information.
  75414. * @param parent defines the object to serialize in
  75415. * @returns the serialized object
  75416. */
  75417. serialize(parent: any): any;
  75418. }
  75419. /**
  75420. * This defines an action responsible to stop an animation once triggered.
  75421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75422. */
  75423. export class StopAnimationAction extends Action {
  75424. private _target;
  75425. /**
  75426. * Instantiate the action
  75427. * @param triggerOptions defines the trigger options
  75428. * @param target defines the target animation or animation name
  75429. * @param condition defines the trigger related conditions
  75430. */
  75431. constructor(triggerOptions: any, target: any, condition?: Condition);
  75432. /** @hidden */
  75433. _prepare(): void;
  75434. /**
  75435. * Execute the action and stop the animation.
  75436. */
  75437. execute(): void;
  75438. /**
  75439. * Serializes the actions and its related information.
  75440. * @param parent defines the object to serialize in
  75441. * @returns the serialized object
  75442. */
  75443. serialize(parent: any): any;
  75444. }
  75445. /**
  75446. * This defines an action responsible that does nothing once triggered.
  75447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75448. */
  75449. export class DoNothingAction extends Action {
  75450. /**
  75451. * Instantiate the action
  75452. * @param triggerOptions defines the trigger options
  75453. * @param condition defines the trigger related conditions
  75454. */
  75455. constructor(triggerOptions?: any, condition?: Condition);
  75456. /**
  75457. * Execute the action and do nothing.
  75458. */
  75459. execute(): void;
  75460. /**
  75461. * Serializes the actions and its related information.
  75462. * @param parent defines the object to serialize in
  75463. * @returns the serialized object
  75464. */
  75465. serialize(parent: any): any;
  75466. }
  75467. /**
  75468. * This defines an action responsible to trigger several actions once triggered.
  75469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75470. */
  75471. export class CombineAction extends Action {
  75472. /**
  75473. * The list of aggregated animations to run.
  75474. */
  75475. children: Action[];
  75476. /**
  75477. * Instantiate the action
  75478. * @param triggerOptions defines the trigger options
  75479. * @param children defines the list of aggregated animations to run
  75480. * @param condition defines the trigger related conditions
  75481. */
  75482. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75483. /** @hidden */
  75484. _prepare(): void;
  75485. /**
  75486. * Execute the action and executes all the aggregated actions.
  75487. */
  75488. execute(evt: ActionEvent): void;
  75489. /**
  75490. * Serializes the actions and its related information.
  75491. * @param parent defines the object to serialize in
  75492. * @returns the serialized object
  75493. */
  75494. serialize(parent: any): any;
  75495. }
  75496. /**
  75497. * This defines an action responsible to run code (external event) once triggered.
  75498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75499. */
  75500. export class ExecuteCodeAction extends Action {
  75501. /**
  75502. * The callback function to run.
  75503. */
  75504. func: (evt: ActionEvent) => void;
  75505. /**
  75506. * Instantiate the action
  75507. * @param triggerOptions defines the trigger options
  75508. * @param func defines the callback function to run
  75509. * @param condition defines the trigger related conditions
  75510. */
  75511. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75512. /**
  75513. * Execute the action and run the attached code.
  75514. */
  75515. execute(evt: ActionEvent): void;
  75516. }
  75517. /**
  75518. * This defines an action responsible to set the parent property of the target once triggered.
  75519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75520. */
  75521. export class SetParentAction extends Action {
  75522. private _parent;
  75523. private _target;
  75524. /**
  75525. * Instantiate the action
  75526. * @param triggerOptions defines the trigger options
  75527. * @param target defines the target containing the parent property
  75528. * @param parent defines from where the animation should start (animation frame)
  75529. * @param condition defines the trigger related conditions
  75530. */
  75531. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75532. /** @hidden */
  75533. _prepare(): void;
  75534. /**
  75535. * Execute the action and set the parent property.
  75536. */
  75537. execute(): void;
  75538. /**
  75539. * Serializes the actions and its related information.
  75540. * @param parent defines the object to serialize in
  75541. * @returns the serialized object
  75542. */
  75543. serialize(parent: any): any;
  75544. }
  75545. }
  75546. declare module BABYLON {
  75547. /**
  75548. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75549. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75551. */
  75552. export class ActionManager extends AbstractActionManager {
  75553. /**
  75554. * Nothing
  75555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75556. */
  75557. static readonly NothingTrigger: number;
  75558. /**
  75559. * On pick
  75560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75561. */
  75562. static readonly OnPickTrigger: number;
  75563. /**
  75564. * On left pick
  75565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75566. */
  75567. static readonly OnLeftPickTrigger: number;
  75568. /**
  75569. * On right pick
  75570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75571. */
  75572. static readonly OnRightPickTrigger: number;
  75573. /**
  75574. * On center pick
  75575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75576. */
  75577. static readonly OnCenterPickTrigger: number;
  75578. /**
  75579. * On pick down
  75580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75581. */
  75582. static readonly OnPickDownTrigger: number;
  75583. /**
  75584. * On double pick
  75585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75586. */
  75587. static readonly OnDoublePickTrigger: number;
  75588. /**
  75589. * On pick up
  75590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75591. */
  75592. static readonly OnPickUpTrigger: number;
  75593. /**
  75594. * On pick out.
  75595. * This trigger will only be raised if you also declared a OnPickDown
  75596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75597. */
  75598. static readonly OnPickOutTrigger: number;
  75599. /**
  75600. * On long press
  75601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75602. */
  75603. static readonly OnLongPressTrigger: number;
  75604. /**
  75605. * On pointer over
  75606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75607. */
  75608. static readonly OnPointerOverTrigger: number;
  75609. /**
  75610. * On pointer out
  75611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75612. */
  75613. static readonly OnPointerOutTrigger: number;
  75614. /**
  75615. * On every frame
  75616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75617. */
  75618. static readonly OnEveryFrameTrigger: number;
  75619. /**
  75620. * On intersection enter
  75621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75622. */
  75623. static readonly OnIntersectionEnterTrigger: number;
  75624. /**
  75625. * On intersection exit
  75626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75627. */
  75628. static readonly OnIntersectionExitTrigger: number;
  75629. /**
  75630. * On key down
  75631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75632. */
  75633. static readonly OnKeyDownTrigger: number;
  75634. /**
  75635. * On key up
  75636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75637. */
  75638. static readonly OnKeyUpTrigger: number;
  75639. private _scene;
  75640. /**
  75641. * Creates a new action manager
  75642. * @param scene defines the hosting scene
  75643. */
  75644. constructor(scene: Scene);
  75645. /**
  75646. * Releases all associated resources
  75647. */
  75648. dispose(): void;
  75649. /**
  75650. * Gets hosting scene
  75651. * @returns the hosting scene
  75652. */
  75653. getScene(): Scene;
  75654. /**
  75655. * Does this action manager handles actions of any of the given triggers
  75656. * @param triggers defines the triggers to be tested
  75657. * @return a boolean indicating whether one (or more) of the triggers is handled
  75658. */
  75659. hasSpecificTriggers(triggers: number[]): boolean;
  75660. /**
  75661. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75662. * speed.
  75663. * @param triggerA defines the trigger to be tested
  75664. * @param triggerB defines the trigger to be tested
  75665. * @return a boolean indicating whether one (or more) of the triggers is handled
  75666. */
  75667. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75668. /**
  75669. * Does this action manager handles actions of a given trigger
  75670. * @param trigger defines the trigger to be tested
  75671. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75672. * @return whether the trigger is handled
  75673. */
  75674. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75675. /**
  75676. * Does this action manager has pointer triggers
  75677. */
  75678. readonly hasPointerTriggers: boolean;
  75679. /**
  75680. * Does this action manager has pick triggers
  75681. */
  75682. readonly hasPickTriggers: boolean;
  75683. /**
  75684. * Registers an action to this action manager
  75685. * @param action defines the action to be registered
  75686. * @return the action amended (prepared) after registration
  75687. */
  75688. registerAction(action: IAction): Nullable<IAction>;
  75689. /**
  75690. * Unregisters an action to this action manager
  75691. * @param action defines the action to be unregistered
  75692. * @return a boolean indicating whether the action has been unregistered
  75693. */
  75694. unregisterAction(action: IAction): Boolean;
  75695. /**
  75696. * Process a specific trigger
  75697. * @param trigger defines the trigger to process
  75698. * @param evt defines the event details to be processed
  75699. */
  75700. processTrigger(trigger: number, evt?: IActionEvent): void;
  75701. /** @hidden */
  75702. _getEffectiveTarget(target: any, propertyPath: string): any;
  75703. /** @hidden */
  75704. _getProperty(propertyPath: string): string;
  75705. /**
  75706. * Serialize this manager to a JSON object
  75707. * @param name defines the property name to store this manager
  75708. * @returns a JSON representation of this manager
  75709. */
  75710. serialize(name: string): any;
  75711. /**
  75712. * Creates a new ActionManager from a JSON data
  75713. * @param parsedActions defines the JSON data to read from
  75714. * @param object defines the hosting mesh
  75715. * @param scene defines the hosting scene
  75716. */
  75717. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75718. /**
  75719. * Get a trigger name by index
  75720. * @param trigger defines the trigger index
  75721. * @returns a trigger name
  75722. */
  75723. static GetTriggerName(trigger: number): string;
  75724. }
  75725. }
  75726. declare module BABYLON {
  75727. /**
  75728. * Class representing a ray with position and direction
  75729. */
  75730. export class Ray {
  75731. /** origin point */
  75732. origin: Vector3;
  75733. /** direction */
  75734. direction: Vector3;
  75735. /** length of the ray */
  75736. length: number;
  75737. private static readonly TmpVector3;
  75738. private _tmpRay;
  75739. /**
  75740. * Creates a new ray
  75741. * @param origin origin point
  75742. * @param direction direction
  75743. * @param length length of the ray
  75744. */
  75745. constructor(
  75746. /** origin point */
  75747. origin: Vector3,
  75748. /** direction */
  75749. direction: Vector3,
  75750. /** length of the ray */
  75751. length?: number);
  75752. /**
  75753. * Checks if the ray intersects a box
  75754. * @param minimum bound of the box
  75755. * @param maximum bound of the box
  75756. * @param intersectionTreshold extra extend to be added to the box in all direction
  75757. * @returns if the box was hit
  75758. */
  75759. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75760. /**
  75761. * Checks if the ray intersects a box
  75762. * @param box the bounding box to check
  75763. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75764. * @returns if the box was hit
  75765. */
  75766. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75767. /**
  75768. * If the ray hits a sphere
  75769. * @param sphere the bounding sphere to check
  75770. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75771. * @returns true if it hits the sphere
  75772. */
  75773. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75774. /**
  75775. * If the ray hits a triange
  75776. * @param vertex0 triangle vertex
  75777. * @param vertex1 triangle vertex
  75778. * @param vertex2 triangle vertex
  75779. * @returns intersection information if hit
  75780. */
  75781. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75782. /**
  75783. * Checks if ray intersects a plane
  75784. * @param plane the plane to check
  75785. * @returns the distance away it was hit
  75786. */
  75787. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75788. /**
  75789. * Calculate the intercept of a ray on a given axis
  75790. * @param axis to check 'x' | 'y' | 'z'
  75791. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75792. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75793. */
  75794. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75795. /**
  75796. * Checks if ray intersects a mesh
  75797. * @param mesh the mesh to check
  75798. * @param fastCheck if only the bounding box should checked
  75799. * @returns picking info of the intersecton
  75800. */
  75801. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75802. /**
  75803. * Checks if ray intersects a mesh
  75804. * @param meshes the meshes to check
  75805. * @param fastCheck if only the bounding box should checked
  75806. * @param results array to store result in
  75807. * @returns Array of picking infos
  75808. */
  75809. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75810. private _comparePickingInfo;
  75811. private static smallnum;
  75812. private static rayl;
  75813. /**
  75814. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75815. * @param sega the first point of the segment to test the intersection against
  75816. * @param segb the second point of the segment to test the intersection against
  75817. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75818. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75819. */
  75820. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75821. /**
  75822. * Update the ray from viewport position
  75823. * @param x position
  75824. * @param y y position
  75825. * @param viewportWidth viewport width
  75826. * @param viewportHeight viewport height
  75827. * @param world world matrix
  75828. * @param view view matrix
  75829. * @param projection projection matrix
  75830. * @returns this ray updated
  75831. */
  75832. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75833. /**
  75834. * Creates a ray with origin and direction of 0,0,0
  75835. * @returns the new ray
  75836. */
  75837. static Zero(): Ray;
  75838. /**
  75839. * Creates a new ray from screen space and viewport
  75840. * @param x position
  75841. * @param y y position
  75842. * @param viewportWidth viewport width
  75843. * @param viewportHeight viewport height
  75844. * @param world world matrix
  75845. * @param view view matrix
  75846. * @param projection projection matrix
  75847. * @returns new ray
  75848. */
  75849. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75850. /**
  75851. * 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
  75852. * transformed to the given world matrix.
  75853. * @param origin The origin point
  75854. * @param end The end point
  75855. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75856. * @returns the new ray
  75857. */
  75858. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75859. /**
  75860. * Transforms a ray by a matrix
  75861. * @param ray ray to transform
  75862. * @param matrix matrix to apply
  75863. * @returns the resulting new ray
  75864. */
  75865. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75866. /**
  75867. * Transforms a ray by a matrix
  75868. * @param ray ray to transform
  75869. * @param matrix matrix to apply
  75870. * @param result ray to store result in
  75871. */
  75872. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75873. /**
  75874. * Unproject a ray from screen space to object space
  75875. * @param sourceX defines the screen space x coordinate to use
  75876. * @param sourceY defines the screen space y coordinate to use
  75877. * @param viewportWidth defines the current width of the viewport
  75878. * @param viewportHeight defines the current height of the viewport
  75879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75880. * @param view defines the view matrix to use
  75881. * @param projection defines the projection matrix to use
  75882. */
  75883. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75884. }
  75885. /**
  75886. * Type used to define predicate used to select faces when a mesh intersection is detected
  75887. */
  75888. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75889. interface Scene {
  75890. /** @hidden */
  75891. _tempPickingRay: Nullable<Ray>;
  75892. /** @hidden */
  75893. _cachedRayForTransform: Ray;
  75894. /** @hidden */
  75895. _pickWithRayInverseMatrix: Matrix;
  75896. /** @hidden */
  75897. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75898. /** @hidden */
  75899. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75900. }
  75901. }
  75902. declare module BABYLON {
  75903. /**
  75904. * Groups all the scene component constants in one place to ease maintenance.
  75905. * @hidden
  75906. */
  75907. export class SceneComponentConstants {
  75908. static readonly NAME_EFFECTLAYER: string;
  75909. static readonly NAME_LAYER: string;
  75910. static readonly NAME_LENSFLARESYSTEM: string;
  75911. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75912. static readonly NAME_PARTICLESYSTEM: string;
  75913. static readonly NAME_GAMEPAD: string;
  75914. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75915. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75916. static readonly NAME_DEPTHRENDERER: string;
  75917. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75918. static readonly NAME_SPRITE: string;
  75919. static readonly NAME_OUTLINERENDERER: string;
  75920. static readonly NAME_PROCEDURALTEXTURE: string;
  75921. static readonly NAME_SHADOWGENERATOR: string;
  75922. static readonly NAME_OCTREE: string;
  75923. static readonly NAME_PHYSICSENGINE: string;
  75924. static readonly NAME_AUDIO: string;
  75925. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75926. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75927. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75928. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75929. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75930. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75931. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75932. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75933. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75934. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75935. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75936. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75937. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75938. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75939. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75940. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75941. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75942. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75943. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75944. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75945. static readonly STEP_AFTERRENDER_AUDIO: number;
  75946. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75947. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75948. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75949. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75950. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75951. static readonly STEP_POINTERMOVE_SPRITE: number;
  75952. static readonly STEP_POINTERDOWN_SPRITE: number;
  75953. static readonly STEP_POINTERUP_SPRITE: number;
  75954. }
  75955. /**
  75956. * This represents a scene component.
  75957. *
  75958. * This is used to decouple the dependency the scene is having on the different workloads like
  75959. * layers, post processes...
  75960. */
  75961. export interface ISceneComponent {
  75962. /**
  75963. * The name of the component. Each component must have a unique name.
  75964. */
  75965. name: string;
  75966. /**
  75967. * The scene the component belongs to.
  75968. */
  75969. scene: Scene;
  75970. /**
  75971. * Register the component to one instance of a scene.
  75972. */
  75973. register(): void;
  75974. /**
  75975. * Rebuilds the elements related to this component in case of
  75976. * context lost for instance.
  75977. */
  75978. rebuild(): void;
  75979. /**
  75980. * Disposes the component and the associated ressources.
  75981. */
  75982. dispose(): void;
  75983. }
  75984. /**
  75985. * This represents a SERIALIZABLE scene component.
  75986. *
  75987. * This extends Scene Component to add Serialization methods on top.
  75988. */
  75989. export interface ISceneSerializableComponent extends ISceneComponent {
  75990. /**
  75991. * Adds all the elements from the container to the scene
  75992. * @param container the container holding the elements
  75993. */
  75994. addFromContainer(container: AbstractScene): void;
  75995. /**
  75996. * Removes all the elements in the container from the scene
  75997. * @param container contains the elements to remove
  75998. * @param dispose if the removed element should be disposed (default: false)
  75999. */
  76000. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76001. /**
  76002. * Serializes the component data to the specified json object
  76003. * @param serializationObject The object to serialize to
  76004. */
  76005. serialize(serializationObject: any): void;
  76006. }
  76007. /**
  76008. * Strong typing of a Mesh related stage step action
  76009. */
  76010. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76011. /**
  76012. * Strong typing of a Evaluate Sub Mesh related stage step action
  76013. */
  76014. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76015. /**
  76016. * Strong typing of a Active Mesh related stage step action
  76017. */
  76018. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76019. /**
  76020. * Strong typing of a Camera related stage step action
  76021. */
  76022. export type CameraStageAction = (camera: Camera) => void;
  76023. /**
  76024. * Strong typing of a Camera Frame buffer related stage step action
  76025. */
  76026. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76027. /**
  76028. * Strong typing of a Render Target related stage step action
  76029. */
  76030. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76031. /**
  76032. * Strong typing of a RenderingGroup related stage step action
  76033. */
  76034. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76035. /**
  76036. * Strong typing of a Mesh Render related stage step action
  76037. */
  76038. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76039. /**
  76040. * Strong typing of a simple stage step action
  76041. */
  76042. export type SimpleStageAction = () => void;
  76043. /**
  76044. * Strong typing of a render target action.
  76045. */
  76046. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76047. /**
  76048. * Strong typing of a pointer move action.
  76049. */
  76050. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76051. /**
  76052. * Strong typing of a pointer up/down action.
  76053. */
  76054. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76055. /**
  76056. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76057. * @hidden
  76058. */
  76059. export class Stage<T extends Function> extends Array<{
  76060. index: number;
  76061. component: ISceneComponent;
  76062. action: T;
  76063. }> {
  76064. /**
  76065. * Hide ctor from the rest of the world.
  76066. * @param items The items to add.
  76067. */
  76068. private constructor();
  76069. /**
  76070. * Creates a new Stage.
  76071. * @returns A new instance of a Stage
  76072. */
  76073. static Create<T extends Function>(): Stage<T>;
  76074. /**
  76075. * Registers a step in an ordered way in the targeted stage.
  76076. * @param index Defines the position to register the step in
  76077. * @param component Defines the component attached to the step
  76078. * @param action Defines the action to launch during the step
  76079. */
  76080. registerStep(index: number, component: ISceneComponent, action: T): void;
  76081. /**
  76082. * Clears all the steps from the stage.
  76083. */
  76084. clear(): void;
  76085. }
  76086. }
  76087. declare module BABYLON {
  76088. interface Scene {
  76089. /** @hidden */
  76090. _pointerOverSprite: Nullable<Sprite>;
  76091. /** @hidden */
  76092. _pickedDownSprite: Nullable<Sprite>;
  76093. /** @hidden */
  76094. _tempSpritePickingRay: Nullable<Ray>;
  76095. /**
  76096. * All of the sprite managers added to this scene
  76097. * @see http://doc.babylonjs.com/babylon101/sprites
  76098. */
  76099. spriteManagers: Array<ISpriteManager>;
  76100. /**
  76101. * An event triggered when sprites rendering is about to start
  76102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76103. */
  76104. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76105. /**
  76106. * An event triggered when sprites rendering is done
  76107. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76108. */
  76109. onAfterSpritesRenderingObservable: Observable<Scene>;
  76110. /** @hidden */
  76111. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76112. /** Launch a ray to try to pick a sprite in the scene
  76113. * @param x position on screen
  76114. * @param y position on screen
  76115. * @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
  76116. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76117. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76118. * @returns a PickingInfo
  76119. */
  76120. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76121. /** Use the given ray to pick a sprite in the scene
  76122. * @param ray The ray (in world space) to use to pick meshes
  76123. * @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
  76124. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76126. * @returns a PickingInfo
  76127. */
  76128. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76129. /** @hidden */
  76130. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76131. /** Launch a ray to try to pick sprites in the scene
  76132. * @param x position on screen
  76133. * @param y position on screen
  76134. * @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
  76135. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76136. * @returns a PickingInfo array
  76137. */
  76138. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76139. /** Use the given ray to pick sprites in the scene
  76140. * @param ray The ray (in world space) to use to pick meshes
  76141. * @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
  76142. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76143. * @returns a PickingInfo array
  76144. */
  76145. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76146. /**
  76147. * Force the sprite under the pointer
  76148. * @param sprite defines the sprite to use
  76149. */
  76150. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76151. /**
  76152. * Gets the sprite under the pointer
  76153. * @returns a Sprite or null if no sprite is under the pointer
  76154. */
  76155. getPointerOverSprite(): Nullable<Sprite>;
  76156. }
  76157. /**
  76158. * Defines the sprite scene component responsible to manage sprites
  76159. * in a given scene.
  76160. */
  76161. export class SpriteSceneComponent implements ISceneComponent {
  76162. /**
  76163. * The component name helpfull to identify the component in the list of scene components.
  76164. */
  76165. readonly name: string;
  76166. /**
  76167. * The scene the component belongs to.
  76168. */
  76169. scene: Scene;
  76170. /** @hidden */
  76171. private _spritePredicate;
  76172. /**
  76173. * Creates a new instance of the component for the given scene
  76174. * @param scene Defines the scene to register the component in
  76175. */
  76176. constructor(scene: Scene);
  76177. /**
  76178. * Registers the component in a given scene
  76179. */
  76180. register(): void;
  76181. /**
  76182. * Rebuilds the elements related to this component in case of
  76183. * context lost for instance.
  76184. */
  76185. rebuild(): void;
  76186. /**
  76187. * Disposes the component and the associated ressources.
  76188. */
  76189. dispose(): void;
  76190. private _pickSpriteButKeepRay;
  76191. private _pointerMove;
  76192. private _pointerDown;
  76193. private _pointerUp;
  76194. }
  76195. }
  76196. declare module BABYLON {
  76197. /** @hidden */
  76198. export var fogFragmentDeclaration: {
  76199. name: string;
  76200. shader: string;
  76201. };
  76202. }
  76203. declare module BABYLON {
  76204. /** @hidden */
  76205. export var fogFragment: {
  76206. name: string;
  76207. shader: string;
  76208. };
  76209. }
  76210. declare module BABYLON {
  76211. /** @hidden */
  76212. export var spritesPixelShader: {
  76213. name: string;
  76214. shader: string;
  76215. };
  76216. }
  76217. declare module BABYLON {
  76218. /** @hidden */
  76219. export var fogVertexDeclaration: {
  76220. name: string;
  76221. shader: string;
  76222. };
  76223. }
  76224. declare module BABYLON {
  76225. /** @hidden */
  76226. export var spritesVertexShader: {
  76227. name: string;
  76228. shader: string;
  76229. };
  76230. }
  76231. declare module BABYLON {
  76232. /**
  76233. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76234. */
  76235. export interface ISpriteManager extends IDisposable {
  76236. /**
  76237. * Restricts the camera to viewing objects with the same layerMask.
  76238. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76239. */
  76240. layerMask: number;
  76241. /**
  76242. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76243. */
  76244. isPickable: boolean;
  76245. /**
  76246. * Specifies the rendering group id for this mesh (0 by default)
  76247. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76248. */
  76249. renderingGroupId: number;
  76250. /**
  76251. * Defines the list of sprites managed by the manager.
  76252. */
  76253. sprites: Array<Sprite>;
  76254. /**
  76255. * Tests the intersection of a sprite with a specific ray.
  76256. * @param ray The ray we are sending to test the collision
  76257. * @param camera The camera space we are sending rays in
  76258. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76259. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76260. * @returns picking info or null.
  76261. */
  76262. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76263. /**
  76264. * Intersects the sprites with a ray
  76265. * @param ray defines the ray to intersect with
  76266. * @param camera defines the current active camera
  76267. * @param predicate defines a predicate used to select candidate sprites
  76268. * @returns null if no hit or a PickingInfo array
  76269. */
  76270. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76271. /**
  76272. * Renders the list of sprites on screen.
  76273. */
  76274. render(): void;
  76275. }
  76276. /**
  76277. * Class used to manage multiple sprites on the same spritesheet
  76278. * @see http://doc.babylonjs.com/babylon101/sprites
  76279. */
  76280. export class SpriteManager implements ISpriteManager {
  76281. /** defines the manager's name */
  76282. name: string;
  76283. /** Gets the list of sprites */
  76284. sprites: Sprite[];
  76285. /** Gets or sets the rendering group id (0 by default) */
  76286. renderingGroupId: number;
  76287. /** Gets or sets camera layer mask */
  76288. layerMask: number;
  76289. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76290. fogEnabled: boolean;
  76291. /** Gets or sets a boolean indicating if the sprites are pickable */
  76292. isPickable: boolean;
  76293. /** Defines the default width of a cell in the spritesheet */
  76294. cellWidth: number;
  76295. /** Defines the default height of a cell in the spritesheet */
  76296. cellHeight: number;
  76297. /** Associative array from JSON sprite data file */
  76298. private _cellData;
  76299. /** Array of sprite names from JSON sprite data file */
  76300. private _spriteMap;
  76301. /** True when packed cell data from JSON file is ready*/
  76302. private _packedAndReady;
  76303. /**
  76304. * An event triggered when the manager is disposed.
  76305. */
  76306. onDisposeObservable: Observable<SpriteManager>;
  76307. private _onDisposeObserver;
  76308. /**
  76309. * Callback called when the manager is disposed
  76310. */
  76311. onDispose: () => void;
  76312. private _capacity;
  76313. private _fromPacked;
  76314. private _spriteTexture;
  76315. private _epsilon;
  76316. private _scene;
  76317. private _vertexData;
  76318. private _buffer;
  76319. private _vertexBuffers;
  76320. private _indexBuffer;
  76321. private _effectBase;
  76322. private _effectFog;
  76323. /**
  76324. * Gets or sets the spritesheet texture
  76325. */
  76326. texture: Texture;
  76327. /**
  76328. * Creates a new sprite manager
  76329. * @param name defines the manager's name
  76330. * @param imgUrl defines the sprite sheet url
  76331. * @param capacity defines the maximum allowed number of sprites
  76332. * @param cellSize defines the size of a sprite cell
  76333. * @param scene defines the hosting scene
  76334. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76335. * @param samplingMode defines the smapling mode to use with spritesheet
  76336. * @param fromPacked set to false; do not alter
  76337. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76338. */
  76339. constructor(
  76340. /** defines the manager's name */
  76341. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76342. private _makePacked;
  76343. private _appendSpriteVertex;
  76344. /**
  76345. * Intersects the sprites with a ray
  76346. * @param ray defines the ray to intersect with
  76347. * @param camera defines the current active camera
  76348. * @param predicate defines a predicate used to select candidate sprites
  76349. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76350. * @returns null if no hit or a PickingInfo
  76351. */
  76352. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76353. /**
  76354. * Intersects the sprites with a ray
  76355. * @param ray defines the ray to intersect with
  76356. * @param camera defines the current active camera
  76357. * @param predicate defines a predicate used to select candidate sprites
  76358. * @returns null if no hit or a PickingInfo array
  76359. */
  76360. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76361. /**
  76362. * Render all child sprites
  76363. */
  76364. render(): void;
  76365. /**
  76366. * Release associated resources
  76367. */
  76368. dispose(): void;
  76369. }
  76370. }
  76371. declare module BABYLON {
  76372. /**
  76373. * Class used to represent a sprite
  76374. * @see http://doc.babylonjs.com/babylon101/sprites
  76375. */
  76376. export class Sprite {
  76377. /** defines the name */
  76378. name: string;
  76379. /** Gets or sets the current world position */
  76380. position: Vector3;
  76381. /** Gets or sets the main color */
  76382. color: Color4;
  76383. /** Gets or sets the width */
  76384. width: number;
  76385. /** Gets or sets the height */
  76386. height: number;
  76387. /** Gets or sets rotation angle */
  76388. angle: number;
  76389. /** Gets or sets the cell index in the sprite sheet */
  76390. cellIndex: number;
  76391. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76392. cellRef: string;
  76393. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76394. invertU: number;
  76395. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76396. invertV: number;
  76397. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76398. disposeWhenFinishedAnimating: boolean;
  76399. /** Gets the list of attached animations */
  76400. animations: Animation[];
  76401. /** Gets or sets a boolean indicating if the sprite can be picked */
  76402. isPickable: boolean;
  76403. /**
  76404. * Gets or sets the associated action manager
  76405. */
  76406. actionManager: Nullable<ActionManager>;
  76407. private _animationStarted;
  76408. private _loopAnimation;
  76409. private _fromIndex;
  76410. private _toIndex;
  76411. private _delay;
  76412. private _direction;
  76413. private _manager;
  76414. private _time;
  76415. private _onAnimationEnd;
  76416. /**
  76417. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76418. */
  76419. isVisible: boolean;
  76420. /**
  76421. * Gets or sets the sprite size
  76422. */
  76423. size: number;
  76424. /**
  76425. * Creates a new Sprite
  76426. * @param name defines the name
  76427. * @param manager defines the manager
  76428. */
  76429. constructor(
  76430. /** defines the name */
  76431. name: string, manager: ISpriteManager);
  76432. /**
  76433. * Starts an animation
  76434. * @param from defines the initial key
  76435. * @param to defines the end key
  76436. * @param loop defines if the animation must loop
  76437. * @param delay defines the start delay (in ms)
  76438. * @param onAnimationEnd defines a callback to call when animation ends
  76439. */
  76440. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76441. /** Stops current animation (if any) */
  76442. stopAnimation(): void;
  76443. /** @hidden */
  76444. _animate(deltaTime: number): void;
  76445. /** Release associated resources */
  76446. dispose(): void;
  76447. }
  76448. }
  76449. declare module BABYLON {
  76450. /**
  76451. * Information about the result of picking within a scene
  76452. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76453. */
  76454. export class PickingInfo {
  76455. /** @hidden */
  76456. _pickingUnavailable: boolean;
  76457. /**
  76458. * If the pick collided with an object
  76459. */
  76460. hit: boolean;
  76461. /**
  76462. * Distance away where the pick collided
  76463. */
  76464. distance: number;
  76465. /**
  76466. * The location of pick collision
  76467. */
  76468. pickedPoint: Nullable<Vector3>;
  76469. /**
  76470. * The mesh corresponding the the pick collision
  76471. */
  76472. pickedMesh: Nullable<AbstractMesh>;
  76473. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76474. bu: number;
  76475. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76476. bv: number;
  76477. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76478. faceId: number;
  76479. /** Id of the the submesh that was picked */
  76480. subMeshId: number;
  76481. /** If a sprite was picked, this will be the sprite the pick collided with */
  76482. pickedSprite: Nullable<Sprite>;
  76483. /**
  76484. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76485. */
  76486. originMesh: Nullable<AbstractMesh>;
  76487. /**
  76488. * The ray that was used to perform the picking.
  76489. */
  76490. ray: Nullable<Ray>;
  76491. /**
  76492. * Gets the normal correspodning to the face the pick collided with
  76493. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76494. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76495. * @returns The normal correspodning to the face the pick collided with
  76496. */
  76497. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76498. /**
  76499. * Gets the texture coordinates of where the pick occured
  76500. * @returns the vector containing the coordnates of the texture
  76501. */
  76502. getTextureCoordinates(): Nullable<Vector2>;
  76503. }
  76504. }
  76505. declare module BABYLON {
  76506. /**
  76507. * Gather the list of pointer event types as constants.
  76508. */
  76509. export class PointerEventTypes {
  76510. /**
  76511. * 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.
  76512. */
  76513. static readonly POINTERDOWN: number;
  76514. /**
  76515. * The pointerup event is fired when a pointer is no longer active.
  76516. */
  76517. static readonly POINTERUP: number;
  76518. /**
  76519. * The pointermove event is fired when a pointer changes coordinates.
  76520. */
  76521. static readonly POINTERMOVE: number;
  76522. /**
  76523. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76524. */
  76525. static readonly POINTERWHEEL: number;
  76526. /**
  76527. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76528. */
  76529. static readonly POINTERPICK: number;
  76530. /**
  76531. * The pointertap event is fired when a the object has been touched and released without drag.
  76532. */
  76533. static readonly POINTERTAP: number;
  76534. /**
  76535. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76536. */
  76537. static readonly POINTERDOUBLETAP: number;
  76538. }
  76539. /**
  76540. * Base class of pointer info types.
  76541. */
  76542. export class PointerInfoBase {
  76543. /**
  76544. * Defines the type of event (PointerEventTypes)
  76545. */
  76546. type: number;
  76547. /**
  76548. * Defines the related dom event
  76549. */
  76550. event: PointerEvent | MouseWheelEvent;
  76551. /**
  76552. * Instantiates the base class of pointers info.
  76553. * @param type Defines the type of event (PointerEventTypes)
  76554. * @param event Defines the related dom event
  76555. */
  76556. constructor(
  76557. /**
  76558. * Defines the type of event (PointerEventTypes)
  76559. */
  76560. type: number,
  76561. /**
  76562. * Defines the related dom event
  76563. */
  76564. event: PointerEvent | MouseWheelEvent);
  76565. }
  76566. /**
  76567. * This class is used to store pointer related info for the onPrePointerObservable event.
  76568. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76569. */
  76570. export class PointerInfoPre extends PointerInfoBase {
  76571. /**
  76572. * Ray from a pointer if availible (eg. 6dof controller)
  76573. */
  76574. ray: Nullable<Ray>;
  76575. /**
  76576. * Defines the local position of the pointer on the canvas.
  76577. */
  76578. localPosition: Vector2;
  76579. /**
  76580. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76581. */
  76582. skipOnPointerObservable: boolean;
  76583. /**
  76584. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76585. * @param type Defines the type of event (PointerEventTypes)
  76586. * @param event Defines the related dom event
  76587. * @param localX Defines the local x coordinates of the pointer when the event occured
  76588. * @param localY Defines the local y coordinates of the pointer when the event occured
  76589. */
  76590. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76591. }
  76592. /**
  76593. * This type contains all the data related to a pointer event in Babylon.js.
  76594. * 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.
  76595. */
  76596. export class PointerInfo extends PointerInfoBase {
  76597. /**
  76598. * Defines the picking info associated to the info (if any)\
  76599. */
  76600. pickInfo: Nullable<PickingInfo>;
  76601. /**
  76602. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76603. * @param type Defines the type of event (PointerEventTypes)
  76604. * @param event Defines the related dom event
  76605. * @param pickInfo Defines the picking info associated to the info (if any)\
  76606. */
  76607. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76608. /**
  76609. * Defines the picking info associated to the info (if any)\
  76610. */
  76611. pickInfo: Nullable<PickingInfo>);
  76612. }
  76613. /**
  76614. * Data relating to a touch event on the screen.
  76615. */
  76616. export interface PointerTouch {
  76617. /**
  76618. * X coordinate of touch.
  76619. */
  76620. x: number;
  76621. /**
  76622. * Y coordinate of touch.
  76623. */
  76624. y: number;
  76625. /**
  76626. * Id of touch. Unique for each finger.
  76627. */
  76628. pointerId: number;
  76629. /**
  76630. * Event type passed from DOM.
  76631. */
  76632. type: any;
  76633. }
  76634. }
  76635. declare module BABYLON {
  76636. /**
  76637. * Manage the mouse inputs to control the movement of a free camera.
  76638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76639. */
  76640. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76641. /**
  76642. * Define if touch is enabled in the mouse input
  76643. */
  76644. touchEnabled: boolean;
  76645. /**
  76646. * Defines the camera the input is attached to.
  76647. */
  76648. camera: FreeCamera;
  76649. /**
  76650. * Defines the buttons associated with the input to handle camera move.
  76651. */
  76652. buttons: number[];
  76653. /**
  76654. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76655. */
  76656. angularSensibility: number;
  76657. private _pointerInput;
  76658. private _onMouseMove;
  76659. private _observer;
  76660. private previousPosition;
  76661. /**
  76662. * Observable for when a pointer move event occurs containing the move offset
  76663. */
  76664. onPointerMovedObservable: Observable<{
  76665. offsetX: number;
  76666. offsetY: number;
  76667. }>;
  76668. /**
  76669. * @hidden
  76670. * If the camera should be rotated automatically based on pointer movement
  76671. */
  76672. _allowCameraRotation: boolean;
  76673. /**
  76674. * Manage the mouse inputs to control the movement of a free camera.
  76675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76676. * @param touchEnabled Defines if touch is enabled or not
  76677. */
  76678. constructor(
  76679. /**
  76680. * Define if touch is enabled in the mouse input
  76681. */
  76682. touchEnabled?: boolean);
  76683. /**
  76684. * Attach the input controls to a specific dom element to get the input from.
  76685. * @param element Defines the element the controls should be listened from
  76686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76687. */
  76688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76689. /**
  76690. * Called on JS contextmenu event.
  76691. * Override this method to provide functionality.
  76692. */
  76693. protected onContextMenu(evt: PointerEvent): void;
  76694. /**
  76695. * Detach the current controls from the specified dom element.
  76696. * @param element Defines the element to stop listening the inputs from
  76697. */
  76698. detachControl(element: Nullable<HTMLElement>): void;
  76699. /**
  76700. * Gets the class name of the current intput.
  76701. * @returns the class name
  76702. */
  76703. getClassName(): string;
  76704. /**
  76705. * Get the friendly name associated with the input class.
  76706. * @returns the input friendly name
  76707. */
  76708. getSimpleName(): string;
  76709. }
  76710. }
  76711. declare module BABYLON {
  76712. /**
  76713. * Manage the touch inputs to control the movement of a free camera.
  76714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76715. */
  76716. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76717. /**
  76718. * Defines the camera the input is attached to.
  76719. */
  76720. camera: FreeCamera;
  76721. /**
  76722. * Defines the touch sensibility for rotation.
  76723. * The higher the faster.
  76724. */
  76725. touchAngularSensibility: number;
  76726. /**
  76727. * Defines the touch sensibility for move.
  76728. * The higher the faster.
  76729. */
  76730. touchMoveSensibility: number;
  76731. private _offsetX;
  76732. private _offsetY;
  76733. private _pointerPressed;
  76734. private _pointerInput;
  76735. private _observer;
  76736. private _onLostFocus;
  76737. /**
  76738. * Attach the input controls to a specific dom element to get the input from.
  76739. * @param element Defines the element the controls should be listened from
  76740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76741. */
  76742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76743. /**
  76744. * Detach the current controls from the specified dom element.
  76745. * @param element Defines the element to stop listening the inputs from
  76746. */
  76747. detachControl(element: Nullable<HTMLElement>): void;
  76748. /**
  76749. * Update the current camera state depending on the inputs that have been used this frame.
  76750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76751. */
  76752. checkInputs(): void;
  76753. /**
  76754. * Gets the class name of the current intput.
  76755. * @returns the class name
  76756. */
  76757. getClassName(): string;
  76758. /**
  76759. * Get the friendly name associated with the input class.
  76760. * @returns the input friendly name
  76761. */
  76762. getSimpleName(): string;
  76763. }
  76764. }
  76765. declare module BABYLON {
  76766. /**
  76767. * Default Inputs manager for the FreeCamera.
  76768. * It groups all the default supported inputs for ease of use.
  76769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76770. */
  76771. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76772. /**
  76773. * @hidden
  76774. */
  76775. _mouseInput: Nullable<FreeCameraMouseInput>;
  76776. /**
  76777. * Instantiates a new FreeCameraInputsManager.
  76778. * @param camera Defines the camera the inputs belong to
  76779. */
  76780. constructor(camera: FreeCamera);
  76781. /**
  76782. * Add keyboard input support to the input manager.
  76783. * @returns the current input manager
  76784. */
  76785. addKeyboard(): FreeCameraInputsManager;
  76786. /**
  76787. * Add mouse input support to the input manager.
  76788. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76789. * @returns the current input manager
  76790. */
  76791. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76792. /**
  76793. * Removes the mouse input support from the manager
  76794. * @returns the current input manager
  76795. */
  76796. removeMouse(): FreeCameraInputsManager;
  76797. /**
  76798. * Add touch input support to the input manager.
  76799. * @returns the current input manager
  76800. */
  76801. addTouch(): FreeCameraInputsManager;
  76802. /**
  76803. * Remove all attached input methods from a camera
  76804. */
  76805. clear(): void;
  76806. }
  76807. }
  76808. declare module BABYLON {
  76809. /**
  76810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76811. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76813. */
  76814. export class FreeCamera extends TargetCamera {
  76815. /**
  76816. * Define the collision ellipsoid of the camera.
  76817. * This is helpful to simulate a camera body like the player body around the camera
  76818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76819. */
  76820. ellipsoid: Vector3;
  76821. /**
  76822. * Define an offset for the position of the ellipsoid around the camera.
  76823. * This can be helpful to determine the center of the body near the gravity center of the body
  76824. * instead of its head.
  76825. */
  76826. ellipsoidOffset: Vector3;
  76827. /**
  76828. * Enable or disable collisions of the camera with the rest of the scene objects.
  76829. */
  76830. checkCollisions: boolean;
  76831. /**
  76832. * Enable or disable gravity on the camera.
  76833. */
  76834. applyGravity: boolean;
  76835. /**
  76836. * Define the input manager associated to the camera.
  76837. */
  76838. inputs: FreeCameraInputsManager;
  76839. /**
  76840. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76841. * Higher values reduce sensitivity.
  76842. */
  76843. /**
  76844. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76845. * Higher values reduce sensitivity.
  76846. */
  76847. angularSensibility: number;
  76848. /**
  76849. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76850. */
  76851. keysUp: number[];
  76852. /**
  76853. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76854. */
  76855. keysDown: number[];
  76856. /**
  76857. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76858. */
  76859. keysLeft: number[];
  76860. /**
  76861. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76862. */
  76863. keysRight: number[];
  76864. /**
  76865. * Event raised when the camera collide with a mesh in the scene.
  76866. */
  76867. onCollide: (collidedMesh: AbstractMesh) => void;
  76868. private _collider;
  76869. private _needMoveForGravity;
  76870. private _oldPosition;
  76871. private _diffPosition;
  76872. private _newPosition;
  76873. /** @hidden */
  76874. _localDirection: Vector3;
  76875. /** @hidden */
  76876. _transformedDirection: Vector3;
  76877. /**
  76878. * Instantiates a Free Camera.
  76879. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76880. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76882. * @param name Define the name of the camera in the scene
  76883. * @param position Define the start position of the camera in the scene
  76884. * @param scene Define the scene the camera belongs to
  76885. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76886. */
  76887. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76888. /**
  76889. * Attached controls to the current camera.
  76890. * @param element Defines the element the controls should be listened from
  76891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76892. */
  76893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76894. /**
  76895. * Detach the current controls from the camera.
  76896. * The camera will stop reacting to inputs.
  76897. * @param element Defines the element to stop listening the inputs from
  76898. */
  76899. detachControl(element: HTMLElement): void;
  76900. private _collisionMask;
  76901. /**
  76902. * Define a collision mask to limit the list of object the camera can collide with
  76903. */
  76904. collisionMask: number;
  76905. /** @hidden */
  76906. _collideWithWorld(displacement: Vector3): void;
  76907. private _onCollisionPositionChange;
  76908. /** @hidden */
  76909. _checkInputs(): void;
  76910. /** @hidden */
  76911. _decideIfNeedsToMove(): boolean;
  76912. /** @hidden */
  76913. _updatePosition(): void;
  76914. /**
  76915. * Destroy the camera and release the current resources hold by it.
  76916. */
  76917. dispose(): void;
  76918. /**
  76919. * Gets the current object class name.
  76920. * @return the class name
  76921. */
  76922. getClassName(): string;
  76923. }
  76924. }
  76925. declare module BABYLON {
  76926. /**
  76927. * Represents a gamepad control stick position
  76928. */
  76929. export class StickValues {
  76930. /**
  76931. * The x component of the control stick
  76932. */
  76933. x: number;
  76934. /**
  76935. * The y component of the control stick
  76936. */
  76937. y: number;
  76938. /**
  76939. * Initializes the gamepad x and y control stick values
  76940. * @param x The x component of the gamepad control stick value
  76941. * @param y The y component of the gamepad control stick value
  76942. */
  76943. constructor(
  76944. /**
  76945. * The x component of the control stick
  76946. */
  76947. x: number,
  76948. /**
  76949. * The y component of the control stick
  76950. */
  76951. y: number);
  76952. }
  76953. /**
  76954. * An interface which manages callbacks for gamepad button changes
  76955. */
  76956. export interface GamepadButtonChanges {
  76957. /**
  76958. * Called when a gamepad has been changed
  76959. */
  76960. changed: boolean;
  76961. /**
  76962. * Called when a gamepad press event has been triggered
  76963. */
  76964. pressChanged: boolean;
  76965. /**
  76966. * Called when a touch event has been triggered
  76967. */
  76968. touchChanged: boolean;
  76969. /**
  76970. * Called when a value has changed
  76971. */
  76972. valueChanged: boolean;
  76973. }
  76974. /**
  76975. * Represents a gamepad
  76976. */
  76977. export class Gamepad {
  76978. /**
  76979. * The id of the gamepad
  76980. */
  76981. id: string;
  76982. /**
  76983. * The index of the gamepad
  76984. */
  76985. index: number;
  76986. /**
  76987. * The browser gamepad
  76988. */
  76989. browserGamepad: any;
  76990. /**
  76991. * Specifies what type of gamepad this represents
  76992. */
  76993. type: number;
  76994. private _leftStick;
  76995. private _rightStick;
  76996. /** @hidden */
  76997. _isConnected: boolean;
  76998. private _leftStickAxisX;
  76999. private _leftStickAxisY;
  77000. private _rightStickAxisX;
  77001. private _rightStickAxisY;
  77002. /**
  77003. * Triggered when the left control stick has been changed
  77004. */
  77005. private _onleftstickchanged;
  77006. /**
  77007. * Triggered when the right control stick has been changed
  77008. */
  77009. private _onrightstickchanged;
  77010. /**
  77011. * Represents a gamepad controller
  77012. */
  77013. static GAMEPAD: number;
  77014. /**
  77015. * Represents a generic controller
  77016. */
  77017. static GENERIC: number;
  77018. /**
  77019. * Represents an XBox controller
  77020. */
  77021. static XBOX: number;
  77022. /**
  77023. * Represents a pose-enabled controller
  77024. */
  77025. static POSE_ENABLED: number;
  77026. /**
  77027. * Represents an Dual Shock controller
  77028. */
  77029. static DUALSHOCK: number;
  77030. /**
  77031. * Specifies whether the left control stick should be Y-inverted
  77032. */
  77033. protected _invertLeftStickY: boolean;
  77034. /**
  77035. * Specifies if the gamepad has been connected
  77036. */
  77037. readonly isConnected: boolean;
  77038. /**
  77039. * Initializes the gamepad
  77040. * @param id The id of the gamepad
  77041. * @param index The index of the gamepad
  77042. * @param browserGamepad The browser gamepad
  77043. * @param leftStickX The x component of the left joystick
  77044. * @param leftStickY The y component of the left joystick
  77045. * @param rightStickX The x component of the right joystick
  77046. * @param rightStickY The y component of the right joystick
  77047. */
  77048. constructor(
  77049. /**
  77050. * The id of the gamepad
  77051. */
  77052. id: string,
  77053. /**
  77054. * The index of the gamepad
  77055. */
  77056. index: number,
  77057. /**
  77058. * The browser gamepad
  77059. */
  77060. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77061. /**
  77062. * Callback triggered when the left joystick has changed
  77063. * @param callback
  77064. */
  77065. onleftstickchanged(callback: (values: StickValues) => void): void;
  77066. /**
  77067. * Callback triggered when the right joystick has changed
  77068. * @param callback
  77069. */
  77070. onrightstickchanged(callback: (values: StickValues) => void): void;
  77071. /**
  77072. * Gets the left joystick
  77073. */
  77074. /**
  77075. * Sets the left joystick values
  77076. */
  77077. leftStick: StickValues;
  77078. /**
  77079. * Gets the right joystick
  77080. */
  77081. /**
  77082. * Sets the right joystick value
  77083. */
  77084. rightStick: StickValues;
  77085. /**
  77086. * Updates the gamepad joystick positions
  77087. */
  77088. update(): void;
  77089. /**
  77090. * Disposes the gamepad
  77091. */
  77092. dispose(): void;
  77093. }
  77094. /**
  77095. * Represents a generic gamepad
  77096. */
  77097. export class GenericPad extends Gamepad {
  77098. private _buttons;
  77099. private _onbuttondown;
  77100. private _onbuttonup;
  77101. /**
  77102. * Observable triggered when a button has been pressed
  77103. */
  77104. onButtonDownObservable: Observable<number>;
  77105. /**
  77106. * Observable triggered when a button has been released
  77107. */
  77108. onButtonUpObservable: Observable<number>;
  77109. /**
  77110. * Callback triggered when a button has been pressed
  77111. * @param callback Called when a button has been pressed
  77112. */
  77113. onbuttondown(callback: (buttonPressed: number) => void): void;
  77114. /**
  77115. * Callback triggered when a button has been released
  77116. * @param callback Called when a button has been released
  77117. */
  77118. onbuttonup(callback: (buttonReleased: number) => void): void;
  77119. /**
  77120. * Initializes the generic gamepad
  77121. * @param id The id of the generic gamepad
  77122. * @param index The index of the generic gamepad
  77123. * @param browserGamepad The browser gamepad
  77124. */
  77125. constructor(id: string, index: number, browserGamepad: any);
  77126. private _setButtonValue;
  77127. /**
  77128. * Updates the generic gamepad
  77129. */
  77130. update(): void;
  77131. /**
  77132. * Disposes the generic gamepad
  77133. */
  77134. dispose(): void;
  77135. }
  77136. }
  77137. declare module BABYLON {
  77138. interface Engine {
  77139. /**
  77140. * Creates a raw texture
  77141. * @param data defines the data to store in the texture
  77142. * @param width defines the width of the texture
  77143. * @param height defines the height of the texture
  77144. * @param format defines the format of the data
  77145. * @param generateMipMaps defines if the engine should generate the mip levels
  77146. * @param invertY defines if data must be stored with Y axis inverted
  77147. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77148. * @param compression defines the compression used (null by default)
  77149. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77150. * @returns the raw texture inside an InternalTexture
  77151. */
  77152. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77153. /**
  77154. * Update a raw texture
  77155. * @param texture defines the texture to update
  77156. * @param data defines the data to store in the texture
  77157. * @param format defines the format of the data
  77158. * @param invertY defines if data must be stored with Y axis inverted
  77159. */
  77160. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77161. /**
  77162. * Update a raw texture
  77163. * @param texture defines the texture to update
  77164. * @param data defines the data to store in the texture
  77165. * @param format defines the format of the data
  77166. * @param invertY defines if data must be stored with Y axis inverted
  77167. * @param compression defines the compression used (null by default)
  77168. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77169. */
  77170. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77171. /**
  77172. * Creates a new raw cube texture
  77173. * @param data defines the array of data to use to create each face
  77174. * @param size defines the size of the textures
  77175. * @param format defines the format of the data
  77176. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77177. * @param generateMipMaps defines if the engine should generate the mip levels
  77178. * @param invertY defines if data must be stored with Y axis inverted
  77179. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77180. * @param compression defines the compression used (null by default)
  77181. * @returns the cube texture as an InternalTexture
  77182. */
  77183. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77184. /**
  77185. * Update a raw cube texture
  77186. * @param texture defines the texture to udpdate
  77187. * @param data defines the data to store
  77188. * @param format defines the data format
  77189. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77190. * @param invertY defines if data must be stored with Y axis inverted
  77191. */
  77192. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77193. /**
  77194. * Update a raw cube texture
  77195. * @param texture defines the texture to udpdate
  77196. * @param data defines the data to store
  77197. * @param format defines the data format
  77198. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77199. * @param invertY defines if data must be stored with Y axis inverted
  77200. * @param compression defines the compression used (null by default)
  77201. */
  77202. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77203. /**
  77204. * Update a raw cube texture
  77205. * @param texture defines the texture to udpdate
  77206. * @param data defines the data to store
  77207. * @param format defines the data format
  77208. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77209. * @param invertY defines if data must be stored with Y axis inverted
  77210. * @param compression defines the compression used (null by default)
  77211. * @param level defines which level of the texture to update
  77212. */
  77213. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77214. /**
  77215. * Creates a new raw cube texture from a specified url
  77216. * @param url defines the url where the data is located
  77217. * @param scene defines the current scene
  77218. * @param size defines the size of the textures
  77219. * @param format defines the format of the data
  77220. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77221. * @param noMipmap defines if the engine should avoid generating the mip levels
  77222. * @param callback defines a callback used to extract texture data from loaded data
  77223. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77224. * @param onLoad defines a callback called when texture is loaded
  77225. * @param onError defines a callback called if there is an error
  77226. * @returns the cube texture as an InternalTexture
  77227. */
  77228. 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;
  77229. /**
  77230. * Creates a new raw cube texture from a specified url
  77231. * @param url defines the url where the data is located
  77232. * @param scene defines the current scene
  77233. * @param size defines the size of the textures
  77234. * @param format defines the format of the data
  77235. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77236. * @param noMipmap defines if the engine should avoid generating the mip levels
  77237. * @param callback defines a callback used to extract texture data from loaded data
  77238. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77239. * @param onLoad defines a callback called when texture is loaded
  77240. * @param onError defines a callback called if there is an error
  77241. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77242. * @param invertY defines if data must be stored with Y axis inverted
  77243. * @returns the cube texture as an InternalTexture
  77244. */
  77245. 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;
  77246. /**
  77247. * Creates a new raw 3D texture
  77248. * @param data defines the data used to create the texture
  77249. * @param width defines the width of the texture
  77250. * @param height defines the height of the texture
  77251. * @param depth defines the depth of the texture
  77252. * @param format defines the format of the texture
  77253. * @param generateMipMaps defines if the engine must generate mip levels
  77254. * @param invertY defines if data must be stored with Y axis inverted
  77255. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77256. * @param compression defines the compressed used (can be null)
  77257. * @param textureType defines the compressed used (can be null)
  77258. * @returns a new raw 3D texture (stored in an InternalTexture)
  77259. */
  77260. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77261. /**
  77262. * Update a raw 3D texture
  77263. * @param texture defines the texture to update
  77264. * @param data defines the data to store
  77265. * @param format defines the data format
  77266. * @param invertY defines if data must be stored with Y axis inverted
  77267. */
  77268. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77269. /**
  77270. * Update a raw 3D texture
  77271. * @param texture defines the texture to update
  77272. * @param data defines the data to store
  77273. * @param format defines the data format
  77274. * @param invertY defines if data must be stored with Y axis inverted
  77275. * @param compression defines the used compression (can be null)
  77276. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77277. */
  77278. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77279. }
  77280. }
  77281. declare module BABYLON {
  77282. /**
  77283. * Raw texture can help creating a texture directly from an array of data.
  77284. * This can be super useful if you either get the data from an uncompressed source or
  77285. * if you wish to create your texture pixel by pixel.
  77286. */
  77287. export class RawTexture extends Texture {
  77288. /**
  77289. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77290. */
  77291. format: number;
  77292. private _engine;
  77293. /**
  77294. * Instantiates a new RawTexture.
  77295. * Raw texture can help creating a texture directly from an array of data.
  77296. * This can be super useful if you either get the data from an uncompressed source or
  77297. * if you wish to create your texture pixel by pixel.
  77298. * @param data define the array of data to use to create the texture
  77299. * @param width define the width of the texture
  77300. * @param height define the height of the texture
  77301. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77302. * @param scene define the scene the texture belongs to
  77303. * @param generateMipMaps define whether mip maps should be generated or not
  77304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77306. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77307. */
  77308. constructor(data: ArrayBufferView, width: number, height: number,
  77309. /**
  77310. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77311. */
  77312. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77313. /**
  77314. * Updates the texture underlying data.
  77315. * @param data Define the new data of the texture
  77316. */
  77317. update(data: ArrayBufferView): void;
  77318. /**
  77319. * Creates a luminance texture from some data.
  77320. * @param data Define the texture data
  77321. * @param width Define the width of the texture
  77322. * @param height Define the height of the texture
  77323. * @param scene Define the scene the texture belongs to
  77324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77327. * @returns the luminance texture
  77328. */
  77329. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77330. /**
  77331. * Creates a luminance alpha texture from some data.
  77332. * @param data Define the texture data
  77333. * @param width Define the width of the texture
  77334. * @param height Define the height of the texture
  77335. * @param scene Define the scene the texture belongs to
  77336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77339. * @returns the luminance alpha texture
  77340. */
  77341. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77342. /**
  77343. * Creates an alpha texture from some data.
  77344. * @param data Define the texture data
  77345. * @param width Define the width of the texture
  77346. * @param height Define the height of the texture
  77347. * @param scene Define the scene the texture belongs to
  77348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77351. * @returns the alpha texture
  77352. */
  77353. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77354. /**
  77355. * Creates a RGB texture from some data.
  77356. * @param data Define the texture data
  77357. * @param width Define the width of the texture
  77358. * @param height Define the height of the texture
  77359. * @param scene Define the scene the texture belongs to
  77360. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77361. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77362. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77363. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77364. * @returns the RGB alpha texture
  77365. */
  77366. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77367. /**
  77368. * Creates a RGBA texture from some data.
  77369. * @param data Define the texture data
  77370. * @param width Define the width of the texture
  77371. * @param height Define the height of the texture
  77372. * @param scene Define the scene the texture belongs to
  77373. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77374. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77375. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77376. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77377. * @returns the RGBA texture
  77378. */
  77379. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77380. /**
  77381. * Creates a R texture from some data.
  77382. * @param data Define the texture data
  77383. * @param width Define the width of the texture
  77384. * @param height Define the height of the texture
  77385. * @param scene Define the scene the texture belongs to
  77386. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77387. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77388. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77389. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77390. * @returns the R texture
  77391. */
  77392. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77393. }
  77394. }
  77395. declare module BABYLON {
  77396. /**
  77397. * Interface for the size containing width and height
  77398. */
  77399. export interface ISize {
  77400. /**
  77401. * Width
  77402. */
  77403. width: number;
  77404. /**
  77405. * Heighht
  77406. */
  77407. height: number;
  77408. }
  77409. /**
  77410. * Size containing widht and height
  77411. */
  77412. export class Size implements ISize {
  77413. /**
  77414. * Width
  77415. */
  77416. width: number;
  77417. /**
  77418. * Height
  77419. */
  77420. height: number;
  77421. /**
  77422. * Creates a Size object from the given width and height (floats).
  77423. * @param width width of the new size
  77424. * @param height height of the new size
  77425. */
  77426. constructor(width: number, height: number);
  77427. /**
  77428. * Returns a string with the Size width and height
  77429. * @returns a string with the Size width and height
  77430. */
  77431. toString(): string;
  77432. /**
  77433. * "Size"
  77434. * @returns the string "Size"
  77435. */
  77436. getClassName(): string;
  77437. /**
  77438. * Returns the Size hash code.
  77439. * @returns a hash code for a unique width and height
  77440. */
  77441. getHashCode(): number;
  77442. /**
  77443. * Updates the current size from the given one.
  77444. * @param src the given size
  77445. */
  77446. copyFrom(src: Size): void;
  77447. /**
  77448. * Updates in place the current Size from the given floats.
  77449. * @param width width of the new size
  77450. * @param height height of the new size
  77451. * @returns the updated Size.
  77452. */
  77453. copyFromFloats(width: number, height: number): Size;
  77454. /**
  77455. * Updates in place the current Size from the given floats.
  77456. * @param width width to set
  77457. * @param height height to set
  77458. * @returns the updated Size.
  77459. */
  77460. set(width: number, height: number): Size;
  77461. /**
  77462. * Multiplies the width and height by numbers
  77463. * @param w factor to multiple the width by
  77464. * @param h factor to multiple the height by
  77465. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77466. */
  77467. multiplyByFloats(w: number, h: number): Size;
  77468. /**
  77469. * Clones the size
  77470. * @returns a new Size copied from the given one.
  77471. */
  77472. clone(): Size;
  77473. /**
  77474. * True if the current Size and the given one width and height are strictly equal.
  77475. * @param other the other size to compare against
  77476. * @returns True if the current Size and the given one width and height are strictly equal.
  77477. */
  77478. equals(other: Size): boolean;
  77479. /**
  77480. * The surface of the Size : width * height (float).
  77481. */
  77482. readonly surface: number;
  77483. /**
  77484. * Create a new size of zero
  77485. * @returns a new Size set to (0.0, 0.0)
  77486. */
  77487. static Zero(): Size;
  77488. /**
  77489. * Sums the width and height of two sizes
  77490. * @param otherSize size to add to this size
  77491. * @returns a new Size set as the addition result of the current Size and the given one.
  77492. */
  77493. add(otherSize: Size): Size;
  77494. /**
  77495. * Subtracts the width and height of two
  77496. * @param otherSize size to subtract to this size
  77497. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77498. */
  77499. subtract(otherSize: Size): Size;
  77500. /**
  77501. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77502. * @param start starting size to lerp between
  77503. * @param end end size to lerp between
  77504. * @param amount amount to lerp between the start and end values
  77505. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77506. */
  77507. static Lerp(start: Size, end: Size, amount: number): Size;
  77508. }
  77509. }
  77510. declare module BABYLON {
  77511. /**
  77512. * Defines a runtime animation
  77513. */
  77514. export class RuntimeAnimation {
  77515. private _events;
  77516. /**
  77517. * The current frame of the runtime animation
  77518. */
  77519. private _currentFrame;
  77520. /**
  77521. * The animation used by the runtime animation
  77522. */
  77523. private _animation;
  77524. /**
  77525. * The target of the runtime animation
  77526. */
  77527. private _target;
  77528. /**
  77529. * The initiating animatable
  77530. */
  77531. private _host;
  77532. /**
  77533. * The original value of the runtime animation
  77534. */
  77535. private _originalValue;
  77536. /**
  77537. * The original blend value of the runtime animation
  77538. */
  77539. private _originalBlendValue;
  77540. /**
  77541. * The offsets cache of the runtime animation
  77542. */
  77543. private _offsetsCache;
  77544. /**
  77545. * The high limits cache of the runtime animation
  77546. */
  77547. private _highLimitsCache;
  77548. /**
  77549. * Specifies if the runtime animation has been stopped
  77550. */
  77551. private _stopped;
  77552. /**
  77553. * The blending factor of the runtime animation
  77554. */
  77555. private _blendingFactor;
  77556. /**
  77557. * The BabylonJS scene
  77558. */
  77559. private _scene;
  77560. /**
  77561. * The current value of the runtime animation
  77562. */
  77563. private _currentValue;
  77564. /** @hidden */
  77565. _animationState: _IAnimationState;
  77566. /**
  77567. * The active target of the runtime animation
  77568. */
  77569. private _activeTargets;
  77570. private _currentActiveTarget;
  77571. private _directTarget;
  77572. /**
  77573. * The target path of the runtime animation
  77574. */
  77575. private _targetPath;
  77576. /**
  77577. * The weight of the runtime animation
  77578. */
  77579. private _weight;
  77580. /**
  77581. * The ratio offset of the runtime animation
  77582. */
  77583. private _ratioOffset;
  77584. /**
  77585. * The previous delay of the runtime animation
  77586. */
  77587. private _previousDelay;
  77588. /**
  77589. * The previous ratio of the runtime animation
  77590. */
  77591. private _previousRatio;
  77592. private _enableBlending;
  77593. private _keys;
  77594. private _minFrame;
  77595. private _maxFrame;
  77596. private _minValue;
  77597. private _maxValue;
  77598. private _targetIsArray;
  77599. /**
  77600. * Gets the current frame of the runtime animation
  77601. */
  77602. readonly currentFrame: number;
  77603. /**
  77604. * Gets the weight of the runtime animation
  77605. */
  77606. readonly weight: number;
  77607. /**
  77608. * Gets the current value of the runtime animation
  77609. */
  77610. readonly currentValue: any;
  77611. /**
  77612. * Gets the target path of the runtime animation
  77613. */
  77614. readonly targetPath: string;
  77615. /**
  77616. * Gets the actual target of the runtime animation
  77617. */
  77618. readonly target: any;
  77619. /** @hidden */
  77620. _onLoop: () => void;
  77621. /**
  77622. * Create a new RuntimeAnimation object
  77623. * @param target defines the target of the animation
  77624. * @param animation defines the source animation object
  77625. * @param scene defines the hosting scene
  77626. * @param host defines the initiating Animatable
  77627. */
  77628. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77629. private _preparePath;
  77630. /**
  77631. * Gets the animation from the runtime animation
  77632. */
  77633. readonly animation: Animation;
  77634. /**
  77635. * Resets the runtime animation to the beginning
  77636. * @param restoreOriginal defines whether to restore the target property to the original value
  77637. */
  77638. reset(restoreOriginal?: boolean): void;
  77639. /**
  77640. * Specifies if the runtime animation is stopped
  77641. * @returns Boolean specifying if the runtime animation is stopped
  77642. */
  77643. isStopped(): boolean;
  77644. /**
  77645. * Disposes of the runtime animation
  77646. */
  77647. dispose(): void;
  77648. /**
  77649. * Apply the interpolated value to the target
  77650. * @param currentValue defines the value computed by the animation
  77651. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77652. */
  77653. setValue(currentValue: any, weight: number): void;
  77654. private _getOriginalValues;
  77655. private _setValue;
  77656. /**
  77657. * Gets the loop pmode of the runtime animation
  77658. * @returns Loop Mode
  77659. */
  77660. private _getCorrectLoopMode;
  77661. /**
  77662. * Move the current animation to a given frame
  77663. * @param frame defines the frame to move to
  77664. */
  77665. goToFrame(frame: number): void;
  77666. /**
  77667. * @hidden Internal use only
  77668. */
  77669. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77670. /**
  77671. * Execute the current animation
  77672. * @param delay defines the delay to add to the current frame
  77673. * @param from defines the lower bound of the animation range
  77674. * @param to defines the upper bound of the animation range
  77675. * @param loop defines if the current animation must loop
  77676. * @param speedRatio defines the current speed ratio
  77677. * @param weight defines the weight of the animation (default is -1 so no weight)
  77678. * @param onLoop optional callback called when animation loops
  77679. * @returns a boolean indicating if the animation is running
  77680. */
  77681. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77682. }
  77683. }
  77684. declare module BABYLON {
  77685. /**
  77686. * Class used to store an actual running animation
  77687. */
  77688. export class Animatable {
  77689. /** defines the target object */
  77690. target: any;
  77691. /** defines the starting frame number (default is 0) */
  77692. fromFrame: number;
  77693. /** defines the ending frame number (default is 100) */
  77694. toFrame: number;
  77695. /** defines if the animation must loop (default is false) */
  77696. loopAnimation: boolean;
  77697. /** defines a callback to call when animation ends if it is not looping */
  77698. onAnimationEnd?: (() => void) | null | undefined;
  77699. /** defines a callback to call when animation loops */
  77700. onAnimationLoop?: (() => void) | null | undefined;
  77701. private _localDelayOffset;
  77702. private _pausedDelay;
  77703. private _runtimeAnimations;
  77704. private _paused;
  77705. private _scene;
  77706. private _speedRatio;
  77707. private _weight;
  77708. private _syncRoot;
  77709. /**
  77710. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77711. * This will only apply for non looping animation (default is true)
  77712. */
  77713. disposeOnEnd: boolean;
  77714. /**
  77715. * Gets a boolean indicating if the animation has started
  77716. */
  77717. animationStarted: boolean;
  77718. /**
  77719. * Observer raised when the animation ends
  77720. */
  77721. onAnimationEndObservable: Observable<Animatable>;
  77722. /**
  77723. * Observer raised when the animation loops
  77724. */
  77725. onAnimationLoopObservable: Observable<Animatable>;
  77726. /**
  77727. * Gets the root Animatable used to synchronize and normalize animations
  77728. */
  77729. readonly syncRoot: Nullable<Animatable>;
  77730. /**
  77731. * Gets the current frame of the first RuntimeAnimation
  77732. * Used to synchronize Animatables
  77733. */
  77734. readonly masterFrame: number;
  77735. /**
  77736. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77737. */
  77738. weight: number;
  77739. /**
  77740. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77741. */
  77742. speedRatio: number;
  77743. /**
  77744. * Creates a new Animatable
  77745. * @param scene defines the hosting scene
  77746. * @param target defines the target object
  77747. * @param fromFrame defines the starting frame number (default is 0)
  77748. * @param toFrame defines the ending frame number (default is 100)
  77749. * @param loopAnimation defines if the animation must loop (default is false)
  77750. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77751. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77752. * @param animations defines a group of animation to add to the new Animatable
  77753. * @param onAnimationLoop defines a callback to call when animation loops
  77754. */
  77755. constructor(scene: Scene,
  77756. /** defines the target object */
  77757. target: any,
  77758. /** defines the starting frame number (default is 0) */
  77759. fromFrame?: number,
  77760. /** defines the ending frame number (default is 100) */
  77761. toFrame?: number,
  77762. /** defines if the animation must loop (default is false) */
  77763. loopAnimation?: boolean, speedRatio?: number,
  77764. /** defines a callback to call when animation ends if it is not looping */
  77765. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77766. /** defines a callback to call when animation loops */
  77767. onAnimationLoop?: (() => void) | null | undefined);
  77768. /**
  77769. * Synchronize and normalize current Animatable with a source Animatable
  77770. * This is useful when using animation weights and when animations are not of the same length
  77771. * @param root defines the root Animatable to synchronize with
  77772. * @returns the current Animatable
  77773. */
  77774. syncWith(root: Animatable): Animatable;
  77775. /**
  77776. * Gets the list of runtime animations
  77777. * @returns an array of RuntimeAnimation
  77778. */
  77779. getAnimations(): RuntimeAnimation[];
  77780. /**
  77781. * Adds more animations to the current animatable
  77782. * @param target defines the target of the animations
  77783. * @param animations defines the new animations to add
  77784. */
  77785. appendAnimations(target: any, animations: Animation[]): void;
  77786. /**
  77787. * Gets the source animation for a specific property
  77788. * @param property defines the propertyu to look for
  77789. * @returns null or the source animation for the given property
  77790. */
  77791. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77792. /**
  77793. * Gets the runtime animation for a specific property
  77794. * @param property defines the propertyu to look for
  77795. * @returns null or the runtime animation for the given property
  77796. */
  77797. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77798. /**
  77799. * Resets the animatable to its original state
  77800. */
  77801. reset(): void;
  77802. /**
  77803. * Allows the animatable to blend with current running animations
  77804. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77805. * @param blendingSpeed defines the blending speed to use
  77806. */
  77807. enableBlending(blendingSpeed: number): void;
  77808. /**
  77809. * Disable animation blending
  77810. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77811. */
  77812. disableBlending(): void;
  77813. /**
  77814. * Jump directly to a given frame
  77815. * @param frame defines the frame to jump to
  77816. */
  77817. goToFrame(frame: number): void;
  77818. /**
  77819. * Pause the animation
  77820. */
  77821. pause(): void;
  77822. /**
  77823. * Restart the animation
  77824. */
  77825. restart(): void;
  77826. private _raiseOnAnimationEnd;
  77827. /**
  77828. * Stop and delete the current animation
  77829. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77830. * @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)
  77831. */
  77832. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77833. /**
  77834. * Wait asynchronously for the animation to end
  77835. * @returns a promise which will be fullfilled when the animation ends
  77836. */
  77837. waitAsync(): Promise<Animatable>;
  77838. /** @hidden */
  77839. _animate(delay: number): boolean;
  77840. }
  77841. interface Scene {
  77842. /** @hidden */
  77843. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77844. /** @hidden */
  77845. _processLateAnimationBindingsForMatrices(holder: {
  77846. totalWeight: number;
  77847. animations: RuntimeAnimation[];
  77848. originalValue: Matrix;
  77849. }): any;
  77850. /** @hidden */
  77851. _processLateAnimationBindingsForQuaternions(holder: {
  77852. totalWeight: number;
  77853. animations: RuntimeAnimation[];
  77854. originalValue: Quaternion;
  77855. }, refQuaternion: Quaternion): Quaternion;
  77856. /** @hidden */
  77857. _processLateAnimationBindings(): void;
  77858. /**
  77859. * Will start the animation sequence of a given target
  77860. * @param target defines the target
  77861. * @param from defines from which frame should animation start
  77862. * @param to defines until which frame should animation run.
  77863. * @param weight defines the weight to apply to the animation (1.0 by default)
  77864. * @param loop defines if the animation loops
  77865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77866. * @param onAnimationEnd defines the function to be executed when the animation ends
  77867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77868. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77869. * @param onAnimationLoop defines the callback to call when an animation loops
  77870. * @returns the animatable object created for this animation
  77871. */
  77872. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77873. /**
  77874. * Will start the animation sequence of a given target
  77875. * @param target defines the target
  77876. * @param from defines from which frame should animation start
  77877. * @param to defines until which frame should animation run.
  77878. * @param loop defines if the animation loops
  77879. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77880. * @param onAnimationEnd defines the function to be executed when the animation ends
  77881. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77882. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77883. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77884. * @param onAnimationLoop defines the callback to call when an animation loops
  77885. * @returns the animatable object created for this animation
  77886. */
  77887. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77888. /**
  77889. * Will start the animation sequence of a given target and its hierarchy
  77890. * @param target defines the target
  77891. * @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.
  77892. * @param from defines from which frame should animation start
  77893. * @param to defines until which frame should animation run.
  77894. * @param loop defines if the animation loops
  77895. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77896. * @param onAnimationEnd defines the function to be executed when the animation ends
  77897. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77898. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77899. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77900. * @param onAnimationLoop defines the callback to call when an animation loops
  77901. * @returns the list of created animatables
  77902. */
  77903. 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[];
  77904. /**
  77905. * Begin a new animation on a given node
  77906. * @param target defines the target where the animation will take place
  77907. * @param animations defines the list of animations to start
  77908. * @param from defines the initial value
  77909. * @param to defines the final value
  77910. * @param loop defines if you want animation to loop (off by default)
  77911. * @param speedRatio defines the speed ratio to apply to all animations
  77912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77913. * @param onAnimationLoop defines the callback to call when an animation loops
  77914. * @returns the list of created animatables
  77915. */
  77916. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77917. /**
  77918. * Begin a new animation on a given node and its hierarchy
  77919. * @param target defines the root node where the animation will take place
  77920. * @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.
  77921. * @param animations defines the list of animations to start
  77922. * @param from defines the initial value
  77923. * @param to defines the final value
  77924. * @param loop defines if you want animation to loop (off by default)
  77925. * @param speedRatio defines the speed ratio to apply to all animations
  77926. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77927. * @param onAnimationLoop defines the callback to call when an animation loops
  77928. * @returns the list of animatables created for all nodes
  77929. */
  77930. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77931. /**
  77932. * Gets the animatable associated with a specific target
  77933. * @param target defines the target of the animatable
  77934. * @returns the required animatable if found
  77935. */
  77936. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77937. /**
  77938. * Gets all animatables associated with a given target
  77939. * @param target defines the target to look animatables for
  77940. * @returns an array of Animatables
  77941. */
  77942. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77943. /**
  77944. * Stops and removes all animations that have been applied to the scene
  77945. */
  77946. stopAllAnimations(): void;
  77947. }
  77948. interface Bone {
  77949. /**
  77950. * Copy an animation range from another bone
  77951. * @param source defines the source bone
  77952. * @param rangeName defines the range name to copy
  77953. * @param frameOffset defines the frame offset
  77954. * @param rescaleAsRequired defines if rescaling must be applied if required
  77955. * @param skelDimensionsRatio defines the scaling ratio
  77956. * @returns true if operation was successful
  77957. */
  77958. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77959. }
  77960. }
  77961. declare module BABYLON {
  77962. /**
  77963. * Class used to override all child animations of a given target
  77964. */
  77965. export class AnimationPropertiesOverride {
  77966. /**
  77967. * Gets or sets a value indicating if animation blending must be used
  77968. */
  77969. enableBlending: boolean;
  77970. /**
  77971. * Gets or sets the blending speed to use when enableBlending is true
  77972. */
  77973. blendingSpeed: number;
  77974. /**
  77975. * Gets or sets the default loop mode to use
  77976. */
  77977. loopMode: number;
  77978. }
  77979. }
  77980. declare module BABYLON {
  77981. /**
  77982. * Class used to handle skinning animations
  77983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77984. */
  77985. export class Skeleton implements IAnimatable {
  77986. /** defines the skeleton name */
  77987. name: string;
  77988. /** defines the skeleton Id */
  77989. id: string;
  77990. /**
  77991. * Defines the list of child bones
  77992. */
  77993. bones: Bone[];
  77994. /**
  77995. * Defines an estimate of the dimension of the skeleton at rest
  77996. */
  77997. dimensionsAtRest: Vector3;
  77998. /**
  77999. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78000. */
  78001. needInitialSkinMatrix: boolean;
  78002. /**
  78003. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78004. */
  78005. overrideMesh: Nullable<AbstractMesh>;
  78006. /**
  78007. * Gets the list of animations attached to this skeleton
  78008. */
  78009. animations: Array<Animation>;
  78010. private _scene;
  78011. private _isDirty;
  78012. private _transformMatrices;
  78013. private _transformMatrixTexture;
  78014. private _meshesWithPoseMatrix;
  78015. private _animatables;
  78016. private _identity;
  78017. private _synchronizedWithMesh;
  78018. private _ranges;
  78019. private _lastAbsoluteTransformsUpdateId;
  78020. private _canUseTextureForBones;
  78021. private _uniqueId;
  78022. /** @hidden */
  78023. _numBonesWithLinkedTransformNode: number;
  78024. /** @hidden */
  78025. _hasWaitingData: Nullable<boolean>;
  78026. /**
  78027. * Specifies if the skeleton should be serialized
  78028. */
  78029. doNotSerialize: boolean;
  78030. private _useTextureToStoreBoneMatrices;
  78031. /**
  78032. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78033. * Please note that this option is not available if the hardware does not support it
  78034. */
  78035. useTextureToStoreBoneMatrices: boolean;
  78036. private _animationPropertiesOverride;
  78037. /**
  78038. * Gets or sets the animation properties override
  78039. */
  78040. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78041. /**
  78042. * List of inspectable custom properties (used by the Inspector)
  78043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78044. */
  78045. inspectableCustomProperties: IInspectable[];
  78046. /**
  78047. * An observable triggered before computing the skeleton's matrices
  78048. */
  78049. onBeforeComputeObservable: Observable<Skeleton>;
  78050. /**
  78051. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78052. */
  78053. readonly isUsingTextureForMatrices: boolean;
  78054. /**
  78055. * Gets the unique ID of this skeleton
  78056. */
  78057. readonly uniqueId: number;
  78058. /**
  78059. * Creates a new skeleton
  78060. * @param name defines the skeleton name
  78061. * @param id defines the skeleton Id
  78062. * @param scene defines the hosting scene
  78063. */
  78064. constructor(
  78065. /** defines the skeleton name */
  78066. name: string,
  78067. /** defines the skeleton Id */
  78068. id: string, scene: Scene);
  78069. /**
  78070. * Gets the current object class name.
  78071. * @return the class name
  78072. */
  78073. getClassName(): string;
  78074. /**
  78075. * Returns an array containing the root bones
  78076. * @returns an array containing the root bones
  78077. */
  78078. getChildren(): Array<Bone>;
  78079. /**
  78080. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78081. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78082. * @returns a Float32Array containing matrices data
  78083. */
  78084. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78085. /**
  78086. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78087. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78088. * @returns a raw texture containing the data
  78089. */
  78090. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78091. /**
  78092. * Gets the current hosting scene
  78093. * @returns a scene object
  78094. */
  78095. getScene(): Scene;
  78096. /**
  78097. * Gets a string representing the current skeleton data
  78098. * @param fullDetails defines a boolean indicating if we want a verbose version
  78099. * @returns a string representing the current skeleton data
  78100. */
  78101. toString(fullDetails?: boolean): string;
  78102. /**
  78103. * Get bone's index searching by name
  78104. * @param name defines bone's name to search for
  78105. * @return the indice of the bone. Returns -1 if not found
  78106. */
  78107. getBoneIndexByName(name: string): number;
  78108. /**
  78109. * Creater a new animation range
  78110. * @param name defines the name of the range
  78111. * @param from defines the start key
  78112. * @param to defines the end key
  78113. */
  78114. createAnimationRange(name: string, from: number, to: number): void;
  78115. /**
  78116. * Delete a specific animation range
  78117. * @param name defines the name of the range
  78118. * @param deleteFrames defines if frames must be removed as well
  78119. */
  78120. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78121. /**
  78122. * Gets a specific animation range
  78123. * @param name defines the name of the range to look for
  78124. * @returns the requested animation range or null if not found
  78125. */
  78126. getAnimationRange(name: string): Nullable<AnimationRange>;
  78127. /**
  78128. * Gets the list of all animation ranges defined on this skeleton
  78129. * @returns an array
  78130. */
  78131. getAnimationRanges(): Nullable<AnimationRange>[];
  78132. /**
  78133. * Copy animation range from a source skeleton.
  78134. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78135. * @param source defines the source skeleton
  78136. * @param name defines the name of the range to copy
  78137. * @param rescaleAsRequired defines if rescaling must be applied if required
  78138. * @returns true if operation was successful
  78139. */
  78140. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78141. /**
  78142. * Forces the skeleton to go to rest pose
  78143. */
  78144. returnToRest(): void;
  78145. private _getHighestAnimationFrame;
  78146. /**
  78147. * Begin a specific animation range
  78148. * @param name defines the name of the range to start
  78149. * @param loop defines if looping must be turned on (false by default)
  78150. * @param speedRatio defines the speed ratio to apply (1 by default)
  78151. * @param onAnimationEnd defines a callback which will be called when animation will end
  78152. * @returns a new animatable
  78153. */
  78154. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78155. /** @hidden */
  78156. _markAsDirty(): void;
  78157. /** @hidden */
  78158. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78159. /** @hidden */
  78160. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78161. private _computeTransformMatrices;
  78162. /**
  78163. * Build all resources required to render a skeleton
  78164. */
  78165. prepare(): void;
  78166. /**
  78167. * Gets the list of animatables currently running for this skeleton
  78168. * @returns an array of animatables
  78169. */
  78170. getAnimatables(): IAnimatable[];
  78171. /**
  78172. * Clone the current skeleton
  78173. * @param name defines the name of the new skeleton
  78174. * @param id defines the id of the new skeleton
  78175. * @returns the new skeleton
  78176. */
  78177. clone(name: string, id: string): Skeleton;
  78178. /**
  78179. * Enable animation blending for this skeleton
  78180. * @param blendingSpeed defines the blending speed to apply
  78181. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78182. */
  78183. enableBlending(blendingSpeed?: number): void;
  78184. /**
  78185. * Releases all resources associated with the current skeleton
  78186. */
  78187. dispose(): void;
  78188. /**
  78189. * Serialize the skeleton in a JSON object
  78190. * @returns a JSON object
  78191. */
  78192. serialize(): any;
  78193. /**
  78194. * Creates a new skeleton from serialized data
  78195. * @param parsedSkeleton defines the serialized data
  78196. * @param scene defines the hosting scene
  78197. * @returns a new skeleton
  78198. */
  78199. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78200. /**
  78201. * Compute all node absolute transforms
  78202. * @param forceUpdate defines if computation must be done even if cache is up to date
  78203. */
  78204. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78205. /**
  78206. * Gets the root pose matrix
  78207. * @returns a matrix
  78208. */
  78209. getPoseMatrix(): Nullable<Matrix>;
  78210. /**
  78211. * Sorts bones per internal index
  78212. */
  78213. sortBones(): void;
  78214. private _sortBones;
  78215. }
  78216. }
  78217. declare module BABYLON {
  78218. /**
  78219. * Class used to store bone information
  78220. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78221. */
  78222. export class Bone extends Node {
  78223. /**
  78224. * defines the bone name
  78225. */
  78226. name: string;
  78227. private static _tmpVecs;
  78228. private static _tmpQuat;
  78229. private static _tmpMats;
  78230. /**
  78231. * Gets the list of child bones
  78232. */
  78233. children: Bone[];
  78234. /** Gets the animations associated with this bone */
  78235. animations: Animation[];
  78236. /**
  78237. * Gets or sets bone length
  78238. */
  78239. length: number;
  78240. /**
  78241. * @hidden Internal only
  78242. * Set this value to map this bone to a different index in the transform matrices
  78243. * Set this value to -1 to exclude the bone from the transform matrices
  78244. */
  78245. _index: Nullable<number>;
  78246. private _skeleton;
  78247. private _localMatrix;
  78248. private _restPose;
  78249. private _baseMatrix;
  78250. private _absoluteTransform;
  78251. private _invertedAbsoluteTransform;
  78252. private _parent;
  78253. private _scalingDeterminant;
  78254. private _worldTransform;
  78255. private _localScaling;
  78256. private _localRotation;
  78257. private _localPosition;
  78258. private _needToDecompose;
  78259. private _needToCompose;
  78260. /** @hidden */
  78261. _linkedTransformNode: Nullable<TransformNode>;
  78262. /** @hidden */
  78263. _waitingTransformNodeId: Nullable<string>;
  78264. /** @hidden */
  78265. /** @hidden */
  78266. _matrix: Matrix;
  78267. /**
  78268. * Create a new bone
  78269. * @param name defines the bone name
  78270. * @param skeleton defines the parent skeleton
  78271. * @param parentBone defines the parent (can be null if the bone is the root)
  78272. * @param localMatrix defines the local matrix
  78273. * @param restPose defines the rest pose matrix
  78274. * @param baseMatrix defines the base matrix
  78275. * @param index defines index of the bone in the hiearchy
  78276. */
  78277. constructor(
  78278. /**
  78279. * defines the bone name
  78280. */
  78281. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78282. /**
  78283. * Gets the current object class name.
  78284. * @return the class name
  78285. */
  78286. getClassName(): string;
  78287. /**
  78288. * Gets the parent skeleton
  78289. * @returns a skeleton
  78290. */
  78291. getSkeleton(): Skeleton;
  78292. /**
  78293. * Gets parent bone
  78294. * @returns a bone or null if the bone is the root of the bone hierarchy
  78295. */
  78296. getParent(): Nullable<Bone>;
  78297. /**
  78298. * Returns an array containing the root bones
  78299. * @returns an array containing the root bones
  78300. */
  78301. getChildren(): Array<Bone>;
  78302. /**
  78303. * Sets the parent bone
  78304. * @param parent defines the parent (can be null if the bone is the root)
  78305. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78306. */
  78307. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78308. /**
  78309. * Gets the local matrix
  78310. * @returns a matrix
  78311. */
  78312. getLocalMatrix(): Matrix;
  78313. /**
  78314. * Gets the base matrix (initial matrix which remains unchanged)
  78315. * @returns a matrix
  78316. */
  78317. getBaseMatrix(): Matrix;
  78318. /**
  78319. * Gets the rest pose matrix
  78320. * @returns a matrix
  78321. */
  78322. getRestPose(): Matrix;
  78323. /**
  78324. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78325. */
  78326. getWorldMatrix(): Matrix;
  78327. /**
  78328. * Sets the local matrix to rest pose matrix
  78329. */
  78330. returnToRest(): void;
  78331. /**
  78332. * Gets the inverse of the absolute transform matrix.
  78333. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78334. * @returns a matrix
  78335. */
  78336. getInvertedAbsoluteTransform(): Matrix;
  78337. /**
  78338. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78339. * @returns a matrix
  78340. */
  78341. getAbsoluteTransform(): Matrix;
  78342. /**
  78343. * Links with the given transform node.
  78344. * The local matrix of this bone is copied from the transform node every frame.
  78345. * @param transformNode defines the transform node to link to
  78346. */
  78347. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78348. /**
  78349. * Gets the node used to drive the bone's transformation
  78350. * @returns a transform node or null
  78351. */
  78352. getTransformNode(): Nullable<TransformNode>;
  78353. /** Gets or sets current position (in local space) */
  78354. position: Vector3;
  78355. /** Gets or sets current rotation (in local space) */
  78356. rotation: Vector3;
  78357. /** Gets or sets current rotation quaternion (in local space) */
  78358. rotationQuaternion: Quaternion;
  78359. /** Gets or sets current scaling (in local space) */
  78360. scaling: Vector3;
  78361. /**
  78362. * Gets the animation properties override
  78363. */
  78364. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78365. private _decompose;
  78366. private _compose;
  78367. /**
  78368. * Update the base and local matrices
  78369. * @param matrix defines the new base or local matrix
  78370. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78371. * @param updateLocalMatrix defines if the local matrix should be updated
  78372. */
  78373. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78374. /** @hidden */
  78375. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78376. /**
  78377. * Flag the bone as dirty (Forcing it to update everything)
  78378. */
  78379. markAsDirty(): void;
  78380. /** @hidden */
  78381. _markAsDirtyAndCompose(): void;
  78382. private _markAsDirtyAndDecompose;
  78383. /**
  78384. * Translate the bone in local or world space
  78385. * @param vec The amount to translate the bone
  78386. * @param space The space that the translation is in
  78387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78388. */
  78389. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78390. /**
  78391. * Set the postion of the bone in local or world space
  78392. * @param position The position to set the bone
  78393. * @param space The space that the position is in
  78394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78395. */
  78396. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78397. /**
  78398. * Set the absolute position of the bone (world space)
  78399. * @param position The position to set the bone
  78400. * @param mesh The mesh that this bone is attached to
  78401. */
  78402. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78403. /**
  78404. * Scale the bone on the x, y and z axes (in local space)
  78405. * @param x The amount to scale the bone on the x axis
  78406. * @param y The amount to scale the bone on the y axis
  78407. * @param z The amount to scale the bone on the z axis
  78408. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  78409. */
  78410. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78411. /**
  78412. * Set the bone scaling in local space
  78413. * @param scale defines the scaling vector
  78414. */
  78415. setScale(scale: Vector3): void;
  78416. /**
  78417. * Gets the current scaling in local space
  78418. * @returns the current scaling vector
  78419. */
  78420. getScale(): Vector3;
  78421. /**
  78422. * Gets the current scaling in local space and stores it in a target vector
  78423. * @param result defines the target vector
  78424. */
  78425. getScaleToRef(result: Vector3): void;
  78426. /**
  78427. * Set the yaw, pitch, and roll of the bone in local or world space
  78428. * @param yaw The rotation of the bone on the y axis
  78429. * @param pitch The rotation of the bone on the x axis
  78430. * @param roll The rotation of the bone on the z axis
  78431. * @param space The space that the axes of rotation are in
  78432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78433. */
  78434. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78435. /**
  78436. * Add a rotation to the bone on an axis in local or world space
  78437. * @param axis The axis to rotate the bone on
  78438. * @param amount The amount to rotate the bone
  78439. * @param space The space that the axis is in
  78440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78441. */
  78442. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78443. /**
  78444. * Set the rotation of the bone to a particular axis angle in local or world space
  78445. * @param axis The axis to rotate the bone on
  78446. * @param angle The angle that the bone should be rotated to
  78447. * @param space The space that the axis is in
  78448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78449. */
  78450. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78451. /**
  78452. * Set the euler rotation of the bone in local of world space
  78453. * @param rotation The euler rotation that the bone should be set to
  78454. * @param space The space that the rotation is in
  78455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78456. */
  78457. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78458. /**
  78459. * Set the quaternion rotation of the bone in local of world space
  78460. * @param quat The quaternion rotation that the bone should be set to
  78461. * @param space The space that the rotation is in
  78462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78463. */
  78464. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78465. /**
  78466. * Set the rotation matrix of the bone in local of world space
  78467. * @param rotMat The rotation matrix that the bone should be set to
  78468. * @param space The space that the rotation is in
  78469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78470. */
  78471. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78472. private _rotateWithMatrix;
  78473. private _getNegativeRotationToRef;
  78474. /**
  78475. * Get the position of the bone in local or world space
  78476. * @param space The space that the returned position is in
  78477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78478. * @returns The position of the bone
  78479. */
  78480. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78481. /**
  78482. * Copy the position of the bone to a vector3 in local or world space
  78483. * @param space The space that the returned position is in
  78484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78485. * @param result The vector3 to copy the position to
  78486. */
  78487. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78488. /**
  78489. * Get the absolute position of the bone (world space)
  78490. * @param mesh The mesh that this bone is attached to
  78491. * @returns The absolute position of the bone
  78492. */
  78493. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78494. /**
  78495. * Copy the absolute position of the bone (world space) to the result param
  78496. * @param mesh The mesh that this bone is attached to
  78497. * @param result The vector3 to copy the absolute position to
  78498. */
  78499. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78500. /**
  78501. * Compute the absolute transforms of this bone and its children
  78502. */
  78503. computeAbsoluteTransforms(): void;
  78504. /**
  78505. * Get the world direction from an axis that is in the local space of the bone
  78506. * @param localAxis The local direction that is used to compute the world direction
  78507. * @param mesh The mesh that this bone is attached to
  78508. * @returns The world direction
  78509. */
  78510. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78511. /**
  78512. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78513. * @param localAxis The local direction that is used to compute the world direction
  78514. * @param mesh The mesh that this bone is attached to
  78515. * @param result The vector3 that the world direction will be copied to
  78516. */
  78517. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78518. /**
  78519. * Get the euler rotation of the bone in local or world space
  78520. * @param space The space that the rotation should be in
  78521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78522. * @returns The euler rotation
  78523. */
  78524. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78525. /**
  78526. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78527. * @param space The space that the rotation should be in
  78528. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78529. * @param result The vector3 that the rotation should be copied to
  78530. */
  78531. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78532. /**
  78533. * Get the quaternion rotation of the bone in either local or world space
  78534. * @param space The space that the rotation should be in
  78535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78536. * @returns The quaternion rotation
  78537. */
  78538. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78539. /**
  78540. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78541. * @param space The space that the rotation should be in
  78542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78543. * @param result The quaternion that the rotation should be copied to
  78544. */
  78545. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78546. /**
  78547. * Get the rotation matrix of the bone in local or world space
  78548. * @param space The space that the rotation should be in
  78549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78550. * @returns The rotation matrix
  78551. */
  78552. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78553. /**
  78554. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78555. * @param space The space that the rotation should be in
  78556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78557. * @param result The quaternion that the rotation should be copied to
  78558. */
  78559. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78560. /**
  78561. * Get the world position of a point that is in the local space of the bone
  78562. * @param position The local position
  78563. * @param mesh The mesh that this bone is attached to
  78564. * @returns The world position
  78565. */
  78566. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78567. /**
  78568. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78569. * @param position The local position
  78570. * @param mesh The mesh that this bone is attached to
  78571. * @param result The vector3 that the world position should be copied to
  78572. */
  78573. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78574. /**
  78575. * Get the local position of a point that is in world space
  78576. * @param position The world position
  78577. * @param mesh The mesh that this bone is attached to
  78578. * @returns The local position
  78579. */
  78580. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78581. /**
  78582. * Get the local position of a point that is in world space and copy it to the result param
  78583. * @param position The world position
  78584. * @param mesh The mesh that this bone is attached to
  78585. * @param result The vector3 that the local position should be copied to
  78586. */
  78587. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78588. }
  78589. }
  78590. declare module BABYLON {
  78591. /**
  78592. * 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.
  78593. * @see https://doc.babylonjs.com/how_to/transformnode
  78594. */
  78595. export class TransformNode extends Node {
  78596. /**
  78597. * Object will not rotate to face the camera
  78598. */
  78599. static BILLBOARDMODE_NONE: number;
  78600. /**
  78601. * Object will rotate to face the camera but only on the x axis
  78602. */
  78603. static BILLBOARDMODE_X: number;
  78604. /**
  78605. * Object will rotate to face the camera but only on the y axis
  78606. */
  78607. static BILLBOARDMODE_Y: number;
  78608. /**
  78609. * Object will rotate to face the camera but only on the z axis
  78610. */
  78611. static BILLBOARDMODE_Z: number;
  78612. /**
  78613. * Object will rotate to face the camera
  78614. */
  78615. static BILLBOARDMODE_ALL: number;
  78616. /**
  78617. * Object will rotate to face the camera's position instead of orientation
  78618. */
  78619. static BILLBOARDMODE_USE_POSITION: number;
  78620. private _forward;
  78621. private _forwardInverted;
  78622. private _up;
  78623. private _right;
  78624. private _rightInverted;
  78625. private _position;
  78626. private _rotation;
  78627. private _rotationQuaternion;
  78628. protected _scaling: Vector3;
  78629. protected _isDirty: boolean;
  78630. private _transformToBoneReferal;
  78631. private _isAbsoluteSynced;
  78632. private _billboardMode;
  78633. /**
  78634. * Gets or sets the billboard mode. Default is 0.
  78635. *
  78636. * | Value | Type | Description |
  78637. * | --- | --- | --- |
  78638. * | 0 | BILLBOARDMODE_NONE | |
  78639. * | 1 | BILLBOARDMODE_X | |
  78640. * | 2 | BILLBOARDMODE_Y | |
  78641. * | 4 | BILLBOARDMODE_Z | |
  78642. * | 7 | BILLBOARDMODE_ALL | |
  78643. *
  78644. */
  78645. billboardMode: number;
  78646. private _preserveParentRotationForBillboard;
  78647. /**
  78648. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78649. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78650. */
  78651. preserveParentRotationForBillboard: boolean;
  78652. /**
  78653. * 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
  78654. */
  78655. scalingDeterminant: number;
  78656. private _infiniteDistance;
  78657. /**
  78658. * Gets or sets the distance of the object to max, often used by skybox
  78659. */
  78660. infiniteDistance: boolean;
  78661. /**
  78662. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78663. * By default the system will update normals to compensate
  78664. */
  78665. ignoreNonUniformScaling: boolean;
  78666. /**
  78667. * 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
  78668. */
  78669. reIntegrateRotationIntoRotationQuaternion: boolean;
  78670. /** @hidden */
  78671. _poseMatrix: Nullable<Matrix>;
  78672. /** @hidden */
  78673. _localMatrix: Matrix;
  78674. private _usePivotMatrix;
  78675. private _absolutePosition;
  78676. private _absoluteScaling;
  78677. private _absoluteRotationQuaternion;
  78678. private _pivotMatrix;
  78679. private _pivotMatrixInverse;
  78680. protected _postMultiplyPivotMatrix: boolean;
  78681. protected _isWorldMatrixFrozen: boolean;
  78682. /** @hidden */
  78683. _indexInSceneTransformNodesArray: number;
  78684. /**
  78685. * An event triggered after the world matrix is updated
  78686. */
  78687. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78688. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78689. /**
  78690. * Gets a string identifying the name of the class
  78691. * @returns "TransformNode" string
  78692. */
  78693. getClassName(): string;
  78694. /**
  78695. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78696. */
  78697. position: Vector3;
  78698. /**
  78699. * 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)).
  78700. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78701. */
  78702. rotation: Vector3;
  78703. /**
  78704. * 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)).
  78705. */
  78706. scaling: Vector3;
  78707. /**
  78708. * 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).
  78709. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78710. */
  78711. rotationQuaternion: Nullable<Quaternion>;
  78712. /**
  78713. * The forward direction of that transform in world space.
  78714. */
  78715. readonly forward: Vector3;
  78716. /**
  78717. * The up direction of that transform in world space.
  78718. */
  78719. readonly up: Vector3;
  78720. /**
  78721. * The right direction of that transform in world space.
  78722. */
  78723. readonly right: Vector3;
  78724. /**
  78725. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78726. * @param matrix the matrix to copy the pose from
  78727. * @returns this TransformNode.
  78728. */
  78729. updatePoseMatrix(matrix: Matrix): TransformNode;
  78730. /**
  78731. * Returns the mesh Pose matrix.
  78732. * @returns the pose matrix
  78733. */
  78734. getPoseMatrix(): Matrix;
  78735. /** @hidden */
  78736. _isSynchronized(): boolean;
  78737. /** @hidden */
  78738. _initCache(): void;
  78739. /**
  78740. * Flag the transform node as dirty (Forcing it to update everything)
  78741. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78742. * @returns this transform node
  78743. */
  78744. markAsDirty(property: string): TransformNode;
  78745. /**
  78746. * Returns the current mesh absolute position.
  78747. * Returns a Vector3.
  78748. */
  78749. readonly absolutePosition: Vector3;
  78750. /**
  78751. * Returns the current mesh absolute scaling.
  78752. * Returns a Vector3.
  78753. */
  78754. readonly absoluteScaling: Vector3;
  78755. /**
  78756. * Returns the current mesh absolute rotation.
  78757. * Returns a Quaternion.
  78758. */
  78759. readonly absoluteRotationQuaternion: Quaternion;
  78760. /**
  78761. * Sets a new matrix to apply before all other transformation
  78762. * @param matrix defines the transform matrix
  78763. * @returns the current TransformNode
  78764. */
  78765. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78766. /**
  78767. * Sets a new pivot matrix to the current node
  78768. * @param matrix defines the new pivot matrix to use
  78769. * @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
  78770. * @returns the current TransformNode
  78771. */
  78772. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78773. /**
  78774. * Returns the mesh pivot matrix.
  78775. * Default : Identity.
  78776. * @returns the matrix
  78777. */
  78778. getPivotMatrix(): Matrix;
  78779. /**
  78780. * Instantiate (when possible) or clone that node with its hierarchy
  78781. * @param newParent defines the new parent to use for the instance (or clone)
  78782. * @returns an instance (or a clone) of the current node with its hiearchy
  78783. */
  78784. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  78785. /**
  78786. * Prevents the World matrix to be computed any longer
  78787. * @param newWorldMatrix defines an optional matrix to use as world matrix
  78788. * @returns the TransformNode.
  78789. */
  78790. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  78791. /**
  78792. * Allows back the World matrix computation.
  78793. * @returns the TransformNode.
  78794. */
  78795. unfreezeWorldMatrix(): this;
  78796. /**
  78797. * True if the World matrix has been frozen.
  78798. */
  78799. readonly isWorldMatrixFrozen: boolean;
  78800. /**
  78801. * Retuns the mesh absolute position in the World.
  78802. * @returns a Vector3.
  78803. */
  78804. getAbsolutePosition(): Vector3;
  78805. /**
  78806. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78807. * @param absolutePosition the absolute position to set
  78808. * @returns the TransformNode.
  78809. */
  78810. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78811. /**
  78812. * Sets the mesh position in its local space.
  78813. * @param vector3 the position to set in localspace
  78814. * @returns the TransformNode.
  78815. */
  78816. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78817. /**
  78818. * Returns the mesh position in the local space from the current World matrix values.
  78819. * @returns a new Vector3.
  78820. */
  78821. getPositionExpressedInLocalSpace(): Vector3;
  78822. /**
  78823. * Translates the mesh along the passed Vector3 in its local space.
  78824. * @param vector3 the distance to translate in localspace
  78825. * @returns the TransformNode.
  78826. */
  78827. locallyTranslate(vector3: Vector3): TransformNode;
  78828. private static _lookAtVectorCache;
  78829. /**
  78830. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78831. * @param targetPoint the position (must be in same space as current mesh) to look at
  78832. * @param yawCor optional yaw (y-axis) correction in radians
  78833. * @param pitchCor optional pitch (x-axis) correction in radians
  78834. * @param rollCor optional roll (z-axis) correction in radians
  78835. * @param space the choosen space of the target
  78836. * @returns the TransformNode.
  78837. */
  78838. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78839. /**
  78840. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78841. * This Vector3 is expressed in the World space.
  78842. * @param localAxis axis to rotate
  78843. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78844. */
  78845. getDirection(localAxis: Vector3): Vector3;
  78846. /**
  78847. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78848. * localAxis is expressed in the mesh local space.
  78849. * result is computed in the Wordl space from the mesh World matrix.
  78850. * @param localAxis axis to rotate
  78851. * @param result the resulting transformnode
  78852. * @returns this TransformNode.
  78853. */
  78854. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78855. /**
  78856. * Sets this transform node rotation to the given local axis.
  78857. * @param localAxis the axis in local space
  78858. * @param yawCor optional yaw (y-axis) correction in radians
  78859. * @param pitchCor optional pitch (x-axis) correction in radians
  78860. * @param rollCor optional roll (z-axis) correction in radians
  78861. * @returns this TransformNode
  78862. */
  78863. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78864. /**
  78865. * Sets a new pivot point to the current node
  78866. * @param point defines the new pivot point to use
  78867. * @param space defines if the point is in world or local space (local by default)
  78868. * @returns the current TransformNode
  78869. */
  78870. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78871. /**
  78872. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78873. * @returns the pivot point
  78874. */
  78875. getPivotPoint(): Vector3;
  78876. /**
  78877. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78878. * @param result the vector3 to store the result
  78879. * @returns this TransformNode.
  78880. */
  78881. getPivotPointToRef(result: Vector3): TransformNode;
  78882. /**
  78883. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78884. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78885. */
  78886. getAbsolutePivotPoint(): Vector3;
  78887. /**
  78888. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78889. * @param result vector3 to store the result
  78890. * @returns this TransformNode.
  78891. */
  78892. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78893. /**
  78894. * Defines the passed node as the parent of the current node.
  78895. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78896. * @see https://doc.babylonjs.com/how_to/parenting
  78897. * @param node the node ot set as the parent
  78898. * @returns this TransformNode.
  78899. */
  78900. setParent(node: Nullable<Node>): TransformNode;
  78901. private _nonUniformScaling;
  78902. /**
  78903. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78904. */
  78905. readonly nonUniformScaling: boolean;
  78906. /** @hidden */
  78907. _updateNonUniformScalingState(value: boolean): boolean;
  78908. /**
  78909. * Attach the current TransformNode to another TransformNode associated with a bone
  78910. * @param bone Bone affecting the TransformNode
  78911. * @param affectedTransformNode TransformNode associated with the bone
  78912. * @returns this object
  78913. */
  78914. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78915. /**
  78916. * Detach the transform node if its associated with a bone
  78917. * @returns this object
  78918. */
  78919. detachFromBone(): TransformNode;
  78920. private static _rotationAxisCache;
  78921. /**
  78922. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78923. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78924. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78925. * The passed axis is also normalized.
  78926. * @param axis the axis to rotate around
  78927. * @param amount the amount to rotate in radians
  78928. * @param space Space to rotate in (Default: local)
  78929. * @returns the TransformNode.
  78930. */
  78931. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78932. /**
  78933. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78934. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78935. * The passed axis is also normalized. .
  78936. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78937. * @param point the point to rotate around
  78938. * @param axis the axis to rotate around
  78939. * @param amount the amount to rotate in radians
  78940. * @returns the TransformNode
  78941. */
  78942. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78943. /**
  78944. * Translates the mesh along the axis vector for the passed distance in the given space.
  78945. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78946. * @param axis the axis to translate in
  78947. * @param distance the distance to translate
  78948. * @param space Space to rotate in (Default: local)
  78949. * @returns the TransformNode.
  78950. */
  78951. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78952. /**
  78953. * Adds a rotation step to the mesh current rotation.
  78954. * x, y, z are Euler angles expressed in radians.
  78955. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78956. * This means this rotation is made in the mesh local space only.
  78957. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78958. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78959. * ```javascript
  78960. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78961. * ```
  78962. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78963. * 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.
  78964. * @param x Rotation to add
  78965. * @param y Rotation to add
  78966. * @param z Rotation to add
  78967. * @returns the TransformNode.
  78968. */
  78969. addRotation(x: number, y: number, z: number): TransformNode;
  78970. /**
  78971. * @hidden
  78972. */
  78973. protected _getEffectiveParent(): Nullable<Node>;
  78974. /**
  78975. * Computes the world matrix of the node
  78976. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78977. * @returns the world matrix
  78978. */
  78979. computeWorldMatrix(force?: boolean): Matrix;
  78980. protected _afterComputeWorldMatrix(): void;
  78981. /**
  78982. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78983. * @param func callback function to add
  78984. *
  78985. * @returns the TransformNode.
  78986. */
  78987. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78988. /**
  78989. * Removes a registered callback function.
  78990. * @param func callback function to remove
  78991. * @returns the TransformNode.
  78992. */
  78993. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78994. /**
  78995. * Gets the position of the current mesh in camera space
  78996. * @param camera defines the camera to use
  78997. * @returns a position
  78998. */
  78999. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79000. /**
  79001. * Returns the distance from the mesh to the active camera
  79002. * @param camera defines the camera to use
  79003. * @returns the distance
  79004. */
  79005. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79006. /**
  79007. * Clone the current transform node
  79008. * @param name Name of the new clone
  79009. * @param newParent New parent for the clone
  79010. * @param doNotCloneChildren Do not clone children hierarchy
  79011. * @returns the new transform node
  79012. */
  79013. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79014. /**
  79015. * Serializes the objects information.
  79016. * @param currentSerializationObject defines the object to serialize in
  79017. * @returns the serialized object
  79018. */
  79019. serialize(currentSerializationObject?: any): any;
  79020. /**
  79021. * Returns a new TransformNode object parsed from the source provided.
  79022. * @param parsedTransformNode is the source.
  79023. * @param scene the scne the object belongs to
  79024. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79025. * @returns a new TransformNode object parsed from the source provided.
  79026. */
  79027. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79028. /**
  79029. * Get all child-transformNodes of this node
  79030. * @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
  79031. * @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
  79032. * @returns an array of TransformNode
  79033. */
  79034. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79035. /**
  79036. * Releases resources associated with this transform node.
  79037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79039. */
  79040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79041. /**
  79042. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79043. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79044. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79045. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79046. * @returns the current mesh
  79047. */
  79048. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79049. private _syncAbsoluteScalingAndRotation;
  79050. }
  79051. }
  79052. declare module BABYLON {
  79053. /**
  79054. * Defines the types of pose enabled controllers that are supported
  79055. */
  79056. export enum PoseEnabledControllerType {
  79057. /**
  79058. * HTC Vive
  79059. */
  79060. VIVE = 0,
  79061. /**
  79062. * Oculus Rift
  79063. */
  79064. OCULUS = 1,
  79065. /**
  79066. * Windows mixed reality
  79067. */
  79068. WINDOWS = 2,
  79069. /**
  79070. * Samsung gear VR
  79071. */
  79072. GEAR_VR = 3,
  79073. /**
  79074. * Google Daydream
  79075. */
  79076. DAYDREAM = 4,
  79077. /**
  79078. * Generic
  79079. */
  79080. GENERIC = 5
  79081. }
  79082. /**
  79083. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79084. */
  79085. export interface MutableGamepadButton {
  79086. /**
  79087. * Value of the button/trigger
  79088. */
  79089. value: number;
  79090. /**
  79091. * If the button/trigger is currently touched
  79092. */
  79093. touched: boolean;
  79094. /**
  79095. * If the button/trigger is currently pressed
  79096. */
  79097. pressed: boolean;
  79098. }
  79099. /**
  79100. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79101. * @hidden
  79102. */
  79103. export interface ExtendedGamepadButton extends GamepadButton {
  79104. /**
  79105. * If the button/trigger is currently pressed
  79106. */
  79107. readonly pressed: boolean;
  79108. /**
  79109. * If the button/trigger is currently touched
  79110. */
  79111. readonly touched: boolean;
  79112. /**
  79113. * Value of the button/trigger
  79114. */
  79115. readonly value: number;
  79116. }
  79117. /** @hidden */
  79118. export interface _GamePadFactory {
  79119. /**
  79120. * Returns wether or not the current gamepad can be created for this type of controller.
  79121. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79122. * @returns true if it can be created, otherwise false
  79123. */
  79124. canCreate(gamepadInfo: any): boolean;
  79125. /**
  79126. * Creates a new instance of the Gamepad.
  79127. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79128. * @returns the new gamepad instance
  79129. */
  79130. create(gamepadInfo: any): Gamepad;
  79131. }
  79132. /**
  79133. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79134. */
  79135. export class PoseEnabledControllerHelper {
  79136. /** @hidden */
  79137. static _ControllerFactories: _GamePadFactory[];
  79138. /** @hidden */
  79139. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79140. /**
  79141. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79142. * @param vrGamepad the gamepad to initialized
  79143. * @returns a vr controller of the type the gamepad identified as
  79144. */
  79145. static InitiateController(vrGamepad: any): Gamepad;
  79146. }
  79147. /**
  79148. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79149. */
  79150. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79151. /**
  79152. * If the controller is used in a webXR session
  79153. */
  79154. isXR: boolean;
  79155. private _deviceRoomPosition;
  79156. private _deviceRoomRotationQuaternion;
  79157. /**
  79158. * The device position in babylon space
  79159. */
  79160. devicePosition: Vector3;
  79161. /**
  79162. * The device rotation in babylon space
  79163. */
  79164. deviceRotationQuaternion: Quaternion;
  79165. /**
  79166. * The scale factor of the device in babylon space
  79167. */
  79168. deviceScaleFactor: number;
  79169. /**
  79170. * (Likely devicePosition should be used instead) The device position in its room space
  79171. */
  79172. position: Vector3;
  79173. /**
  79174. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79175. */
  79176. rotationQuaternion: Quaternion;
  79177. /**
  79178. * The type of controller (Eg. Windows mixed reality)
  79179. */
  79180. controllerType: PoseEnabledControllerType;
  79181. protected _calculatedPosition: Vector3;
  79182. private _calculatedRotation;
  79183. /**
  79184. * The raw pose from the device
  79185. */
  79186. rawPose: DevicePose;
  79187. private _trackPosition;
  79188. private _maxRotationDistFromHeadset;
  79189. private _draggedRoomRotation;
  79190. /**
  79191. * @hidden
  79192. */
  79193. _disableTrackPosition(fixedPosition: Vector3): void;
  79194. /**
  79195. * Internal, the mesh attached to the controller
  79196. * @hidden
  79197. */
  79198. _mesh: Nullable<AbstractMesh>;
  79199. private _poseControlledCamera;
  79200. private _leftHandSystemQuaternion;
  79201. /**
  79202. * Internal, matrix used to convert room space to babylon space
  79203. * @hidden
  79204. */
  79205. _deviceToWorld: Matrix;
  79206. /**
  79207. * Node to be used when casting a ray from the controller
  79208. * @hidden
  79209. */
  79210. _pointingPoseNode: Nullable<TransformNode>;
  79211. /**
  79212. * Name of the child mesh that can be used to cast a ray from the controller
  79213. */
  79214. static readonly POINTING_POSE: string;
  79215. /**
  79216. * Creates a new PoseEnabledController from a gamepad
  79217. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79218. */
  79219. constructor(browserGamepad: any);
  79220. private _workingMatrix;
  79221. /**
  79222. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79223. */
  79224. update(): void;
  79225. /**
  79226. * Updates only the pose device and mesh without doing any button event checking
  79227. */
  79228. protected _updatePoseAndMesh(): void;
  79229. /**
  79230. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79231. * @param poseData raw pose fromthe device
  79232. */
  79233. updateFromDevice(poseData: DevicePose): void;
  79234. /**
  79235. * @hidden
  79236. */
  79237. _meshAttachedObservable: Observable<AbstractMesh>;
  79238. /**
  79239. * Attaches a mesh to the controller
  79240. * @param mesh the mesh to be attached
  79241. */
  79242. attachToMesh(mesh: AbstractMesh): void;
  79243. /**
  79244. * Attaches the controllers mesh to a camera
  79245. * @param camera the camera the mesh should be attached to
  79246. */
  79247. attachToPoseControlledCamera(camera: TargetCamera): void;
  79248. /**
  79249. * Disposes of the controller
  79250. */
  79251. dispose(): void;
  79252. /**
  79253. * The mesh that is attached to the controller
  79254. */
  79255. readonly mesh: Nullable<AbstractMesh>;
  79256. /**
  79257. * Gets the ray of the controller in the direction the controller is pointing
  79258. * @param length the length the resulting ray should be
  79259. * @returns a ray in the direction the controller is pointing
  79260. */
  79261. getForwardRay(length?: number): Ray;
  79262. }
  79263. }
  79264. declare module BABYLON {
  79265. /**
  79266. * Defines the WebVRController object that represents controllers tracked in 3D space
  79267. */
  79268. export abstract class WebVRController extends PoseEnabledController {
  79269. /**
  79270. * Internal, the default controller model for the controller
  79271. */
  79272. protected _defaultModel: AbstractMesh;
  79273. /**
  79274. * Fired when the trigger state has changed
  79275. */
  79276. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79277. /**
  79278. * Fired when the main button state has changed
  79279. */
  79280. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79281. /**
  79282. * Fired when the secondary button state has changed
  79283. */
  79284. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79285. /**
  79286. * Fired when the pad state has changed
  79287. */
  79288. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79289. /**
  79290. * Fired when controllers stick values have changed
  79291. */
  79292. onPadValuesChangedObservable: Observable<StickValues>;
  79293. /**
  79294. * Array of button availible on the controller
  79295. */
  79296. protected _buttons: Array<MutableGamepadButton>;
  79297. private _onButtonStateChange;
  79298. /**
  79299. * Fired when a controller button's state has changed
  79300. * @param callback the callback containing the button that was modified
  79301. */
  79302. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79303. /**
  79304. * X and Y axis corresponding to the controllers joystick
  79305. */
  79306. pad: StickValues;
  79307. /**
  79308. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79309. */
  79310. hand: string;
  79311. /**
  79312. * The default controller model for the controller
  79313. */
  79314. readonly defaultModel: AbstractMesh;
  79315. /**
  79316. * Creates a new WebVRController from a gamepad
  79317. * @param vrGamepad the gamepad that the WebVRController should be created from
  79318. */
  79319. constructor(vrGamepad: any);
  79320. /**
  79321. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79322. */
  79323. update(): void;
  79324. /**
  79325. * Function to be called when a button is modified
  79326. */
  79327. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79328. /**
  79329. * Loads a mesh and attaches it to the controller
  79330. * @param scene the scene the mesh should be added to
  79331. * @param meshLoaded callback for when the mesh has been loaded
  79332. */
  79333. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79334. private _setButtonValue;
  79335. private _changes;
  79336. private _checkChanges;
  79337. /**
  79338. * Disposes of th webVRCOntroller
  79339. */
  79340. dispose(): void;
  79341. }
  79342. }
  79343. declare module BABYLON {
  79344. /**
  79345. * The HemisphericLight simulates the ambient environment light,
  79346. * so the passed direction is the light reflection direction, not the incoming direction.
  79347. */
  79348. export class HemisphericLight extends Light {
  79349. /**
  79350. * The groundColor is the light in the opposite direction to the one specified during creation.
  79351. * 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.
  79352. */
  79353. groundColor: Color3;
  79354. /**
  79355. * The light reflection direction, not the incoming direction.
  79356. */
  79357. direction: Vector3;
  79358. /**
  79359. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79360. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79361. * The HemisphericLight can't cast shadows.
  79362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79363. * @param name The friendly name of the light
  79364. * @param direction The direction of the light reflection
  79365. * @param scene The scene the light belongs to
  79366. */
  79367. constructor(name: string, direction: Vector3, scene: Scene);
  79368. protected _buildUniformLayout(): void;
  79369. /**
  79370. * Returns the string "HemisphericLight".
  79371. * @return The class name
  79372. */
  79373. getClassName(): string;
  79374. /**
  79375. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79376. * Returns the updated direction.
  79377. * @param target The target the direction should point to
  79378. * @return The computed direction
  79379. */
  79380. setDirectionToTarget(target: Vector3): Vector3;
  79381. /**
  79382. * Returns the shadow generator associated to the light.
  79383. * @returns Always null for hemispheric lights because it does not support shadows.
  79384. */
  79385. getShadowGenerator(): Nullable<IShadowGenerator>;
  79386. /**
  79387. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79388. * @param effect The effect to update
  79389. * @param lightIndex The index of the light in the effect to update
  79390. * @returns The hemispheric light
  79391. */
  79392. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79393. /**
  79394. * Computes the world matrix of the node
  79395. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79396. * @param useWasUpdatedFlag defines a reserved property
  79397. * @returns the world matrix
  79398. */
  79399. computeWorldMatrix(): Matrix;
  79400. /**
  79401. * Returns the integer 3.
  79402. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79403. */
  79404. getTypeID(): number;
  79405. /**
  79406. * Prepares the list of defines specific to the light type.
  79407. * @param defines the list of defines
  79408. * @param lightIndex defines the index of the light for the effect
  79409. */
  79410. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79411. }
  79412. }
  79413. declare module BABYLON {
  79414. /** @hidden */
  79415. export var vrMultiviewToSingleviewPixelShader: {
  79416. name: string;
  79417. shader: string;
  79418. };
  79419. }
  79420. declare module BABYLON {
  79421. /**
  79422. * Renders to multiple views with a single draw call
  79423. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79424. */
  79425. export class MultiviewRenderTarget extends RenderTargetTexture {
  79426. /**
  79427. * Creates a multiview render target
  79428. * @param scene scene used with the render target
  79429. * @param size the size of the render target (used for each view)
  79430. */
  79431. constructor(scene: Scene, size?: number | {
  79432. width: number;
  79433. height: number;
  79434. } | {
  79435. ratio: number;
  79436. });
  79437. /**
  79438. * @hidden
  79439. * @param faceIndex the face index, if its a cube texture
  79440. */
  79441. _bindFrameBuffer(faceIndex?: number): void;
  79442. /**
  79443. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79444. * @returns the view count
  79445. */
  79446. getViewCount(): number;
  79447. }
  79448. }
  79449. declare module BABYLON {
  79450. /**
  79451. * Reprasents a camera frustum
  79452. */
  79453. export class Frustum {
  79454. /**
  79455. * Gets the planes representing the frustum
  79456. * @param transform matrix to be applied to the returned planes
  79457. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79458. */
  79459. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79460. /**
  79461. * Gets the near frustum plane transformed by the transform matrix
  79462. * @param transform transformation matrix to be applied to the resulting frustum plane
  79463. * @param frustumPlane the resuling frustum plane
  79464. */
  79465. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79466. /**
  79467. * Gets the far frustum plane transformed by the transform matrix
  79468. * @param transform transformation matrix to be applied to the resulting frustum plane
  79469. * @param frustumPlane the resuling frustum plane
  79470. */
  79471. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79472. /**
  79473. * Gets the left frustum plane transformed by the transform matrix
  79474. * @param transform transformation matrix to be applied to the resulting frustum plane
  79475. * @param frustumPlane the resuling frustum plane
  79476. */
  79477. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79478. /**
  79479. * Gets the right frustum plane transformed by the transform matrix
  79480. * @param transform transformation matrix to be applied to the resulting frustum plane
  79481. * @param frustumPlane the resuling frustum plane
  79482. */
  79483. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79484. /**
  79485. * Gets the top frustum plane transformed by the transform matrix
  79486. * @param transform transformation matrix to be applied to the resulting frustum plane
  79487. * @param frustumPlane the resuling frustum plane
  79488. */
  79489. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79490. /**
  79491. * Gets the bottom frustum plane transformed by the transform matrix
  79492. * @param transform transformation matrix to be applied to the resulting frustum plane
  79493. * @param frustumPlane the resuling frustum plane
  79494. */
  79495. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79496. /**
  79497. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79498. * @param transform transformation matrix to be applied to the resulting frustum planes
  79499. * @param frustumPlanes the resuling frustum planes
  79500. */
  79501. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79502. }
  79503. }
  79504. declare module BABYLON {
  79505. interface Engine {
  79506. /**
  79507. * Creates a new multiview render target
  79508. * @param width defines the width of the texture
  79509. * @param height defines the height of the texture
  79510. * @returns the created multiview texture
  79511. */
  79512. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79513. /**
  79514. * Binds a multiview framebuffer to be drawn to
  79515. * @param multiviewTexture texture to bind
  79516. */
  79517. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79518. }
  79519. interface Camera {
  79520. /**
  79521. * @hidden
  79522. * 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)
  79523. */
  79524. _useMultiviewToSingleView: boolean;
  79525. /**
  79526. * @hidden
  79527. * 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)
  79528. */
  79529. _multiviewTexture: Nullable<RenderTargetTexture>;
  79530. /**
  79531. * @hidden
  79532. * ensures the multiview texture of the camera exists and has the specified width/height
  79533. * @param width height to set on the multiview texture
  79534. * @param height width to set on the multiview texture
  79535. */
  79536. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79537. }
  79538. interface Scene {
  79539. /** @hidden */
  79540. _transformMatrixR: Matrix;
  79541. /** @hidden */
  79542. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79543. /** @hidden */
  79544. _createMultiviewUbo(): void;
  79545. /** @hidden */
  79546. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79547. /** @hidden */
  79548. _renderMultiviewToSingleView(camera: Camera): void;
  79549. }
  79550. }
  79551. declare module BABYLON {
  79552. /**
  79553. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79554. * This will not be used for webXR as it supports displaying texture arrays directly
  79555. */
  79556. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79557. /**
  79558. * Initializes a VRMultiviewToSingleview
  79559. * @param name name of the post process
  79560. * @param camera camera to be applied to
  79561. * @param scaleFactor scaling factor to the size of the output texture
  79562. */
  79563. constructor(name: string, camera: Camera, scaleFactor: number);
  79564. }
  79565. }
  79566. declare module BABYLON {
  79567. interface Engine {
  79568. /** @hidden */
  79569. _vrDisplay: any;
  79570. /** @hidden */
  79571. _vrSupported: boolean;
  79572. /** @hidden */
  79573. _oldSize: Size;
  79574. /** @hidden */
  79575. _oldHardwareScaleFactor: number;
  79576. /** @hidden */
  79577. _vrExclusivePointerMode: boolean;
  79578. /** @hidden */
  79579. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79580. /** @hidden */
  79581. _onVRDisplayPointerRestricted: () => void;
  79582. /** @hidden */
  79583. _onVRDisplayPointerUnrestricted: () => void;
  79584. /** @hidden */
  79585. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79586. /** @hidden */
  79587. _onVrDisplayDisconnect: Nullable<() => void>;
  79588. /** @hidden */
  79589. _onVrDisplayPresentChange: Nullable<() => void>;
  79590. /**
  79591. * Observable signaled when VR display mode changes
  79592. */
  79593. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79594. /**
  79595. * Observable signaled when VR request present is complete
  79596. */
  79597. onVRRequestPresentComplete: Observable<boolean>;
  79598. /**
  79599. * Observable signaled when VR request present starts
  79600. */
  79601. onVRRequestPresentStart: Observable<Engine>;
  79602. /**
  79603. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79604. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79605. */
  79606. isInVRExclusivePointerMode: boolean;
  79607. /**
  79608. * Gets a boolean indicating if a webVR device was detected
  79609. * @returns true if a webVR device was detected
  79610. */
  79611. isVRDevicePresent(): boolean;
  79612. /**
  79613. * Gets the current webVR device
  79614. * @returns the current webVR device (or null)
  79615. */
  79616. getVRDevice(): any;
  79617. /**
  79618. * Initializes a webVR display and starts listening to display change events
  79619. * The onVRDisplayChangedObservable will be notified upon these changes
  79620. * @returns A promise containing a VRDisplay and if vr is supported
  79621. */
  79622. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79623. /** @hidden */
  79624. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79625. /**
  79626. * Call this function to switch to webVR mode
  79627. * Will do nothing if webVR is not supported or if there is no webVR device
  79628. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79629. */
  79630. enableVR(): void;
  79631. /** @hidden */
  79632. _onVRFullScreenTriggered(): void;
  79633. }
  79634. }
  79635. declare module BABYLON {
  79636. /**
  79637. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79638. * IMPORTANT!! The data is right-hand data.
  79639. * @export
  79640. * @interface DevicePose
  79641. */
  79642. export interface DevicePose {
  79643. /**
  79644. * The position of the device, values in array are [x,y,z].
  79645. */
  79646. readonly position: Nullable<Float32Array>;
  79647. /**
  79648. * The linearVelocity of the device, values in array are [x,y,z].
  79649. */
  79650. readonly linearVelocity: Nullable<Float32Array>;
  79651. /**
  79652. * The linearAcceleration of the device, values in array are [x,y,z].
  79653. */
  79654. readonly linearAcceleration: Nullable<Float32Array>;
  79655. /**
  79656. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79657. */
  79658. readonly orientation: Nullable<Float32Array>;
  79659. /**
  79660. * The angularVelocity of the device, values in array are [x,y,z].
  79661. */
  79662. readonly angularVelocity: Nullable<Float32Array>;
  79663. /**
  79664. * The angularAcceleration of the device, values in array are [x,y,z].
  79665. */
  79666. readonly angularAcceleration: Nullable<Float32Array>;
  79667. }
  79668. /**
  79669. * Interface representing a pose controlled object in Babylon.
  79670. * A pose controlled object has both regular pose values as well as pose values
  79671. * from an external device such as a VR head mounted display
  79672. */
  79673. export interface PoseControlled {
  79674. /**
  79675. * The position of the object in babylon space.
  79676. */
  79677. position: Vector3;
  79678. /**
  79679. * The rotation quaternion of the object in babylon space.
  79680. */
  79681. rotationQuaternion: Quaternion;
  79682. /**
  79683. * The position of the device in babylon space.
  79684. */
  79685. devicePosition?: Vector3;
  79686. /**
  79687. * The rotation quaternion of the device in babylon space.
  79688. */
  79689. deviceRotationQuaternion: Quaternion;
  79690. /**
  79691. * The raw pose coming from the device.
  79692. */
  79693. rawPose: Nullable<DevicePose>;
  79694. /**
  79695. * The scale of the device to be used when translating from device space to babylon space.
  79696. */
  79697. deviceScaleFactor: number;
  79698. /**
  79699. * Updates the poseControlled values based on the input device pose.
  79700. * @param poseData the pose data to update the object with
  79701. */
  79702. updateFromDevice(poseData: DevicePose): void;
  79703. }
  79704. /**
  79705. * Set of options to customize the webVRCamera
  79706. */
  79707. export interface WebVROptions {
  79708. /**
  79709. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79710. */
  79711. trackPosition?: boolean;
  79712. /**
  79713. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79714. */
  79715. positionScale?: number;
  79716. /**
  79717. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79718. */
  79719. displayName?: string;
  79720. /**
  79721. * Should the native controller meshes be initialized. (default: true)
  79722. */
  79723. controllerMeshes?: boolean;
  79724. /**
  79725. * Creating a default HemiLight only on controllers. (default: true)
  79726. */
  79727. defaultLightingOnControllers?: boolean;
  79728. /**
  79729. * If you don't want to use the default VR button of the helper. (default: false)
  79730. */
  79731. useCustomVRButton?: boolean;
  79732. /**
  79733. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79734. */
  79735. customVRButton?: HTMLButtonElement;
  79736. /**
  79737. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79738. */
  79739. rayLength?: number;
  79740. /**
  79741. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79742. */
  79743. defaultHeight?: number;
  79744. /**
  79745. * If multiview should be used if availible (default: false)
  79746. */
  79747. useMultiview?: boolean;
  79748. }
  79749. /**
  79750. * This represents a WebVR camera.
  79751. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79752. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79753. */
  79754. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79755. private webVROptions;
  79756. /**
  79757. * @hidden
  79758. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79759. */
  79760. _vrDevice: any;
  79761. /**
  79762. * The rawPose of the vrDevice.
  79763. */
  79764. rawPose: Nullable<DevicePose>;
  79765. private _onVREnabled;
  79766. private _specsVersion;
  79767. private _attached;
  79768. private _frameData;
  79769. protected _descendants: Array<Node>;
  79770. private _deviceRoomPosition;
  79771. /** @hidden */
  79772. _deviceRoomRotationQuaternion: Quaternion;
  79773. private _standingMatrix;
  79774. /**
  79775. * Represents device position in babylon space.
  79776. */
  79777. devicePosition: Vector3;
  79778. /**
  79779. * Represents device rotation in babylon space.
  79780. */
  79781. deviceRotationQuaternion: Quaternion;
  79782. /**
  79783. * The scale of the device to be used when translating from device space to babylon space.
  79784. */
  79785. deviceScaleFactor: number;
  79786. private _deviceToWorld;
  79787. private _worldToDevice;
  79788. /**
  79789. * References to the webVR controllers for the vrDevice.
  79790. */
  79791. controllers: Array<WebVRController>;
  79792. /**
  79793. * Emits an event when a controller is attached.
  79794. */
  79795. onControllersAttachedObservable: Observable<WebVRController[]>;
  79796. /**
  79797. * Emits an event when a controller's mesh has been loaded;
  79798. */
  79799. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79800. /**
  79801. * Emits an event when the HMD's pose has been updated.
  79802. */
  79803. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79804. private _poseSet;
  79805. /**
  79806. * If the rig cameras be used as parent instead of this camera.
  79807. */
  79808. rigParenting: boolean;
  79809. private _lightOnControllers;
  79810. private _defaultHeight?;
  79811. /**
  79812. * Instantiates a WebVRFreeCamera.
  79813. * @param name The name of the WebVRFreeCamera
  79814. * @param position The starting anchor position for the camera
  79815. * @param scene The scene the camera belongs to
  79816. * @param webVROptions a set of customizable options for the webVRCamera
  79817. */
  79818. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79819. /**
  79820. * Gets the device distance from the ground in meters.
  79821. * @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.
  79822. */
  79823. deviceDistanceToRoomGround(): number;
  79824. /**
  79825. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79826. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79827. */
  79828. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79829. /**
  79830. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79831. * @returns A promise with a boolean set to if the standing matrix is supported.
  79832. */
  79833. useStandingMatrixAsync(): Promise<boolean>;
  79834. /**
  79835. * Disposes the camera
  79836. */
  79837. dispose(): void;
  79838. /**
  79839. * Gets a vrController by name.
  79840. * @param name The name of the controller to retreive
  79841. * @returns the controller matching the name specified or null if not found
  79842. */
  79843. getControllerByName(name: string): Nullable<WebVRController>;
  79844. private _leftController;
  79845. /**
  79846. * The controller corresponding to the users left hand.
  79847. */
  79848. readonly leftController: Nullable<WebVRController>;
  79849. private _rightController;
  79850. /**
  79851. * The controller corresponding to the users right hand.
  79852. */
  79853. readonly rightController: Nullable<WebVRController>;
  79854. /**
  79855. * Casts a ray forward from the vrCamera's gaze.
  79856. * @param length Length of the ray (default: 100)
  79857. * @returns the ray corresponding to the gaze
  79858. */
  79859. getForwardRay(length?: number): Ray;
  79860. /**
  79861. * @hidden
  79862. * Updates the camera based on device's frame data
  79863. */
  79864. _checkInputs(): void;
  79865. /**
  79866. * Updates the poseControlled values based on the input device pose.
  79867. * @param poseData Pose coming from the device
  79868. */
  79869. updateFromDevice(poseData: DevicePose): void;
  79870. private _htmlElementAttached;
  79871. private _detachIfAttached;
  79872. /**
  79873. * WebVR's attach control will start broadcasting frames to the device.
  79874. * Note that in certain browsers (chrome for example) this function must be called
  79875. * within a user-interaction callback. Example:
  79876. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79877. *
  79878. * @param element html element to attach the vrDevice to
  79879. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79880. */
  79881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79882. /**
  79883. * Detaches the camera from the html element and disables VR
  79884. *
  79885. * @param element html element to detach from
  79886. */
  79887. detachControl(element: HTMLElement): void;
  79888. /**
  79889. * @returns the name of this class
  79890. */
  79891. getClassName(): string;
  79892. /**
  79893. * Calls resetPose on the vrDisplay
  79894. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79895. */
  79896. resetToCurrentRotation(): void;
  79897. /**
  79898. * @hidden
  79899. * Updates the rig cameras (left and right eye)
  79900. */
  79901. _updateRigCameras(): void;
  79902. private _workingVector;
  79903. private _oneVector;
  79904. private _workingMatrix;
  79905. private updateCacheCalled;
  79906. private _correctPositionIfNotTrackPosition;
  79907. /**
  79908. * @hidden
  79909. * Updates the cached values of the camera
  79910. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79911. */
  79912. _updateCache(ignoreParentClass?: boolean): void;
  79913. /**
  79914. * @hidden
  79915. * Get current device position in babylon world
  79916. */
  79917. _computeDevicePosition(): void;
  79918. /**
  79919. * Updates the current device position and rotation in the babylon world
  79920. */
  79921. update(): void;
  79922. /**
  79923. * @hidden
  79924. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79925. * @returns an identity matrix
  79926. */
  79927. _getViewMatrix(): Matrix;
  79928. private _tmpMatrix;
  79929. /**
  79930. * This function is called by the two RIG cameras.
  79931. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79932. * @hidden
  79933. */
  79934. _getWebVRViewMatrix(): Matrix;
  79935. /** @hidden */
  79936. _getWebVRProjectionMatrix(): Matrix;
  79937. private _onGamepadConnectedObserver;
  79938. private _onGamepadDisconnectedObserver;
  79939. private _updateCacheWhenTrackingDisabledObserver;
  79940. /**
  79941. * Initializes the controllers and their meshes
  79942. */
  79943. initControllers(): void;
  79944. }
  79945. }
  79946. declare module BABYLON {
  79947. /**
  79948. * Size options for a post process
  79949. */
  79950. export type PostProcessOptions = {
  79951. width: number;
  79952. height: number;
  79953. };
  79954. /**
  79955. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79956. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79957. */
  79958. export class PostProcess {
  79959. /** Name of the PostProcess. */
  79960. name: string;
  79961. /**
  79962. * Gets or sets the unique id of the post process
  79963. */
  79964. uniqueId: number;
  79965. /**
  79966. * Width of the texture to apply the post process on
  79967. */
  79968. width: number;
  79969. /**
  79970. * Height of the texture to apply the post process on
  79971. */
  79972. height: number;
  79973. /**
  79974. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79975. * @hidden
  79976. */
  79977. _outputTexture: Nullable<InternalTexture>;
  79978. /**
  79979. * Sampling mode used by the shader
  79980. * See https://doc.babylonjs.com/classes/3.1/texture
  79981. */
  79982. renderTargetSamplingMode: number;
  79983. /**
  79984. * Clear color to use when screen clearing
  79985. */
  79986. clearColor: Color4;
  79987. /**
  79988. * If the buffer needs to be cleared before applying the post process. (default: true)
  79989. * Should be set to false if shader will overwrite all previous pixels.
  79990. */
  79991. autoClear: boolean;
  79992. /**
  79993. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79994. */
  79995. alphaMode: number;
  79996. /**
  79997. * Sets the setAlphaBlendConstants of the babylon engine
  79998. */
  79999. alphaConstants: Color4;
  80000. /**
  80001. * Animations to be used for the post processing
  80002. */
  80003. animations: Animation[];
  80004. /**
  80005. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80006. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80007. */
  80008. enablePixelPerfectMode: boolean;
  80009. /**
  80010. * Force the postprocess to be applied without taking in account viewport
  80011. */
  80012. forceFullscreenViewport: boolean;
  80013. /**
  80014. * List of inspectable custom properties (used by the Inspector)
  80015. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80016. */
  80017. inspectableCustomProperties: IInspectable[];
  80018. /**
  80019. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80020. *
  80021. * | Value | Type | Description |
  80022. * | ----- | ----------------------------------- | ----------- |
  80023. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80024. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80025. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80026. *
  80027. */
  80028. scaleMode: number;
  80029. /**
  80030. * Force textures to be a power of two (default: false)
  80031. */
  80032. alwaysForcePOT: boolean;
  80033. private _samples;
  80034. /**
  80035. * Number of sample textures (default: 1)
  80036. */
  80037. samples: number;
  80038. /**
  80039. * Modify the scale of the post process to be the same as the viewport (default: false)
  80040. */
  80041. adaptScaleToCurrentViewport: boolean;
  80042. private _camera;
  80043. private _scene;
  80044. private _engine;
  80045. private _options;
  80046. private _reusable;
  80047. private _textureType;
  80048. /**
  80049. * Smart array of input and output textures for the post process.
  80050. * @hidden
  80051. */
  80052. _textures: SmartArray<InternalTexture>;
  80053. /**
  80054. * The index in _textures that corresponds to the output texture.
  80055. * @hidden
  80056. */
  80057. _currentRenderTextureInd: number;
  80058. private _effect;
  80059. private _samplers;
  80060. private _fragmentUrl;
  80061. private _vertexUrl;
  80062. private _parameters;
  80063. private _scaleRatio;
  80064. protected _indexParameters: any;
  80065. private _shareOutputWithPostProcess;
  80066. private _texelSize;
  80067. private _forcedOutputTexture;
  80068. /**
  80069. * Returns the fragment url or shader name used in the post process.
  80070. * @returns the fragment url or name in the shader store.
  80071. */
  80072. getEffectName(): string;
  80073. /**
  80074. * An event triggered when the postprocess is activated.
  80075. */
  80076. onActivateObservable: Observable<Camera>;
  80077. private _onActivateObserver;
  80078. /**
  80079. * A function that is added to the onActivateObservable
  80080. */
  80081. onActivate: Nullable<(camera: Camera) => void>;
  80082. /**
  80083. * An event triggered when the postprocess changes its size.
  80084. */
  80085. onSizeChangedObservable: Observable<PostProcess>;
  80086. private _onSizeChangedObserver;
  80087. /**
  80088. * A function that is added to the onSizeChangedObservable
  80089. */
  80090. onSizeChanged: (postProcess: PostProcess) => void;
  80091. /**
  80092. * An event triggered when the postprocess applies its effect.
  80093. */
  80094. onApplyObservable: Observable<Effect>;
  80095. private _onApplyObserver;
  80096. /**
  80097. * A function that is added to the onApplyObservable
  80098. */
  80099. onApply: (effect: Effect) => void;
  80100. /**
  80101. * An event triggered before rendering the postprocess
  80102. */
  80103. onBeforeRenderObservable: Observable<Effect>;
  80104. private _onBeforeRenderObserver;
  80105. /**
  80106. * A function that is added to the onBeforeRenderObservable
  80107. */
  80108. onBeforeRender: (effect: Effect) => void;
  80109. /**
  80110. * An event triggered after rendering the postprocess
  80111. */
  80112. onAfterRenderObservable: Observable<Effect>;
  80113. private _onAfterRenderObserver;
  80114. /**
  80115. * A function that is added to the onAfterRenderObservable
  80116. */
  80117. onAfterRender: (efect: Effect) => void;
  80118. /**
  80119. * 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
  80120. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80121. */
  80122. inputTexture: InternalTexture;
  80123. /**
  80124. * Gets the camera which post process is applied to.
  80125. * @returns The camera the post process is applied to.
  80126. */
  80127. getCamera(): Camera;
  80128. /**
  80129. * Gets the texel size of the postprocess.
  80130. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80131. */
  80132. readonly texelSize: Vector2;
  80133. /**
  80134. * Creates a new instance PostProcess
  80135. * @param name The name of the PostProcess.
  80136. * @param fragmentUrl The url of the fragment shader to be used.
  80137. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80138. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80139. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80140. * @param camera The camera to apply the render pass to.
  80141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80142. * @param engine The engine which the post process will be applied. (default: current engine)
  80143. * @param reusable If the post process can be reused on the same frame. (default: false)
  80144. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80145. * @param textureType Type of textures used when performing the post process. (default: 0)
  80146. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80147. * @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
  80148. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80149. */
  80150. constructor(
  80151. /** Name of the PostProcess. */
  80152. 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);
  80153. /**
  80154. * Gets a string idenfifying the name of the class
  80155. * @returns "PostProcess" string
  80156. */
  80157. getClassName(): string;
  80158. /**
  80159. * Gets the engine which this post process belongs to.
  80160. * @returns The engine the post process was enabled with.
  80161. */
  80162. getEngine(): Engine;
  80163. /**
  80164. * The effect that is created when initializing the post process.
  80165. * @returns The created effect corresponding the the postprocess.
  80166. */
  80167. getEffect(): Effect;
  80168. /**
  80169. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80170. * @param postProcess The post process to share the output with.
  80171. * @returns This post process.
  80172. */
  80173. shareOutputWith(postProcess: PostProcess): PostProcess;
  80174. /**
  80175. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80176. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80177. */
  80178. useOwnOutput(): void;
  80179. /**
  80180. * Updates the effect with the current post process compile time values and recompiles the shader.
  80181. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80182. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80183. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80184. * @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
  80185. * @param onCompiled Called when the shader has been compiled.
  80186. * @param onError Called if there is an error when compiling a shader.
  80187. */
  80188. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80189. /**
  80190. * The post process is reusable if it can be used multiple times within one frame.
  80191. * @returns If the post process is reusable
  80192. */
  80193. isReusable(): boolean;
  80194. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80195. markTextureDirty(): void;
  80196. /**
  80197. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80198. * 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.
  80199. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80200. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80201. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80202. * @returns The target texture that was bound to be written to.
  80203. */
  80204. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80205. /**
  80206. * If the post process is supported.
  80207. */
  80208. readonly isSupported: boolean;
  80209. /**
  80210. * The aspect ratio of the output texture.
  80211. */
  80212. readonly aspectRatio: number;
  80213. /**
  80214. * Get a value indicating if the post-process is ready to be used
  80215. * @returns true if the post-process is ready (shader is compiled)
  80216. */
  80217. isReady(): boolean;
  80218. /**
  80219. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80220. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80221. */
  80222. apply(): Nullable<Effect>;
  80223. private _disposeTextures;
  80224. /**
  80225. * Disposes the post process.
  80226. * @param camera The camera to dispose the post process on.
  80227. */
  80228. dispose(camera?: Camera): void;
  80229. }
  80230. }
  80231. declare module BABYLON {
  80232. /** @hidden */
  80233. export var kernelBlurVaryingDeclaration: {
  80234. name: string;
  80235. shader: string;
  80236. };
  80237. }
  80238. declare module BABYLON {
  80239. /** @hidden */
  80240. export var kernelBlurFragment: {
  80241. name: string;
  80242. shader: string;
  80243. };
  80244. }
  80245. declare module BABYLON {
  80246. /** @hidden */
  80247. export var kernelBlurFragment2: {
  80248. name: string;
  80249. shader: string;
  80250. };
  80251. }
  80252. declare module BABYLON {
  80253. /** @hidden */
  80254. export var kernelBlurPixelShader: {
  80255. name: string;
  80256. shader: string;
  80257. };
  80258. }
  80259. declare module BABYLON {
  80260. /** @hidden */
  80261. export var kernelBlurVertex: {
  80262. name: string;
  80263. shader: string;
  80264. };
  80265. }
  80266. declare module BABYLON {
  80267. /** @hidden */
  80268. export var kernelBlurVertexShader: {
  80269. name: string;
  80270. shader: string;
  80271. };
  80272. }
  80273. declare module BABYLON {
  80274. /**
  80275. * The Blur Post Process which blurs an image based on a kernel and direction.
  80276. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80277. */
  80278. export class BlurPostProcess extends PostProcess {
  80279. /** The direction in which to blur the image. */
  80280. direction: Vector2;
  80281. private blockCompilation;
  80282. protected _kernel: number;
  80283. protected _idealKernel: number;
  80284. protected _packedFloat: boolean;
  80285. private _staticDefines;
  80286. /**
  80287. * Sets the length in pixels of the blur sample region
  80288. */
  80289. /**
  80290. * Gets the length in pixels of the blur sample region
  80291. */
  80292. kernel: number;
  80293. /**
  80294. * Sets wether or not the blur needs to unpack/repack floats
  80295. */
  80296. /**
  80297. * Gets wether or not the blur is unpacking/repacking floats
  80298. */
  80299. packedFloat: boolean;
  80300. /**
  80301. * Creates a new instance BlurPostProcess
  80302. * @param name The name of the effect.
  80303. * @param direction The direction in which to blur the image.
  80304. * @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.
  80305. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80306. * @param camera The camera to apply the render pass to.
  80307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80308. * @param engine The engine which the post process will be applied. (default: current engine)
  80309. * @param reusable If the post process can be reused on the same frame. (default: false)
  80310. * @param textureType Type of textures used when performing the post process. (default: 0)
  80311. * @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)
  80312. */
  80313. constructor(name: string,
  80314. /** The direction in which to blur the image. */
  80315. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80316. /**
  80317. * Updates the effect with the current post process compile time values and recompiles the shader.
  80318. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80319. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80320. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80321. * @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
  80322. * @param onCompiled Called when the shader has been compiled.
  80323. * @param onError Called if there is an error when compiling a shader.
  80324. */
  80325. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80326. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80327. /**
  80328. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80329. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80330. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80331. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80332. * The gaps between physical kernels are compensated for in the weighting of the samples
  80333. * @param idealKernel Ideal blur kernel.
  80334. * @return Nearest best kernel.
  80335. */
  80336. protected _nearestBestKernel(idealKernel: number): number;
  80337. /**
  80338. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80339. * @param x The point on the Gaussian distribution to sample.
  80340. * @return the value of the Gaussian function at x.
  80341. */
  80342. protected _gaussianWeight(x: number): number;
  80343. /**
  80344. * Generates a string that can be used as a floating point number in GLSL.
  80345. * @param x Value to print.
  80346. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80347. * @return GLSL float string.
  80348. */
  80349. protected _glslFloat(x: number, decimalFigures?: number): string;
  80350. }
  80351. }
  80352. declare module BABYLON {
  80353. /**
  80354. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80355. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80356. * You can then easily use it as a reflectionTexture on a flat surface.
  80357. * In case the surface is not a plane, please consider relying on reflection probes.
  80358. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80359. */
  80360. export class MirrorTexture extends RenderTargetTexture {
  80361. private scene;
  80362. /**
  80363. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80364. * 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.
  80365. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80366. */
  80367. mirrorPlane: Plane;
  80368. /**
  80369. * Define the blur ratio used to blur the reflection if needed.
  80370. */
  80371. blurRatio: number;
  80372. /**
  80373. * Define the adaptive blur kernel used to blur the reflection if needed.
  80374. * This will autocompute the closest best match for the `blurKernel`
  80375. */
  80376. adaptiveBlurKernel: number;
  80377. /**
  80378. * Define the blur kernel used to blur the reflection if needed.
  80379. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80380. */
  80381. blurKernel: number;
  80382. /**
  80383. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80384. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80385. */
  80386. blurKernelX: number;
  80387. /**
  80388. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80389. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80390. */
  80391. blurKernelY: number;
  80392. private _autoComputeBlurKernel;
  80393. protected _onRatioRescale(): void;
  80394. private _updateGammaSpace;
  80395. private _imageProcessingConfigChangeObserver;
  80396. private _transformMatrix;
  80397. private _mirrorMatrix;
  80398. private _savedViewMatrix;
  80399. private _blurX;
  80400. private _blurY;
  80401. private _adaptiveBlurKernel;
  80402. private _blurKernelX;
  80403. private _blurKernelY;
  80404. private _blurRatio;
  80405. /**
  80406. * Instantiates a Mirror Texture.
  80407. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80408. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80409. * You can then easily use it as a reflectionTexture on a flat surface.
  80410. * In case the surface is not a plane, please consider relying on reflection probes.
  80411. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80412. * @param name
  80413. * @param size
  80414. * @param scene
  80415. * @param generateMipMaps
  80416. * @param type
  80417. * @param samplingMode
  80418. * @param generateDepthBuffer
  80419. */
  80420. constructor(name: string, size: number | {
  80421. width: number;
  80422. height: number;
  80423. } | {
  80424. ratio: number;
  80425. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80426. private _preparePostProcesses;
  80427. /**
  80428. * Clone the mirror texture.
  80429. * @returns the cloned texture
  80430. */
  80431. clone(): MirrorTexture;
  80432. /**
  80433. * Serialize the texture to a JSON representation you could use in Parse later on
  80434. * @returns the serialized JSON representation
  80435. */
  80436. serialize(): any;
  80437. /**
  80438. * Dispose the texture and release its associated resources.
  80439. */
  80440. dispose(): void;
  80441. }
  80442. }
  80443. declare module BABYLON {
  80444. /**
  80445. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80446. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80447. */
  80448. export class Texture extends BaseTexture {
  80449. /** @hidden */
  80450. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80451. /** @hidden */
  80452. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80453. /** @hidden */
  80454. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80455. /** nearest is mag = nearest and min = nearest and mip = linear */
  80456. static readonly NEAREST_SAMPLINGMODE: number;
  80457. /** nearest is mag = nearest and min = nearest and mip = linear */
  80458. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80460. static readonly BILINEAR_SAMPLINGMODE: number;
  80461. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80462. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80463. /** Trilinear is mag = linear and min = linear and mip = linear */
  80464. static readonly TRILINEAR_SAMPLINGMODE: number;
  80465. /** Trilinear is mag = linear and min = linear and mip = linear */
  80466. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80467. /** mag = nearest and min = nearest and mip = nearest */
  80468. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80469. /** mag = nearest and min = linear and mip = nearest */
  80470. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80471. /** mag = nearest and min = linear and mip = linear */
  80472. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80473. /** mag = nearest and min = linear and mip = none */
  80474. static readonly NEAREST_LINEAR: number;
  80475. /** mag = nearest and min = nearest and mip = none */
  80476. static readonly NEAREST_NEAREST: number;
  80477. /** mag = linear and min = nearest and mip = nearest */
  80478. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80479. /** mag = linear and min = nearest and mip = linear */
  80480. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80481. /** mag = linear and min = linear and mip = none */
  80482. static readonly LINEAR_LINEAR: number;
  80483. /** mag = linear and min = nearest and mip = none */
  80484. static readonly LINEAR_NEAREST: number;
  80485. /** Explicit coordinates mode */
  80486. static readonly EXPLICIT_MODE: number;
  80487. /** Spherical coordinates mode */
  80488. static readonly SPHERICAL_MODE: number;
  80489. /** Planar coordinates mode */
  80490. static readonly PLANAR_MODE: number;
  80491. /** Cubic coordinates mode */
  80492. static readonly CUBIC_MODE: number;
  80493. /** Projection coordinates mode */
  80494. static readonly PROJECTION_MODE: number;
  80495. /** Inverse Cubic coordinates mode */
  80496. static readonly SKYBOX_MODE: number;
  80497. /** Inverse Cubic coordinates mode */
  80498. static readonly INVCUBIC_MODE: number;
  80499. /** Equirectangular coordinates mode */
  80500. static readonly EQUIRECTANGULAR_MODE: number;
  80501. /** Equirectangular Fixed coordinates mode */
  80502. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80503. /** Equirectangular Fixed Mirrored coordinates mode */
  80504. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80505. /** Texture is not repeating outside of 0..1 UVs */
  80506. static readonly CLAMP_ADDRESSMODE: number;
  80507. /** Texture is repeating outside of 0..1 UVs */
  80508. static readonly WRAP_ADDRESSMODE: number;
  80509. /** Texture is repeating and mirrored */
  80510. static readonly MIRROR_ADDRESSMODE: number;
  80511. /**
  80512. * 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
  80513. */
  80514. static UseSerializedUrlIfAny: boolean;
  80515. /**
  80516. * Define the url of the texture.
  80517. */
  80518. url: Nullable<string>;
  80519. /**
  80520. * Define an offset on the texture to offset the u coordinates of the UVs
  80521. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80522. */
  80523. uOffset: number;
  80524. /**
  80525. * Define an offset on the texture to offset the v coordinates of the UVs
  80526. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80527. */
  80528. vOffset: number;
  80529. /**
  80530. * Define an offset on the texture to scale the u coordinates of the UVs
  80531. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80532. */
  80533. uScale: number;
  80534. /**
  80535. * Define an offset on the texture to scale the v coordinates of the UVs
  80536. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80537. */
  80538. vScale: number;
  80539. /**
  80540. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80541. * @see http://doc.babylonjs.com/how_to/more_materials
  80542. */
  80543. uAng: number;
  80544. /**
  80545. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80546. * @see http://doc.babylonjs.com/how_to/more_materials
  80547. */
  80548. vAng: number;
  80549. /**
  80550. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80551. * @see http://doc.babylonjs.com/how_to/more_materials
  80552. */
  80553. wAng: number;
  80554. /**
  80555. * Defines the center of rotation (U)
  80556. */
  80557. uRotationCenter: number;
  80558. /**
  80559. * Defines the center of rotation (V)
  80560. */
  80561. vRotationCenter: number;
  80562. /**
  80563. * Defines the center of rotation (W)
  80564. */
  80565. wRotationCenter: number;
  80566. /**
  80567. * Are mip maps generated for this texture or not.
  80568. */
  80569. readonly noMipmap: boolean;
  80570. /**
  80571. * List of inspectable custom properties (used by the Inspector)
  80572. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80573. */
  80574. inspectableCustomProperties: Nullable<IInspectable[]>;
  80575. private _noMipmap;
  80576. /** @hidden */
  80577. _invertY: boolean;
  80578. private _rowGenerationMatrix;
  80579. private _cachedTextureMatrix;
  80580. private _projectionModeMatrix;
  80581. private _t0;
  80582. private _t1;
  80583. private _t2;
  80584. private _cachedUOffset;
  80585. private _cachedVOffset;
  80586. private _cachedUScale;
  80587. private _cachedVScale;
  80588. private _cachedUAng;
  80589. private _cachedVAng;
  80590. private _cachedWAng;
  80591. private _cachedProjectionMatrixId;
  80592. private _cachedCoordinatesMode;
  80593. /** @hidden */
  80594. protected _initialSamplingMode: number;
  80595. /** @hidden */
  80596. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80597. private _deleteBuffer;
  80598. protected _format: Nullable<number>;
  80599. private _delayedOnLoad;
  80600. private _delayedOnError;
  80601. /**
  80602. * Observable triggered once the texture has been loaded.
  80603. */
  80604. onLoadObservable: Observable<Texture>;
  80605. protected _isBlocking: boolean;
  80606. /**
  80607. * Is the texture preventing material to render while loading.
  80608. * If false, a default texture will be used instead of the loading one during the preparation step.
  80609. */
  80610. isBlocking: boolean;
  80611. /**
  80612. * Get the current sampling mode associated with the texture.
  80613. */
  80614. readonly samplingMode: number;
  80615. /**
  80616. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80617. */
  80618. readonly invertY: boolean;
  80619. /**
  80620. * Instantiates a new texture.
  80621. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80622. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80623. * @param url define the url of the picture to load as a texture
  80624. * @param scene define the scene or engine the texture will belong to
  80625. * @param noMipmap define if the texture will require mip maps or not
  80626. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80627. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80628. * @param onLoad define a callback triggered when the texture has been loaded
  80629. * @param onError define a callback triggered when an error occurred during the loading session
  80630. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80631. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80632. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80633. */
  80634. 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);
  80635. /**
  80636. * Update the url (and optional buffer) of this texture if url was null during construction.
  80637. * @param url the url of the texture
  80638. * @param buffer the buffer of the texture (defaults to null)
  80639. * @param onLoad callback called when the texture is loaded (defaults to null)
  80640. */
  80641. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80642. /**
  80643. * Finish the loading sequence of a texture flagged as delayed load.
  80644. * @hidden
  80645. */
  80646. delayLoad(): void;
  80647. private _prepareRowForTextureGeneration;
  80648. /**
  80649. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80650. * @returns the transform matrix of the texture.
  80651. */
  80652. getTextureMatrix(): Matrix;
  80653. /**
  80654. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80655. * @returns The reflection texture transform
  80656. */
  80657. getReflectionTextureMatrix(): Matrix;
  80658. /**
  80659. * Clones the texture.
  80660. * @returns the cloned texture
  80661. */
  80662. clone(): Texture;
  80663. /**
  80664. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80665. * @returns The JSON representation of the texture
  80666. */
  80667. serialize(): any;
  80668. /**
  80669. * Get the current class name of the texture useful for serialization or dynamic coding.
  80670. * @returns "Texture"
  80671. */
  80672. getClassName(): string;
  80673. /**
  80674. * Dispose the texture and release its associated resources.
  80675. */
  80676. dispose(): void;
  80677. /**
  80678. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80679. * @param parsedTexture Define the JSON representation of the texture
  80680. * @param scene Define the scene the parsed texture should be instantiated in
  80681. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80682. * @returns The parsed texture if successful
  80683. */
  80684. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80685. /**
  80686. * Creates a texture from its base 64 representation.
  80687. * @param data Define the base64 payload without the data: prefix
  80688. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80689. * @param scene Define the scene the texture should belong to
  80690. * @param noMipmap Forces the texture to not create mip map information if true
  80691. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80692. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80693. * @param onLoad define a callback triggered when the texture has been loaded
  80694. * @param onError define a callback triggered when an error occurred during the loading session
  80695. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80696. * @returns the created texture
  80697. */
  80698. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80699. /**
  80700. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80701. * @param data Define the base64 payload without the data: prefix
  80702. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80703. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80704. * @param scene Define the scene the texture should belong to
  80705. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80706. * @param noMipmap Forces the texture to not create mip map information if true
  80707. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80708. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80709. * @param onLoad define a callback triggered when the texture has been loaded
  80710. * @param onError define a callback triggered when an error occurred during the loading session
  80711. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80712. * @returns the created texture
  80713. */
  80714. 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;
  80715. }
  80716. }
  80717. declare module BABYLON {
  80718. /**
  80719. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80721. */
  80722. export class PostProcessManager {
  80723. private _scene;
  80724. private _indexBuffer;
  80725. private _vertexBuffers;
  80726. /**
  80727. * Creates a new instance PostProcess
  80728. * @param scene The scene that the post process is associated with.
  80729. */
  80730. constructor(scene: Scene);
  80731. private _prepareBuffers;
  80732. private _buildIndexBuffer;
  80733. /**
  80734. * Rebuilds the vertex buffers of the manager.
  80735. * @hidden
  80736. */
  80737. _rebuild(): void;
  80738. /**
  80739. * Prepares a frame to be run through a post process.
  80740. * @param sourceTexture The input texture to the post procesess. (default: null)
  80741. * @param postProcesses An array of post processes to be run. (default: null)
  80742. * @returns True if the post processes were able to be run.
  80743. * @hidden
  80744. */
  80745. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80746. /**
  80747. * Manually render a set of post processes to a texture.
  80748. * @param postProcesses An array of post processes to be run.
  80749. * @param targetTexture The target texture to render to.
  80750. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80751. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80752. * @param lodLevel defines which lod of the texture to render to
  80753. */
  80754. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80755. /**
  80756. * Finalize the result of the output of the postprocesses.
  80757. * @param doNotPresent If true the result will not be displayed to the screen.
  80758. * @param targetTexture The target texture to render to.
  80759. * @param faceIndex The index of the face to bind the target texture to.
  80760. * @param postProcesses The array of post processes to render.
  80761. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80762. * @hidden
  80763. */
  80764. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80765. /**
  80766. * Disposes of the post process manager.
  80767. */
  80768. dispose(): void;
  80769. }
  80770. }
  80771. declare module BABYLON {
  80772. /** Interface used by value gradients (color, factor, ...) */
  80773. export interface IValueGradient {
  80774. /**
  80775. * Gets or sets the gradient value (between 0 and 1)
  80776. */
  80777. gradient: number;
  80778. }
  80779. /** Class used to store color4 gradient */
  80780. export class ColorGradient implements IValueGradient {
  80781. /**
  80782. * Gets or sets the gradient value (between 0 and 1)
  80783. */
  80784. gradient: number;
  80785. /**
  80786. * Gets or sets first associated color
  80787. */
  80788. color1: Color4;
  80789. /**
  80790. * Gets or sets second associated color
  80791. */
  80792. color2?: Color4;
  80793. /**
  80794. * Will get a color picked randomly between color1 and color2.
  80795. * If color2 is undefined then color1 will be used
  80796. * @param result defines the target Color4 to store the result in
  80797. */
  80798. getColorToRef(result: Color4): void;
  80799. }
  80800. /** Class used to store color 3 gradient */
  80801. export class Color3Gradient implements IValueGradient {
  80802. /**
  80803. * Gets or sets the gradient value (between 0 and 1)
  80804. */
  80805. gradient: number;
  80806. /**
  80807. * Gets or sets the associated color
  80808. */
  80809. color: Color3;
  80810. }
  80811. /** Class used to store factor gradient */
  80812. export class FactorGradient implements IValueGradient {
  80813. /**
  80814. * Gets or sets the gradient value (between 0 and 1)
  80815. */
  80816. gradient: number;
  80817. /**
  80818. * Gets or sets first associated factor
  80819. */
  80820. factor1: number;
  80821. /**
  80822. * Gets or sets second associated factor
  80823. */
  80824. factor2?: number;
  80825. /**
  80826. * Will get a number picked randomly between factor1 and factor2.
  80827. * If factor2 is undefined then factor1 will be used
  80828. * @returns the picked number
  80829. */
  80830. getFactor(): number;
  80831. }
  80832. /**
  80833. * Helper used to simplify some generic gradient tasks
  80834. */
  80835. export class GradientHelper {
  80836. /**
  80837. * Gets the current gradient from an array of IValueGradient
  80838. * @param ratio defines the current ratio to get
  80839. * @param gradients defines the array of IValueGradient
  80840. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80841. */
  80842. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80843. }
  80844. }
  80845. declare module BABYLON {
  80846. interface AbstractScene {
  80847. /**
  80848. * The list of procedural textures added to the scene
  80849. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80850. */
  80851. proceduralTextures: Array<ProceduralTexture>;
  80852. }
  80853. /**
  80854. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80855. * in a given scene.
  80856. */
  80857. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80858. /**
  80859. * The component name helpfull to identify the component in the list of scene components.
  80860. */
  80861. readonly name: string;
  80862. /**
  80863. * The scene the component belongs to.
  80864. */
  80865. scene: Scene;
  80866. /**
  80867. * Creates a new instance of the component for the given scene
  80868. * @param scene Defines the scene to register the component in
  80869. */
  80870. constructor(scene: Scene);
  80871. /**
  80872. * Registers the component in a given scene
  80873. */
  80874. register(): void;
  80875. /**
  80876. * Rebuilds the elements related to this component in case of
  80877. * context lost for instance.
  80878. */
  80879. rebuild(): void;
  80880. /**
  80881. * Disposes the component and the associated ressources.
  80882. */
  80883. dispose(): void;
  80884. private _beforeClear;
  80885. }
  80886. }
  80887. declare module BABYLON {
  80888. interface Engine {
  80889. /**
  80890. * Creates a new render target cube texture
  80891. * @param size defines the size of the texture
  80892. * @param options defines the options used to create the texture
  80893. * @returns a new render target cube texture stored in an InternalTexture
  80894. */
  80895. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80896. }
  80897. }
  80898. declare module BABYLON {
  80899. /** @hidden */
  80900. export var proceduralVertexShader: {
  80901. name: string;
  80902. shader: string;
  80903. };
  80904. }
  80905. declare module BABYLON {
  80906. /**
  80907. * 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.
  80908. * This is the base class of any Procedural texture and contains most of the shareable code.
  80909. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80910. */
  80911. export class ProceduralTexture extends Texture {
  80912. isCube: boolean;
  80913. /**
  80914. * Define if the texture is enabled or not (disabled texture will not render)
  80915. */
  80916. isEnabled: boolean;
  80917. /**
  80918. * Define if the texture must be cleared before rendering (default is true)
  80919. */
  80920. autoClear: boolean;
  80921. /**
  80922. * Callback called when the texture is generated
  80923. */
  80924. onGenerated: () => void;
  80925. /**
  80926. * Event raised when the texture is generated
  80927. */
  80928. onGeneratedObservable: Observable<ProceduralTexture>;
  80929. /** @hidden */
  80930. _generateMipMaps: boolean;
  80931. /** @hidden **/
  80932. _effect: Effect;
  80933. /** @hidden */
  80934. _textures: {
  80935. [key: string]: Texture;
  80936. };
  80937. private _size;
  80938. private _currentRefreshId;
  80939. private _refreshRate;
  80940. private _vertexBuffers;
  80941. private _indexBuffer;
  80942. private _uniforms;
  80943. private _samplers;
  80944. private _fragment;
  80945. private _floats;
  80946. private _ints;
  80947. private _floatsArrays;
  80948. private _colors3;
  80949. private _colors4;
  80950. private _vectors2;
  80951. private _vectors3;
  80952. private _matrices;
  80953. private _fallbackTexture;
  80954. private _fallbackTextureUsed;
  80955. private _engine;
  80956. private _cachedDefines;
  80957. private _contentUpdateId;
  80958. private _contentData;
  80959. /**
  80960. * Instantiates a new procedural texture.
  80961. * 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.
  80962. * This is the base class of any Procedural texture and contains most of the shareable code.
  80963. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80964. * @param name Define the name of the texture
  80965. * @param size Define the size of the texture to create
  80966. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80967. * @param scene Define the scene the texture belongs to
  80968. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80969. * @param generateMipMaps Define if the texture should creates mip maps or not
  80970. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80971. */
  80972. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80973. /**
  80974. * The effect that is created when initializing the post process.
  80975. * @returns The created effect corresponding the the postprocess.
  80976. */
  80977. getEffect(): Effect;
  80978. /**
  80979. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80980. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80981. */
  80982. getContent(): Nullable<ArrayBufferView>;
  80983. private _createIndexBuffer;
  80984. /** @hidden */
  80985. _rebuild(): void;
  80986. /**
  80987. * Resets the texture in order to recreate its associated resources.
  80988. * This can be called in case of context loss
  80989. */
  80990. reset(): void;
  80991. protected _getDefines(): string;
  80992. /**
  80993. * Is the texture ready to be used ? (rendered at least once)
  80994. * @returns true if ready, otherwise, false.
  80995. */
  80996. isReady(): boolean;
  80997. /**
  80998. * Resets the refresh counter of the texture and start bak from scratch.
  80999. * Could be useful to regenerate the texture if it is setup to render only once.
  81000. */
  81001. resetRefreshCounter(): void;
  81002. /**
  81003. * Set the fragment shader to use in order to render the texture.
  81004. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81005. */
  81006. setFragment(fragment: any): void;
  81007. /**
  81008. * Define the refresh rate of the texture or the rendering frequency.
  81009. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81010. */
  81011. refreshRate: number;
  81012. /** @hidden */
  81013. _shouldRender(): boolean;
  81014. /**
  81015. * Get the size the texture is rendering at.
  81016. * @returns the size (texture is always squared)
  81017. */
  81018. getRenderSize(): number;
  81019. /**
  81020. * Resize the texture to new value.
  81021. * @param size Define the new size the texture should have
  81022. * @param generateMipMaps Define whether the new texture should create mip maps
  81023. */
  81024. resize(size: number, generateMipMaps: boolean): void;
  81025. private _checkUniform;
  81026. /**
  81027. * Set a texture in the shader program used to render.
  81028. * @param name Define the name of the uniform samplers as defined in the shader
  81029. * @param texture Define the texture to bind to this sampler
  81030. * @return the texture itself allowing "fluent" like uniform updates
  81031. */
  81032. setTexture(name: string, texture: Texture): ProceduralTexture;
  81033. /**
  81034. * Set a float in the shader.
  81035. * @param name Define the name of the uniform as defined in the shader
  81036. * @param value Define the value to give to the uniform
  81037. * @return the texture itself allowing "fluent" like uniform updates
  81038. */
  81039. setFloat(name: string, value: number): ProceduralTexture;
  81040. /**
  81041. * Set a int in the shader.
  81042. * @param name Define the name of the uniform as defined in the shader
  81043. * @param value Define the value to give to the uniform
  81044. * @return the texture itself allowing "fluent" like uniform updates
  81045. */
  81046. setInt(name: string, value: number): ProceduralTexture;
  81047. /**
  81048. * Set an array of floats in the shader.
  81049. * @param name Define the name of the uniform as defined in the shader
  81050. * @param value Define the value to give to the uniform
  81051. * @return the texture itself allowing "fluent" like uniform updates
  81052. */
  81053. setFloats(name: string, value: number[]): ProceduralTexture;
  81054. /**
  81055. * Set a vec3 in the shader from a Color3.
  81056. * @param name Define the name of the uniform as defined in the shader
  81057. * @param value Define the value to give to the uniform
  81058. * @return the texture itself allowing "fluent" like uniform updates
  81059. */
  81060. setColor3(name: string, value: Color3): ProceduralTexture;
  81061. /**
  81062. * Set a vec4 in the shader from a Color4.
  81063. * @param name Define the name of the uniform as defined in the shader
  81064. * @param value Define the value to give to the uniform
  81065. * @return the texture itself allowing "fluent" like uniform updates
  81066. */
  81067. setColor4(name: string, value: Color4): ProceduralTexture;
  81068. /**
  81069. * Set a vec2 in the shader from a Vector2.
  81070. * @param name Define the name of the uniform as defined in the shader
  81071. * @param value Define the value to give to the uniform
  81072. * @return the texture itself allowing "fluent" like uniform updates
  81073. */
  81074. setVector2(name: string, value: Vector2): ProceduralTexture;
  81075. /**
  81076. * Set a vec3 in the shader from a Vector3.
  81077. * @param name Define the name of the uniform as defined in the shader
  81078. * @param value Define the value to give to the uniform
  81079. * @return the texture itself allowing "fluent" like uniform updates
  81080. */
  81081. setVector3(name: string, value: Vector3): ProceduralTexture;
  81082. /**
  81083. * Set a mat4 in the shader from a MAtrix.
  81084. * @param name Define the name of the uniform as defined in the shader
  81085. * @param value Define the value to give to the uniform
  81086. * @return the texture itself allowing "fluent" like uniform updates
  81087. */
  81088. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81089. /**
  81090. * Render the texture to its associated render target.
  81091. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81092. */
  81093. render(useCameraPostProcess?: boolean): void;
  81094. /**
  81095. * Clone the texture.
  81096. * @returns the cloned texture
  81097. */
  81098. clone(): ProceduralTexture;
  81099. /**
  81100. * Dispose the texture and release its asoociated resources.
  81101. */
  81102. dispose(): void;
  81103. }
  81104. }
  81105. declare module BABYLON {
  81106. /**
  81107. * This represents the base class for particle system in Babylon.
  81108. * 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.
  81109. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81110. * @example https://doc.babylonjs.com/babylon101/particles
  81111. */
  81112. export class BaseParticleSystem {
  81113. /**
  81114. * Source color is added to the destination color without alpha affecting the result
  81115. */
  81116. static BLENDMODE_ONEONE: number;
  81117. /**
  81118. * Blend current color and particle color using particle’s alpha
  81119. */
  81120. static BLENDMODE_STANDARD: number;
  81121. /**
  81122. * Add current color and particle color multiplied by particle’s alpha
  81123. */
  81124. static BLENDMODE_ADD: number;
  81125. /**
  81126. * Multiply current color with particle color
  81127. */
  81128. static BLENDMODE_MULTIPLY: number;
  81129. /**
  81130. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81131. */
  81132. static BLENDMODE_MULTIPLYADD: number;
  81133. /**
  81134. * List of animations used by the particle system.
  81135. */
  81136. animations: Animation[];
  81137. /**
  81138. * The id of the Particle system.
  81139. */
  81140. id: string;
  81141. /**
  81142. * The friendly name of the Particle system.
  81143. */
  81144. name: string;
  81145. /**
  81146. * The rendering group used by the Particle system to chose when to render.
  81147. */
  81148. renderingGroupId: number;
  81149. /**
  81150. * The emitter represents the Mesh or position we are attaching the particle system to.
  81151. */
  81152. emitter: Nullable<AbstractMesh | Vector3>;
  81153. /**
  81154. * The maximum number of particles to emit per frame
  81155. */
  81156. emitRate: number;
  81157. /**
  81158. * If you want to launch only a few particles at once, that can be done, as well.
  81159. */
  81160. manualEmitCount: number;
  81161. /**
  81162. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81163. */
  81164. updateSpeed: number;
  81165. /**
  81166. * The amount of time the particle system is running (depends of the overall update speed).
  81167. */
  81168. targetStopDuration: number;
  81169. /**
  81170. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81171. */
  81172. disposeOnStop: boolean;
  81173. /**
  81174. * Minimum power of emitting particles.
  81175. */
  81176. minEmitPower: number;
  81177. /**
  81178. * Maximum power of emitting particles.
  81179. */
  81180. maxEmitPower: number;
  81181. /**
  81182. * Minimum life time of emitting particles.
  81183. */
  81184. minLifeTime: number;
  81185. /**
  81186. * Maximum life time of emitting particles.
  81187. */
  81188. maxLifeTime: number;
  81189. /**
  81190. * Minimum Size of emitting particles.
  81191. */
  81192. minSize: number;
  81193. /**
  81194. * Maximum Size of emitting particles.
  81195. */
  81196. maxSize: number;
  81197. /**
  81198. * Minimum scale of emitting particles on X axis.
  81199. */
  81200. minScaleX: number;
  81201. /**
  81202. * Maximum scale of emitting particles on X axis.
  81203. */
  81204. maxScaleX: number;
  81205. /**
  81206. * Minimum scale of emitting particles on Y axis.
  81207. */
  81208. minScaleY: number;
  81209. /**
  81210. * Maximum scale of emitting particles on Y axis.
  81211. */
  81212. maxScaleY: number;
  81213. /**
  81214. * Gets or sets the minimal initial rotation in radians.
  81215. */
  81216. minInitialRotation: number;
  81217. /**
  81218. * Gets or sets the maximal initial rotation in radians.
  81219. */
  81220. maxInitialRotation: number;
  81221. /**
  81222. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81223. */
  81224. minAngularSpeed: number;
  81225. /**
  81226. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81227. */
  81228. maxAngularSpeed: number;
  81229. /**
  81230. * The texture used to render each particle. (this can be a spritesheet)
  81231. */
  81232. particleTexture: Nullable<Texture>;
  81233. /**
  81234. * The layer mask we are rendering the particles through.
  81235. */
  81236. layerMask: number;
  81237. /**
  81238. * This can help using your own shader to render the particle system.
  81239. * The according effect will be created
  81240. */
  81241. customShader: any;
  81242. /**
  81243. * By default particle system starts as soon as they are created. This prevents the
  81244. * automatic start to happen and let you decide when to start emitting particles.
  81245. */
  81246. preventAutoStart: boolean;
  81247. private _noiseTexture;
  81248. /**
  81249. * Gets or sets a texture used to add random noise to particle positions
  81250. */
  81251. noiseTexture: Nullable<ProceduralTexture>;
  81252. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81253. noiseStrength: Vector3;
  81254. /**
  81255. * Callback triggered when the particle animation is ending.
  81256. */
  81257. onAnimationEnd: Nullable<() => void>;
  81258. /**
  81259. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81260. */
  81261. blendMode: number;
  81262. /**
  81263. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81264. * to override the particles.
  81265. */
  81266. forceDepthWrite: boolean;
  81267. /** 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 */
  81268. preWarmCycles: number;
  81269. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81270. preWarmStepOffset: number;
  81271. /**
  81272. * 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)
  81273. */
  81274. spriteCellChangeSpeed: number;
  81275. /**
  81276. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81277. */
  81278. startSpriteCellID: number;
  81279. /**
  81280. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81281. */
  81282. endSpriteCellID: number;
  81283. /**
  81284. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81285. */
  81286. spriteCellWidth: number;
  81287. /**
  81288. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81289. */
  81290. spriteCellHeight: number;
  81291. /**
  81292. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81293. */
  81294. spriteRandomStartCell: boolean;
  81295. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81296. translationPivot: Vector2;
  81297. /** @hidden */
  81298. protected _isAnimationSheetEnabled: boolean;
  81299. /**
  81300. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81301. */
  81302. beginAnimationOnStart: boolean;
  81303. /**
  81304. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81305. */
  81306. beginAnimationFrom: number;
  81307. /**
  81308. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81309. */
  81310. beginAnimationTo: number;
  81311. /**
  81312. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81313. */
  81314. beginAnimationLoop: boolean;
  81315. /**
  81316. * Gets or sets a world offset applied to all particles
  81317. */
  81318. worldOffset: Vector3;
  81319. /**
  81320. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81321. */
  81322. isAnimationSheetEnabled: boolean;
  81323. /**
  81324. * Get hosting scene
  81325. * @returns the scene
  81326. */
  81327. getScene(): Scene;
  81328. /**
  81329. * You can use gravity if you want to give an orientation to your particles.
  81330. */
  81331. gravity: Vector3;
  81332. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81333. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81334. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81335. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81336. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81337. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81338. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81339. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81340. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81341. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81342. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81343. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81344. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81345. /**
  81346. * Defines the delay in milliseconds before starting the system (0 by default)
  81347. */
  81348. startDelay: number;
  81349. /**
  81350. * Gets the current list of drag gradients.
  81351. * You must use addDragGradient and removeDragGradient to udpate this list
  81352. * @returns the list of drag gradients
  81353. */
  81354. getDragGradients(): Nullable<Array<FactorGradient>>;
  81355. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81356. limitVelocityDamping: number;
  81357. /**
  81358. * Gets the current list of limit velocity gradients.
  81359. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81360. * @returns the list of limit velocity gradients
  81361. */
  81362. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81363. /**
  81364. * Gets the current list of color gradients.
  81365. * You must use addColorGradient and removeColorGradient to udpate this list
  81366. * @returns the list of color gradients
  81367. */
  81368. getColorGradients(): Nullable<Array<ColorGradient>>;
  81369. /**
  81370. * Gets the current list of size gradients.
  81371. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81372. * @returns the list of size gradients
  81373. */
  81374. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81375. /**
  81376. * Gets the current list of color remap gradients.
  81377. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81378. * @returns the list of color remap gradients
  81379. */
  81380. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81381. /**
  81382. * Gets the current list of alpha remap gradients.
  81383. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81384. * @returns the list of alpha remap gradients
  81385. */
  81386. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81387. /**
  81388. * Gets the current list of life time gradients.
  81389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81390. * @returns the list of life time gradients
  81391. */
  81392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81393. /**
  81394. * Gets the current list of angular speed gradients.
  81395. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81396. * @returns the list of angular speed gradients
  81397. */
  81398. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81399. /**
  81400. * Gets the current list of velocity gradients.
  81401. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81402. * @returns the list of velocity gradients
  81403. */
  81404. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81405. /**
  81406. * Gets the current list of start size gradients.
  81407. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81408. * @returns the list of start size gradients
  81409. */
  81410. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81411. /**
  81412. * Gets the current list of emit rate gradients.
  81413. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81414. * @returns the list of emit rate gradients
  81415. */
  81416. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81417. /**
  81418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81419. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81420. */
  81421. direction1: Vector3;
  81422. /**
  81423. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81424. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81425. */
  81426. direction2: Vector3;
  81427. /**
  81428. * 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.
  81429. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81430. */
  81431. minEmitBox: Vector3;
  81432. /**
  81433. * 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.
  81434. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81435. */
  81436. maxEmitBox: Vector3;
  81437. /**
  81438. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81439. */
  81440. color1: Color4;
  81441. /**
  81442. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81443. */
  81444. color2: Color4;
  81445. /**
  81446. * Color the particle will have at the end of its lifetime
  81447. */
  81448. colorDead: Color4;
  81449. /**
  81450. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81451. */
  81452. textureMask: Color4;
  81453. /**
  81454. * The particle emitter type defines the emitter used by the particle system.
  81455. * It can be for example box, sphere, or cone...
  81456. */
  81457. particleEmitterType: IParticleEmitterType;
  81458. /** @hidden */
  81459. _isSubEmitter: boolean;
  81460. /**
  81461. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81462. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81463. */
  81464. billboardMode: number;
  81465. protected _isBillboardBased: boolean;
  81466. /**
  81467. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81468. */
  81469. isBillboardBased: boolean;
  81470. /**
  81471. * The scene the particle system belongs to.
  81472. */
  81473. protected _scene: Scene;
  81474. /**
  81475. * Local cache of defines for image processing.
  81476. */
  81477. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81478. /**
  81479. * Default configuration related to image processing available in the standard Material.
  81480. */
  81481. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81482. /**
  81483. * Gets the image processing configuration used either in this material.
  81484. */
  81485. /**
  81486. * Sets the Default image processing configuration used either in the this material.
  81487. *
  81488. * If sets to null, the scene one is in use.
  81489. */
  81490. imageProcessingConfiguration: ImageProcessingConfiguration;
  81491. /**
  81492. * Attaches a new image processing configuration to the Standard Material.
  81493. * @param configuration
  81494. */
  81495. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81496. /** @hidden */
  81497. protected _reset(): void;
  81498. /** @hidden */
  81499. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81500. /**
  81501. * Instantiates a particle system.
  81502. * 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.
  81503. * @param name The name of the particle system
  81504. */
  81505. constructor(name: string);
  81506. /**
  81507. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81510. * @returns the emitter
  81511. */
  81512. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81513. /**
  81514. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81515. * @param radius The radius of the hemisphere to emit from
  81516. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81517. * @returns the emitter
  81518. */
  81519. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81520. /**
  81521. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81522. * @param radius The radius of the sphere to emit from
  81523. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81524. * @returns the emitter
  81525. */
  81526. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81527. /**
  81528. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81529. * @param radius The radius of the sphere to emit from
  81530. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81531. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81532. * @returns the emitter
  81533. */
  81534. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81535. /**
  81536. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81537. * @param radius The radius of the emission cylinder
  81538. * @param height The height of the emission cylinder
  81539. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81540. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81541. * @returns the emitter
  81542. */
  81543. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81544. /**
  81545. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81546. * @param radius The radius of the cylinder to emit from
  81547. * @param height The height of the emission cylinder
  81548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81551. * @returns the emitter
  81552. */
  81553. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81554. /**
  81555. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81556. * @param radius The radius of the cone to emit from
  81557. * @param angle The base angle of the cone
  81558. * @returns the emitter
  81559. */
  81560. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81561. /**
  81562. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81565. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81566. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81567. * @returns the emitter
  81568. */
  81569. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81570. }
  81571. }
  81572. declare module BABYLON {
  81573. /**
  81574. * Type of sub emitter
  81575. */
  81576. export enum SubEmitterType {
  81577. /**
  81578. * Attached to the particle over it's lifetime
  81579. */
  81580. ATTACHED = 0,
  81581. /**
  81582. * Created when the particle dies
  81583. */
  81584. END = 1
  81585. }
  81586. /**
  81587. * Sub emitter class used to emit particles from an existing particle
  81588. */
  81589. export class SubEmitter {
  81590. /**
  81591. * the particle system to be used by the sub emitter
  81592. */
  81593. particleSystem: ParticleSystem;
  81594. /**
  81595. * Type of the submitter (Default: END)
  81596. */
  81597. type: SubEmitterType;
  81598. /**
  81599. * 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)
  81600. * Note: This only is supported when using an emitter of type Mesh
  81601. */
  81602. inheritDirection: boolean;
  81603. /**
  81604. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81605. */
  81606. inheritedVelocityAmount: number;
  81607. /**
  81608. * Creates a sub emitter
  81609. * @param particleSystem the particle system to be used by the sub emitter
  81610. */
  81611. constructor(
  81612. /**
  81613. * the particle system to be used by the sub emitter
  81614. */
  81615. particleSystem: ParticleSystem);
  81616. /**
  81617. * Clones the sub emitter
  81618. * @returns the cloned sub emitter
  81619. */
  81620. clone(): SubEmitter;
  81621. /**
  81622. * Serialize current object to a JSON object
  81623. * @returns the serialized object
  81624. */
  81625. serialize(): any;
  81626. /** @hidden */
  81627. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81628. /**
  81629. * Creates a new SubEmitter from a serialized JSON version
  81630. * @param serializationObject defines the JSON object to read from
  81631. * @param scene defines the hosting scene
  81632. * @param rootUrl defines the rootUrl for data loading
  81633. * @returns a new SubEmitter
  81634. */
  81635. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81636. /** Release associated resources */
  81637. dispose(): void;
  81638. }
  81639. }
  81640. declare module BABYLON {
  81641. /** @hidden */
  81642. export var clipPlaneFragmentDeclaration: {
  81643. name: string;
  81644. shader: string;
  81645. };
  81646. }
  81647. declare module BABYLON {
  81648. /** @hidden */
  81649. export var imageProcessingDeclaration: {
  81650. name: string;
  81651. shader: string;
  81652. };
  81653. }
  81654. declare module BABYLON {
  81655. /** @hidden */
  81656. export var imageProcessingFunctions: {
  81657. name: string;
  81658. shader: string;
  81659. };
  81660. }
  81661. declare module BABYLON {
  81662. /** @hidden */
  81663. export var clipPlaneFragment: {
  81664. name: string;
  81665. shader: string;
  81666. };
  81667. }
  81668. declare module BABYLON {
  81669. /** @hidden */
  81670. export var particlesPixelShader: {
  81671. name: string;
  81672. shader: string;
  81673. };
  81674. }
  81675. declare module BABYLON {
  81676. /** @hidden */
  81677. export var clipPlaneVertexDeclaration: {
  81678. name: string;
  81679. shader: string;
  81680. };
  81681. }
  81682. declare module BABYLON {
  81683. /** @hidden */
  81684. export var clipPlaneVertex: {
  81685. name: string;
  81686. shader: string;
  81687. };
  81688. }
  81689. declare module BABYLON {
  81690. /** @hidden */
  81691. export var particlesVertexShader: {
  81692. name: string;
  81693. shader: string;
  81694. };
  81695. }
  81696. declare module BABYLON {
  81697. /**
  81698. * This represents a particle system in Babylon.
  81699. * 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.
  81700. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81701. * @example https://doc.babylonjs.com/babylon101/particles
  81702. */
  81703. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81704. /**
  81705. * Billboard mode will only apply to Y axis
  81706. */
  81707. static readonly BILLBOARDMODE_Y: number;
  81708. /**
  81709. * Billboard mode will apply to all axes
  81710. */
  81711. static readonly BILLBOARDMODE_ALL: number;
  81712. /**
  81713. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81714. */
  81715. static readonly BILLBOARDMODE_STRETCHED: number;
  81716. /**
  81717. * This function can be defined to provide custom update for active particles.
  81718. * This function will be called instead of regular update (age, position, color, etc.).
  81719. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81720. */
  81721. updateFunction: (particles: Particle[]) => void;
  81722. private _emitterWorldMatrix;
  81723. /**
  81724. * This function can be defined to specify initial direction for every new particle.
  81725. * It by default use the emitterType defined function
  81726. */
  81727. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81728. /**
  81729. * This function can be defined to specify initial position for every new particle.
  81730. * It by default use the emitterType defined function
  81731. */
  81732. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81733. /**
  81734. * @hidden
  81735. */
  81736. _inheritedVelocityOffset: Vector3;
  81737. /**
  81738. * An event triggered when the system is disposed
  81739. */
  81740. onDisposeObservable: Observable<ParticleSystem>;
  81741. private _onDisposeObserver;
  81742. /**
  81743. * Sets a callback that will be triggered when the system is disposed
  81744. */
  81745. onDispose: () => void;
  81746. private _particles;
  81747. private _epsilon;
  81748. private _capacity;
  81749. private _stockParticles;
  81750. private _newPartsExcess;
  81751. private _vertexData;
  81752. private _vertexBuffer;
  81753. private _vertexBuffers;
  81754. private _spriteBuffer;
  81755. private _indexBuffer;
  81756. private _effect;
  81757. private _customEffect;
  81758. private _cachedDefines;
  81759. private _scaledColorStep;
  81760. private _colorDiff;
  81761. private _scaledDirection;
  81762. private _scaledGravity;
  81763. private _currentRenderId;
  81764. private _alive;
  81765. private _useInstancing;
  81766. private _started;
  81767. private _stopped;
  81768. private _actualFrame;
  81769. private _scaledUpdateSpeed;
  81770. private _vertexBufferSize;
  81771. /** @hidden */
  81772. _currentEmitRateGradient: Nullable<FactorGradient>;
  81773. /** @hidden */
  81774. _currentEmitRate1: number;
  81775. /** @hidden */
  81776. _currentEmitRate2: number;
  81777. /** @hidden */
  81778. _currentStartSizeGradient: Nullable<FactorGradient>;
  81779. /** @hidden */
  81780. _currentStartSize1: number;
  81781. /** @hidden */
  81782. _currentStartSize2: number;
  81783. private readonly _rawTextureWidth;
  81784. private _rampGradientsTexture;
  81785. private _useRampGradients;
  81786. /** Gets or sets a boolean indicating that ramp gradients must be used
  81787. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81788. */
  81789. useRampGradients: boolean;
  81790. /**
  81791. * 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.
  81792. * 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: [])
  81793. */
  81794. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81795. private _subEmitters;
  81796. /**
  81797. * @hidden
  81798. * If the particle systems emitter should be disposed when the particle system is disposed
  81799. */
  81800. _disposeEmitterOnDispose: boolean;
  81801. /**
  81802. * The current active Sub-systems, this property is used by the root particle system only.
  81803. */
  81804. activeSubSystems: Array<ParticleSystem>;
  81805. private _rootParticleSystem;
  81806. /**
  81807. * Gets the current list of active particles
  81808. */
  81809. readonly particles: Particle[];
  81810. /**
  81811. * Returns the string "ParticleSystem"
  81812. * @returns a string containing the class name
  81813. */
  81814. getClassName(): string;
  81815. /**
  81816. * Instantiates a particle system.
  81817. * 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.
  81818. * @param name The name of the particle system
  81819. * @param capacity The max number of particles alive at the same time
  81820. * @param scene The scene the particle system belongs to
  81821. * @param customEffect a custom effect used to change the way particles are rendered by default
  81822. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81823. * @param epsilon Offset used to render the particles
  81824. */
  81825. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81826. private _addFactorGradient;
  81827. private _removeFactorGradient;
  81828. /**
  81829. * Adds a new life time gradient
  81830. * @param gradient defines the gradient to use (between 0 and 1)
  81831. * @param factor defines the life time factor to affect to the specified gradient
  81832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81833. * @returns the current particle system
  81834. */
  81835. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81836. /**
  81837. * Remove a specific life time gradient
  81838. * @param gradient defines the gradient to remove
  81839. * @returns the current particle system
  81840. */
  81841. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81842. /**
  81843. * Adds a new size gradient
  81844. * @param gradient defines the gradient to use (between 0 and 1)
  81845. * @param factor defines the size factor to affect to the specified gradient
  81846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81847. * @returns the current particle system
  81848. */
  81849. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81850. /**
  81851. * Remove a specific size gradient
  81852. * @param gradient defines the gradient to remove
  81853. * @returns the current particle system
  81854. */
  81855. removeSizeGradient(gradient: number): IParticleSystem;
  81856. /**
  81857. * Adds a new color remap gradient
  81858. * @param gradient defines the gradient to use (between 0 and 1)
  81859. * @param min defines the color remap minimal range
  81860. * @param max defines the color remap maximal range
  81861. * @returns the current particle system
  81862. */
  81863. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81864. /**
  81865. * Remove a specific color remap gradient
  81866. * @param gradient defines the gradient to remove
  81867. * @returns the current particle system
  81868. */
  81869. removeColorRemapGradient(gradient: number): IParticleSystem;
  81870. /**
  81871. * Adds a new alpha remap gradient
  81872. * @param gradient defines the gradient to use (between 0 and 1)
  81873. * @param min defines the alpha remap minimal range
  81874. * @param max defines the alpha remap maximal range
  81875. * @returns the current particle system
  81876. */
  81877. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81878. /**
  81879. * Remove a specific alpha remap gradient
  81880. * @param gradient defines the gradient to remove
  81881. * @returns the current particle system
  81882. */
  81883. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81884. /**
  81885. * Adds a new angular speed gradient
  81886. * @param gradient defines the gradient to use (between 0 and 1)
  81887. * @param factor defines the angular speed to affect to the specified gradient
  81888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81889. * @returns the current particle system
  81890. */
  81891. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81892. /**
  81893. * Remove a specific angular speed gradient
  81894. * @param gradient defines the gradient to remove
  81895. * @returns the current particle system
  81896. */
  81897. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81898. /**
  81899. * Adds a new velocity gradient
  81900. * @param gradient defines the gradient to use (between 0 and 1)
  81901. * @param factor defines the velocity to affect to the specified gradient
  81902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81903. * @returns the current particle system
  81904. */
  81905. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81906. /**
  81907. * Remove a specific velocity gradient
  81908. * @param gradient defines the gradient to remove
  81909. * @returns the current particle system
  81910. */
  81911. removeVelocityGradient(gradient: number): IParticleSystem;
  81912. /**
  81913. * Adds a new limit velocity gradient
  81914. * @param gradient defines the gradient to use (between 0 and 1)
  81915. * @param factor defines the limit velocity value to affect to the specified gradient
  81916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81917. * @returns the current particle system
  81918. */
  81919. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81920. /**
  81921. * Remove a specific limit velocity gradient
  81922. * @param gradient defines the gradient to remove
  81923. * @returns the current particle system
  81924. */
  81925. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81926. /**
  81927. * Adds a new drag gradient
  81928. * @param gradient defines the gradient to use (between 0 and 1)
  81929. * @param factor defines the drag value to affect to the specified gradient
  81930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81931. * @returns the current particle system
  81932. */
  81933. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81934. /**
  81935. * Remove a specific drag gradient
  81936. * @param gradient defines the gradient to remove
  81937. * @returns the current particle system
  81938. */
  81939. removeDragGradient(gradient: number): IParticleSystem;
  81940. /**
  81941. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81942. * @param gradient defines the gradient to use (between 0 and 1)
  81943. * @param factor defines the emit rate value to affect to the specified gradient
  81944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81945. * @returns the current particle system
  81946. */
  81947. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81948. /**
  81949. * Remove a specific emit rate gradient
  81950. * @param gradient defines the gradient to remove
  81951. * @returns the current particle system
  81952. */
  81953. removeEmitRateGradient(gradient: number): IParticleSystem;
  81954. /**
  81955. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81956. * @param gradient defines the gradient to use (between 0 and 1)
  81957. * @param factor defines the start size value to affect to the specified gradient
  81958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81959. * @returns the current particle system
  81960. */
  81961. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81962. /**
  81963. * Remove a specific start size gradient
  81964. * @param gradient defines the gradient to remove
  81965. * @returns the current particle system
  81966. */
  81967. removeStartSizeGradient(gradient: number): IParticleSystem;
  81968. private _createRampGradientTexture;
  81969. /**
  81970. * Gets the current list of ramp gradients.
  81971. * You must use addRampGradient and removeRampGradient to udpate this list
  81972. * @returns the list of ramp gradients
  81973. */
  81974. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81975. /**
  81976. * Adds a new ramp gradient used to remap particle colors
  81977. * @param gradient defines the gradient to use (between 0 and 1)
  81978. * @param color defines the color to affect to the specified gradient
  81979. * @returns the current particle system
  81980. */
  81981. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81982. /**
  81983. * Remove a specific ramp gradient
  81984. * @param gradient defines the gradient to remove
  81985. * @returns the current particle system
  81986. */
  81987. removeRampGradient(gradient: number): ParticleSystem;
  81988. /**
  81989. * Adds a new color gradient
  81990. * @param gradient defines the gradient to use (between 0 and 1)
  81991. * @param color1 defines the color to affect to the specified gradient
  81992. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81993. * @returns this particle system
  81994. */
  81995. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81996. /**
  81997. * Remove a specific color gradient
  81998. * @param gradient defines the gradient to remove
  81999. * @returns this particle system
  82000. */
  82001. removeColorGradient(gradient: number): IParticleSystem;
  82002. private _fetchR;
  82003. protected _reset(): void;
  82004. private _resetEffect;
  82005. private _createVertexBuffers;
  82006. private _createIndexBuffer;
  82007. /**
  82008. * Gets the maximum number of particles active at the same time.
  82009. * @returns The max number of active particles.
  82010. */
  82011. getCapacity(): number;
  82012. /**
  82013. * Gets whether there are still active particles in the system.
  82014. * @returns True if it is alive, otherwise false.
  82015. */
  82016. isAlive(): boolean;
  82017. /**
  82018. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82019. * @returns True if it has been started, otherwise false.
  82020. */
  82021. isStarted(): boolean;
  82022. private _prepareSubEmitterInternalArray;
  82023. /**
  82024. * Starts the particle system and begins to emit
  82025. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82026. */
  82027. start(delay?: number): void;
  82028. /**
  82029. * Stops the particle system.
  82030. * @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.
  82031. */
  82032. stop(stopSubEmitters?: boolean): void;
  82033. /**
  82034. * Remove all active particles
  82035. */
  82036. reset(): void;
  82037. /**
  82038. * @hidden (for internal use only)
  82039. */
  82040. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82041. /**
  82042. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82043. * Its lifetime will start back at 0.
  82044. */
  82045. recycleParticle: (particle: Particle) => void;
  82046. private _stopSubEmitters;
  82047. private _createParticle;
  82048. private _removeFromRoot;
  82049. private _emitFromParticle;
  82050. private _update;
  82051. /** @hidden */
  82052. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82053. /** @hidden */
  82054. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82055. /** @hidden */
  82056. private _getEffect;
  82057. /**
  82058. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82059. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82060. */
  82061. animate(preWarmOnly?: boolean): void;
  82062. private _appendParticleVertices;
  82063. /**
  82064. * Rebuilds the particle system.
  82065. */
  82066. rebuild(): void;
  82067. /**
  82068. * Is this system ready to be used/rendered
  82069. * @return true if the system is ready
  82070. */
  82071. isReady(): boolean;
  82072. private _render;
  82073. /**
  82074. * Renders the particle system in its current state.
  82075. * @returns the current number of particles
  82076. */
  82077. render(): number;
  82078. /**
  82079. * Disposes the particle system and free the associated resources
  82080. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82081. */
  82082. dispose(disposeTexture?: boolean): void;
  82083. /**
  82084. * Clones the particle system.
  82085. * @param name The name of the cloned object
  82086. * @param newEmitter The new emitter to use
  82087. * @returns the cloned particle system
  82088. */
  82089. clone(name: string, newEmitter: any): ParticleSystem;
  82090. /**
  82091. * Serializes the particle system to a JSON object.
  82092. * @returns the JSON object
  82093. */
  82094. serialize(): any;
  82095. /** @hidden */
  82096. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82097. /** @hidden */
  82098. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82099. /**
  82100. * Parses a JSON object to create a particle system.
  82101. * @param parsedParticleSystem The JSON object to parse
  82102. * @param scene The scene to create the particle system in
  82103. * @param rootUrl The root url to use to load external dependencies like texture
  82104. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82105. * @returns the Parsed particle system
  82106. */
  82107. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82108. }
  82109. }
  82110. declare module BABYLON {
  82111. /**
  82112. * A particle represents one of the element emitted by a particle system.
  82113. * This is mainly define by its coordinates, direction, velocity and age.
  82114. */
  82115. export class Particle {
  82116. /**
  82117. * The particle system the particle belongs to.
  82118. */
  82119. particleSystem: ParticleSystem;
  82120. private static _Count;
  82121. /**
  82122. * Unique ID of the particle
  82123. */
  82124. id: number;
  82125. /**
  82126. * The world position of the particle in the scene.
  82127. */
  82128. position: Vector3;
  82129. /**
  82130. * The world direction of the particle in the scene.
  82131. */
  82132. direction: Vector3;
  82133. /**
  82134. * The color of the particle.
  82135. */
  82136. color: Color4;
  82137. /**
  82138. * The color change of the particle per step.
  82139. */
  82140. colorStep: Color4;
  82141. /**
  82142. * Defines how long will the life of the particle be.
  82143. */
  82144. lifeTime: number;
  82145. /**
  82146. * The current age of the particle.
  82147. */
  82148. age: number;
  82149. /**
  82150. * The current size of the particle.
  82151. */
  82152. size: number;
  82153. /**
  82154. * The current scale of the particle.
  82155. */
  82156. scale: Vector2;
  82157. /**
  82158. * The current angle of the particle.
  82159. */
  82160. angle: number;
  82161. /**
  82162. * Defines how fast is the angle changing.
  82163. */
  82164. angularSpeed: number;
  82165. /**
  82166. * Defines the cell index used by the particle to be rendered from a sprite.
  82167. */
  82168. cellIndex: number;
  82169. /**
  82170. * The information required to support color remapping
  82171. */
  82172. remapData: Vector4;
  82173. /** @hidden */
  82174. _randomCellOffset?: number;
  82175. /** @hidden */
  82176. _initialDirection: Nullable<Vector3>;
  82177. /** @hidden */
  82178. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82179. /** @hidden */
  82180. _initialStartSpriteCellID: number;
  82181. /** @hidden */
  82182. _initialEndSpriteCellID: number;
  82183. /** @hidden */
  82184. _currentColorGradient: Nullable<ColorGradient>;
  82185. /** @hidden */
  82186. _currentColor1: Color4;
  82187. /** @hidden */
  82188. _currentColor2: Color4;
  82189. /** @hidden */
  82190. _currentSizeGradient: Nullable<FactorGradient>;
  82191. /** @hidden */
  82192. _currentSize1: number;
  82193. /** @hidden */
  82194. _currentSize2: number;
  82195. /** @hidden */
  82196. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82197. /** @hidden */
  82198. _currentAngularSpeed1: number;
  82199. /** @hidden */
  82200. _currentAngularSpeed2: number;
  82201. /** @hidden */
  82202. _currentVelocityGradient: Nullable<FactorGradient>;
  82203. /** @hidden */
  82204. _currentVelocity1: number;
  82205. /** @hidden */
  82206. _currentVelocity2: number;
  82207. /** @hidden */
  82208. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82209. /** @hidden */
  82210. _currentLimitVelocity1: number;
  82211. /** @hidden */
  82212. _currentLimitVelocity2: number;
  82213. /** @hidden */
  82214. _currentDragGradient: Nullable<FactorGradient>;
  82215. /** @hidden */
  82216. _currentDrag1: number;
  82217. /** @hidden */
  82218. _currentDrag2: number;
  82219. /** @hidden */
  82220. _randomNoiseCoordinates1: Vector3;
  82221. /** @hidden */
  82222. _randomNoiseCoordinates2: Vector3;
  82223. /**
  82224. * Creates a new instance Particle
  82225. * @param particleSystem the particle system the particle belongs to
  82226. */
  82227. constructor(
  82228. /**
  82229. * The particle system the particle belongs to.
  82230. */
  82231. particleSystem: ParticleSystem);
  82232. private updateCellInfoFromSystem;
  82233. /**
  82234. * Defines how the sprite cell index is updated for the particle
  82235. */
  82236. updateCellIndex(): void;
  82237. /** @hidden */
  82238. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82239. /** @hidden */
  82240. _inheritParticleInfoToSubEmitters(): void;
  82241. /** @hidden */
  82242. _reset(): void;
  82243. /**
  82244. * Copy the properties of particle to another one.
  82245. * @param other the particle to copy the information to.
  82246. */
  82247. copyTo(other: Particle): void;
  82248. }
  82249. }
  82250. declare module BABYLON {
  82251. /**
  82252. * Particle emitter represents a volume emitting particles.
  82253. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82254. */
  82255. export interface IParticleEmitterType {
  82256. /**
  82257. * Called by the particle System when the direction is computed for the created particle.
  82258. * @param worldMatrix is the world matrix of the particle system
  82259. * @param directionToUpdate is the direction vector to update with the result
  82260. * @param particle is the particle we are computed the direction for
  82261. */
  82262. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82263. /**
  82264. * Called by the particle System when the position is computed for the created particle.
  82265. * @param worldMatrix is the world matrix of the particle system
  82266. * @param positionToUpdate is the position vector to update with the result
  82267. * @param particle is the particle we are computed the position for
  82268. */
  82269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82270. /**
  82271. * Clones the current emitter and returns a copy of it
  82272. * @returns the new emitter
  82273. */
  82274. clone(): IParticleEmitterType;
  82275. /**
  82276. * Called by the GPUParticleSystem to setup the update shader
  82277. * @param effect defines the update shader
  82278. */
  82279. applyToShader(effect: Effect): void;
  82280. /**
  82281. * Returns a string to use to update the GPU particles update shader
  82282. * @returns the effect defines string
  82283. */
  82284. getEffectDefines(): string;
  82285. /**
  82286. * Returns a string representing the class name
  82287. * @returns a string containing the class name
  82288. */
  82289. getClassName(): string;
  82290. /**
  82291. * Serializes the particle system to a JSON object.
  82292. * @returns the JSON object
  82293. */
  82294. serialize(): any;
  82295. /**
  82296. * Parse properties from a JSON object
  82297. * @param serializationObject defines the JSON object
  82298. */
  82299. parse(serializationObject: any): void;
  82300. }
  82301. }
  82302. declare module BABYLON {
  82303. /**
  82304. * Particle emitter emitting particles from the inside of a box.
  82305. * It emits the particles randomly between 2 given directions.
  82306. */
  82307. export class BoxParticleEmitter implements IParticleEmitterType {
  82308. /**
  82309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82310. */
  82311. direction1: Vector3;
  82312. /**
  82313. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82314. */
  82315. direction2: Vector3;
  82316. /**
  82317. * 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.
  82318. */
  82319. minEmitBox: Vector3;
  82320. /**
  82321. * 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.
  82322. */
  82323. maxEmitBox: Vector3;
  82324. /**
  82325. * Creates a new instance BoxParticleEmitter
  82326. */
  82327. constructor();
  82328. /**
  82329. * Called by the particle System when the direction is computed for the created particle.
  82330. * @param worldMatrix is the world matrix of the particle system
  82331. * @param directionToUpdate is the direction vector to update with the result
  82332. * @param particle is the particle we are computed the direction for
  82333. */
  82334. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82335. /**
  82336. * Called by the particle System when the position is computed for the created particle.
  82337. * @param worldMatrix is the world matrix of the particle system
  82338. * @param positionToUpdate is the position vector to update with the result
  82339. * @param particle is the particle we are computed the position for
  82340. */
  82341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82342. /**
  82343. * Clones the current emitter and returns a copy of it
  82344. * @returns the new emitter
  82345. */
  82346. clone(): BoxParticleEmitter;
  82347. /**
  82348. * Called by the GPUParticleSystem to setup the update shader
  82349. * @param effect defines the update shader
  82350. */
  82351. applyToShader(effect: Effect): void;
  82352. /**
  82353. * Returns a string to use to update the GPU particles update shader
  82354. * @returns a string containng the defines string
  82355. */
  82356. getEffectDefines(): string;
  82357. /**
  82358. * Returns the string "BoxParticleEmitter"
  82359. * @returns a string containing the class name
  82360. */
  82361. getClassName(): string;
  82362. /**
  82363. * Serializes the particle system to a JSON object.
  82364. * @returns the JSON object
  82365. */
  82366. serialize(): any;
  82367. /**
  82368. * Parse properties from a JSON object
  82369. * @param serializationObject defines the JSON object
  82370. */
  82371. parse(serializationObject: any): void;
  82372. }
  82373. }
  82374. declare module BABYLON {
  82375. /**
  82376. * Particle emitter emitting particles from the inside of a cone.
  82377. * It emits the particles alongside the cone volume from the base to the particle.
  82378. * The emission direction might be randomized.
  82379. */
  82380. export class ConeParticleEmitter implements IParticleEmitterType {
  82381. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82382. directionRandomizer: number;
  82383. private _radius;
  82384. private _angle;
  82385. private _height;
  82386. /**
  82387. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82388. */
  82389. radiusRange: number;
  82390. /**
  82391. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82392. */
  82393. heightRange: number;
  82394. /**
  82395. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82396. */
  82397. emitFromSpawnPointOnly: boolean;
  82398. /**
  82399. * Gets or sets the radius of the emission cone
  82400. */
  82401. radius: number;
  82402. /**
  82403. * Gets or sets the angle of the emission cone
  82404. */
  82405. angle: number;
  82406. private _buildHeight;
  82407. /**
  82408. * Creates a new instance ConeParticleEmitter
  82409. * @param radius the radius of the emission cone (1 by default)
  82410. * @param angle the cone base angle (PI by default)
  82411. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82412. */
  82413. constructor(radius?: number, angle?: number,
  82414. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82415. directionRandomizer?: number);
  82416. /**
  82417. * Called by the particle System when the direction is computed for the created particle.
  82418. * @param worldMatrix is the world matrix of the particle system
  82419. * @param directionToUpdate is the direction vector to update with the result
  82420. * @param particle is the particle we are computed the direction for
  82421. */
  82422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82423. /**
  82424. * Called by the particle System when the position is computed for the created particle.
  82425. * @param worldMatrix is the world matrix of the particle system
  82426. * @param positionToUpdate is the position vector to update with the result
  82427. * @param particle is the particle we are computed the position for
  82428. */
  82429. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82430. /**
  82431. * Clones the current emitter and returns a copy of it
  82432. * @returns the new emitter
  82433. */
  82434. clone(): ConeParticleEmitter;
  82435. /**
  82436. * Called by the GPUParticleSystem to setup the update shader
  82437. * @param effect defines the update shader
  82438. */
  82439. applyToShader(effect: Effect): void;
  82440. /**
  82441. * Returns a string to use to update the GPU particles update shader
  82442. * @returns a string containng the defines string
  82443. */
  82444. getEffectDefines(): string;
  82445. /**
  82446. * Returns the string "ConeParticleEmitter"
  82447. * @returns a string containing the class name
  82448. */
  82449. getClassName(): string;
  82450. /**
  82451. * Serializes the particle system to a JSON object.
  82452. * @returns the JSON object
  82453. */
  82454. serialize(): any;
  82455. /**
  82456. * Parse properties from a JSON object
  82457. * @param serializationObject defines the JSON object
  82458. */
  82459. parse(serializationObject: any): void;
  82460. }
  82461. }
  82462. declare module BABYLON {
  82463. /**
  82464. * Particle emitter emitting particles from the inside of a cylinder.
  82465. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82466. */
  82467. export class CylinderParticleEmitter implements IParticleEmitterType {
  82468. /**
  82469. * The radius of the emission cylinder.
  82470. */
  82471. radius: number;
  82472. /**
  82473. * The height of the emission cylinder.
  82474. */
  82475. height: number;
  82476. /**
  82477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82478. */
  82479. radiusRange: number;
  82480. /**
  82481. * How much to randomize the particle direction [0-1].
  82482. */
  82483. directionRandomizer: number;
  82484. /**
  82485. * Creates a new instance CylinderParticleEmitter
  82486. * @param radius the radius of the emission cylinder (1 by default)
  82487. * @param height the height of the emission cylinder (1 by default)
  82488. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82490. */
  82491. constructor(
  82492. /**
  82493. * The radius of the emission cylinder.
  82494. */
  82495. radius?: number,
  82496. /**
  82497. * The height of the emission cylinder.
  82498. */
  82499. height?: number,
  82500. /**
  82501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82502. */
  82503. radiusRange?: number,
  82504. /**
  82505. * How much to randomize the particle direction [0-1].
  82506. */
  82507. directionRandomizer?: number);
  82508. /**
  82509. * Called by the particle System when the direction is computed for the created particle.
  82510. * @param worldMatrix is the world matrix of the particle system
  82511. * @param directionToUpdate is the direction vector to update with the result
  82512. * @param particle is the particle we are computed the direction for
  82513. */
  82514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82515. /**
  82516. * Called by the particle System when the position is computed for the created particle.
  82517. * @param worldMatrix is the world matrix of the particle system
  82518. * @param positionToUpdate is the position vector to update with the result
  82519. * @param particle is the particle we are computed the position for
  82520. */
  82521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82522. /**
  82523. * Clones the current emitter and returns a copy of it
  82524. * @returns the new emitter
  82525. */
  82526. clone(): CylinderParticleEmitter;
  82527. /**
  82528. * Called by the GPUParticleSystem to setup the update shader
  82529. * @param effect defines the update shader
  82530. */
  82531. applyToShader(effect: Effect): void;
  82532. /**
  82533. * Returns a string to use to update the GPU particles update shader
  82534. * @returns a string containng the defines string
  82535. */
  82536. getEffectDefines(): string;
  82537. /**
  82538. * Returns the string "CylinderParticleEmitter"
  82539. * @returns a string containing the class name
  82540. */
  82541. getClassName(): string;
  82542. /**
  82543. * Serializes the particle system to a JSON object.
  82544. * @returns the JSON object
  82545. */
  82546. serialize(): any;
  82547. /**
  82548. * Parse properties from a JSON object
  82549. * @param serializationObject defines the JSON object
  82550. */
  82551. parse(serializationObject: any): void;
  82552. }
  82553. /**
  82554. * Particle emitter emitting particles from the inside of a cylinder.
  82555. * It emits the particles randomly between two vectors.
  82556. */
  82557. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82558. /**
  82559. * The min limit of the emission direction.
  82560. */
  82561. direction1: Vector3;
  82562. /**
  82563. * The max limit of the emission direction.
  82564. */
  82565. direction2: Vector3;
  82566. /**
  82567. * Creates a new instance CylinderDirectedParticleEmitter
  82568. * @param radius the radius of the emission cylinder (1 by default)
  82569. * @param height the height of the emission cylinder (1 by default)
  82570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82571. * @param direction1 the min limit of the emission direction (up vector by default)
  82572. * @param direction2 the max limit of the emission direction (up vector by default)
  82573. */
  82574. constructor(radius?: number, height?: number, radiusRange?: number,
  82575. /**
  82576. * The min limit of the emission direction.
  82577. */
  82578. direction1?: Vector3,
  82579. /**
  82580. * The max limit of the emission direction.
  82581. */
  82582. direction2?: Vector3);
  82583. /**
  82584. * Called by the particle System when the direction is computed for the created particle.
  82585. * @param worldMatrix is the world matrix of the particle system
  82586. * @param directionToUpdate is the direction vector to update with the result
  82587. * @param particle is the particle we are computed the direction for
  82588. */
  82589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82590. /**
  82591. * Clones the current emitter and returns a copy of it
  82592. * @returns the new emitter
  82593. */
  82594. clone(): CylinderDirectedParticleEmitter;
  82595. /**
  82596. * Called by the GPUParticleSystem to setup the update shader
  82597. * @param effect defines the update shader
  82598. */
  82599. applyToShader(effect: Effect): void;
  82600. /**
  82601. * Returns a string to use to update the GPU particles update shader
  82602. * @returns a string containng the defines string
  82603. */
  82604. getEffectDefines(): string;
  82605. /**
  82606. * Returns the string "CylinderDirectedParticleEmitter"
  82607. * @returns a string containing the class name
  82608. */
  82609. getClassName(): string;
  82610. /**
  82611. * Serializes the particle system to a JSON object.
  82612. * @returns the JSON object
  82613. */
  82614. serialize(): any;
  82615. /**
  82616. * Parse properties from a JSON object
  82617. * @param serializationObject defines the JSON object
  82618. */
  82619. parse(serializationObject: any): void;
  82620. }
  82621. }
  82622. declare module BABYLON {
  82623. /**
  82624. * Particle emitter emitting particles from the inside of a hemisphere.
  82625. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82626. */
  82627. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82628. /**
  82629. * The radius of the emission hemisphere.
  82630. */
  82631. radius: number;
  82632. /**
  82633. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82634. */
  82635. radiusRange: number;
  82636. /**
  82637. * How much to randomize the particle direction [0-1].
  82638. */
  82639. directionRandomizer: number;
  82640. /**
  82641. * Creates a new instance HemisphericParticleEmitter
  82642. * @param radius the radius of the emission hemisphere (1 by default)
  82643. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82644. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82645. */
  82646. constructor(
  82647. /**
  82648. * The radius of the emission hemisphere.
  82649. */
  82650. radius?: number,
  82651. /**
  82652. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82653. */
  82654. radiusRange?: number,
  82655. /**
  82656. * How much to randomize the particle direction [0-1].
  82657. */
  82658. directionRandomizer?: number);
  82659. /**
  82660. * Called by the particle System when the direction is computed for the created particle.
  82661. * @param worldMatrix is the world matrix of the particle system
  82662. * @param directionToUpdate is the direction vector to update with the result
  82663. * @param particle is the particle we are computed the direction for
  82664. */
  82665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82666. /**
  82667. * Called by the particle System when the position is computed for the created particle.
  82668. * @param worldMatrix is the world matrix of the particle system
  82669. * @param positionToUpdate is the position vector to update with the result
  82670. * @param particle is the particle we are computed the position for
  82671. */
  82672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82673. /**
  82674. * Clones the current emitter and returns a copy of it
  82675. * @returns the new emitter
  82676. */
  82677. clone(): HemisphericParticleEmitter;
  82678. /**
  82679. * Called by the GPUParticleSystem to setup the update shader
  82680. * @param effect defines the update shader
  82681. */
  82682. applyToShader(effect: Effect): void;
  82683. /**
  82684. * Returns a string to use to update the GPU particles update shader
  82685. * @returns a string containng the defines string
  82686. */
  82687. getEffectDefines(): string;
  82688. /**
  82689. * Returns the string "HemisphericParticleEmitter"
  82690. * @returns a string containing the class name
  82691. */
  82692. getClassName(): string;
  82693. /**
  82694. * Serializes the particle system to a JSON object.
  82695. * @returns the JSON object
  82696. */
  82697. serialize(): any;
  82698. /**
  82699. * Parse properties from a JSON object
  82700. * @param serializationObject defines the JSON object
  82701. */
  82702. parse(serializationObject: any): void;
  82703. }
  82704. }
  82705. declare module BABYLON {
  82706. /**
  82707. * Particle emitter emitting particles from a point.
  82708. * It emits the particles randomly between 2 given directions.
  82709. */
  82710. export class PointParticleEmitter implements IParticleEmitterType {
  82711. /**
  82712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82713. */
  82714. direction1: Vector3;
  82715. /**
  82716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82717. */
  82718. direction2: Vector3;
  82719. /**
  82720. * Creates a new instance PointParticleEmitter
  82721. */
  82722. constructor();
  82723. /**
  82724. * Called by the particle System when the direction is computed for the created particle.
  82725. * @param worldMatrix is the world matrix of the particle system
  82726. * @param directionToUpdate is the direction vector to update with the result
  82727. * @param particle is the particle we are computed the direction for
  82728. */
  82729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82730. /**
  82731. * Called by the particle System when the position is computed for the created particle.
  82732. * @param worldMatrix is the world matrix of the particle system
  82733. * @param positionToUpdate is the position vector to update with the result
  82734. * @param particle is the particle we are computed the position for
  82735. */
  82736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82737. /**
  82738. * Clones the current emitter and returns a copy of it
  82739. * @returns the new emitter
  82740. */
  82741. clone(): PointParticleEmitter;
  82742. /**
  82743. * Called by the GPUParticleSystem to setup the update shader
  82744. * @param effect defines the update shader
  82745. */
  82746. applyToShader(effect: Effect): void;
  82747. /**
  82748. * Returns a string to use to update the GPU particles update shader
  82749. * @returns a string containng the defines string
  82750. */
  82751. getEffectDefines(): string;
  82752. /**
  82753. * Returns the string "PointParticleEmitter"
  82754. * @returns a string containing the class name
  82755. */
  82756. getClassName(): string;
  82757. /**
  82758. * Serializes the particle system to a JSON object.
  82759. * @returns the JSON object
  82760. */
  82761. serialize(): any;
  82762. /**
  82763. * Parse properties from a JSON object
  82764. * @param serializationObject defines the JSON object
  82765. */
  82766. parse(serializationObject: any): void;
  82767. }
  82768. }
  82769. declare module BABYLON {
  82770. /**
  82771. * Particle emitter emitting particles from the inside of a sphere.
  82772. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82773. */
  82774. export class SphereParticleEmitter implements IParticleEmitterType {
  82775. /**
  82776. * The radius of the emission sphere.
  82777. */
  82778. radius: number;
  82779. /**
  82780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82781. */
  82782. radiusRange: number;
  82783. /**
  82784. * How much to randomize the particle direction [0-1].
  82785. */
  82786. directionRandomizer: number;
  82787. /**
  82788. * Creates a new instance SphereParticleEmitter
  82789. * @param radius the radius of the emission sphere (1 by default)
  82790. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82791. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82792. */
  82793. constructor(
  82794. /**
  82795. * The radius of the emission sphere.
  82796. */
  82797. radius?: number,
  82798. /**
  82799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82800. */
  82801. radiusRange?: number,
  82802. /**
  82803. * How much to randomize the particle direction [0-1].
  82804. */
  82805. directionRandomizer?: number);
  82806. /**
  82807. * Called by the particle System when the direction is computed for the created particle.
  82808. * @param worldMatrix is the world matrix of the particle system
  82809. * @param directionToUpdate is the direction vector to update with the result
  82810. * @param particle is the particle we are computed the direction for
  82811. */
  82812. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82813. /**
  82814. * Called by the particle System when the position is computed for the created particle.
  82815. * @param worldMatrix is the world matrix of the particle system
  82816. * @param positionToUpdate is the position vector to update with the result
  82817. * @param particle is the particle we are computed the position for
  82818. */
  82819. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82820. /**
  82821. * Clones the current emitter and returns a copy of it
  82822. * @returns the new emitter
  82823. */
  82824. clone(): SphereParticleEmitter;
  82825. /**
  82826. * Called by the GPUParticleSystem to setup the update shader
  82827. * @param effect defines the update shader
  82828. */
  82829. applyToShader(effect: Effect): void;
  82830. /**
  82831. * Returns a string to use to update the GPU particles update shader
  82832. * @returns a string containng the defines string
  82833. */
  82834. getEffectDefines(): string;
  82835. /**
  82836. * Returns the string "SphereParticleEmitter"
  82837. * @returns a string containing the class name
  82838. */
  82839. getClassName(): string;
  82840. /**
  82841. * Serializes the particle system to a JSON object.
  82842. * @returns the JSON object
  82843. */
  82844. serialize(): any;
  82845. /**
  82846. * Parse properties from a JSON object
  82847. * @param serializationObject defines the JSON object
  82848. */
  82849. parse(serializationObject: any): void;
  82850. }
  82851. /**
  82852. * Particle emitter emitting particles from the inside of a sphere.
  82853. * It emits the particles randomly between two vectors.
  82854. */
  82855. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82856. /**
  82857. * The min limit of the emission direction.
  82858. */
  82859. direction1: Vector3;
  82860. /**
  82861. * The max limit of the emission direction.
  82862. */
  82863. direction2: Vector3;
  82864. /**
  82865. * Creates a new instance SphereDirectedParticleEmitter
  82866. * @param radius the radius of the emission sphere (1 by default)
  82867. * @param direction1 the min limit of the emission direction (up vector by default)
  82868. * @param direction2 the max limit of the emission direction (up vector by default)
  82869. */
  82870. constructor(radius?: number,
  82871. /**
  82872. * The min limit of the emission direction.
  82873. */
  82874. direction1?: Vector3,
  82875. /**
  82876. * The max limit of the emission direction.
  82877. */
  82878. direction2?: Vector3);
  82879. /**
  82880. * Called by the particle System when the direction is computed for the created particle.
  82881. * @param worldMatrix is the world matrix of the particle system
  82882. * @param directionToUpdate is the direction vector to update with the result
  82883. * @param particle is the particle we are computed the direction for
  82884. */
  82885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82886. /**
  82887. * Clones the current emitter and returns a copy of it
  82888. * @returns the new emitter
  82889. */
  82890. clone(): SphereDirectedParticleEmitter;
  82891. /**
  82892. * Called by the GPUParticleSystem to setup the update shader
  82893. * @param effect defines the update shader
  82894. */
  82895. applyToShader(effect: Effect): void;
  82896. /**
  82897. * Returns a string to use to update the GPU particles update shader
  82898. * @returns a string containng the defines string
  82899. */
  82900. getEffectDefines(): string;
  82901. /**
  82902. * Returns the string "SphereDirectedParticleEmitter"
  82903. * @returns a string containing the class name
  82904. */
  82905. getClassName(): string;
  82906. /**
  82907. * Serializes the particle system to a JSON object.
  82908. * @returns the JSON object
  82909. */
  82910. serialize(): any;
  82911. /**
  82912. * Parse properties from a JSON object
  82913. * @param serializationObject defines the JSON object
  82914. */
  82915. parse(serializationObject: any): void;
  82916. }
  82917. }
  82918. declare module BABYLON {
  82919. /**
  82920. * Interface representing a particle system in Babylon.js.
  82921. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82922. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82923. */
  82924. export interface IParticleSystem {
  82925. /**
  82926. * List of animations used by the particle system.
  82927. */
  82928. animations: Animation[];
  82929. /**
  82930. * The id of the Particle system.
  82931. */
  82932. id: string;
  82933. /**
  82934. * The name of the Particle system.
  82935. */
  82936. name: string;
  82937. /**
  82938. * The emitter represents the Mesh or position we are attaching the particle system to.
  82939. */
  82940. emitter: Nullable<AbstractMesh | Vector3>;
  82941. /**
  82942. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82943. */
  82944. isBillboardBased: boolean;
  82945. /**
  82946. * The rendering group used by the Particle system to chose when to render.
  82947. */
  82948. renderingGroupId: number;
  82949. /**
  82950. * The layer mask we are rendering the particles through.
  82951. */
  82952. layerMask: number;
  82953. /**
  82954. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82955. */
  82956. updateSpeed: number;
  82957. /**
  82958. * The amount of time the particle system is running (depends of the overall update speed).
  82959. */
  82960. targetStopDuration: number;
  82961. /**
  82962. * The texture used to render each particle. (this can be a spritesheet)
  82963. */
  82964. particleTexture: Nullable<Texture>;
  82965. /**
  82966. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82967. */
  82968. blendMode: number;
  82969. /**
  82970. * Minimum life time of emitting particles.
  82971. */
  82972. minLifeTime: number;
  82973. /**
  82974. * Maximum life time of emitting particles.
  82975. */
  82976. maxLifeTime: number;
  82977. /**
  82978. * Minimum Size of emitting particles.
  82979. */
  82980. minSize: number;
  82981. /**
  82982. * Maximum Size of emitting particles.
  82983. */
  82984. maxSize: number;
  82985. /**
  82986. * Minimum scale of emitting particles on X axis.
  82987. */
  82988. minScaleX: number;
  82989. /**
  82990. * Maximum scale of emitting particles on X axis.
  82991. */
  82992. maxScaleX: number;
  82993. /**
  82994. * Minimum scale of emitting particles on Y axis.
  82995. */
  82996. minScaleY: number;
  82997. /**
  82998. * Maximum scale of emitting particles on Y axis.
  82999. */
  83000. maxScaleY: number;
  83001. /**
  83002. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83003. */
  83004. color1: Color4;
  83005. /**
  83006. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83007. */
  83008. color2: Color4;
  83009. /**
  83010. * Color the particle will have at the end of its lifetime.
  83011. */
  83012. colorDead: Color4;
  83013. /**
  83014. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83015. */
  83016. emitRate: number;
  83017. /**
  83018. * You can use gravity if you want to give an orientation to your particles.
  83019. */
  83020. gravity: Vector3;
  83021. /**
  83022. * Minimum power of emitting particles.
  83023. */
  83024. minEmitPower: number;
  83025. /**
  83026. * Maximum power of emitting particles.
  83027. */
  83028. maxEmitPower: number;
  83029. /**
  83030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83031. */
  83032. minAngularSpeed: number;
  83033. /**
  83034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83035. */
  83036. maxAngularSpeed: number;
  83037. /**
  83038. * Gets or sets the minimal initial rotation in radians.
  83039. */
  83040. minInitialRotation: number;
  83041. /**
  83042. * Gets or sets the maximal initial rotation in radians.
  83043. */
  83044. maxInitialRotation: number;
  83045. /**
  83046. * The particle emitter type defines the emitter used by the particle system.
  83047. * It can be for example box, sphere, or cone...
  83048. */
  83049. particleEmitterType: Nullable<IParticleEmitterType>;
  83050. /**
  83051. * Defines the delay in milliseconds before starting the system (0 by default)
  83052. */
  83053. startDelay: number;
  83054. /**
  83055. * 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
  83056. */
  83057. preWarmCycles: number;
  83058. /**
  83059. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83060. */
  83061. preWarmStepOffset: number;
  83062. /**
  83063. * 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)
  83064. */
  83065. spriteCellChangeSpeed: number;
  83066. /**
  83067. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83068. */
  83069. startSpriteCellID: number;
  83070. /**
  83071. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83072. */
  83073. endSpriteCellID: number;
  83074. /**
  83075. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83076. */
  83077. spriteCellWidth: number;
  83078. /**
  83079. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83080. */
  83081. spriteCellHeight: number;
  83082. /**
  83083. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83084. */
  83085. spriteRandomStartCell: boolean;
  83086. /**
  83087. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83088. */
  83089. isAnimationSheetEnabled: boolean;
  83090. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83091. translationPivot: Vector2;
  83092. /**
  83093. * Gets or sets a texture used to add random noise to particle positions
  83094. */
  83095. noiseTexture: Nullable<BaseTexture>;
  83096. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83097. noiseStrength: Vector3;
  83098. /**
  83099. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83100. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83101. */
  83102. billboardMode: number;
  83103. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83104. limitVelocityDamping: number;
  83105. /**
  83106. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83107. */
  83108. beginAnimationOnStart: boolean;
  83109. /**
  83110. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83111. */
  83112. beginAnimationFrom: number;
  83113. /**
  83114. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83115. */
  83116. beginAnimationTo: number;
  83117. /**
  83118. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83119. */
  83120. beginAnimationLoop: boolean;
  83121. /**
  83122. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83123. */
  83124. disposeOnStop: boolean;
  83125. /**
  83126. * Gets the maximum number of particles active at the same time.
  83127. * @returns The max number of active particles.
  83128. */
  83129. getCapacity(): number;
  83130. /**
  83131. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83132. * @returns True if it has been started, otherwise false.
  83133. */
  83134. isStarted(): boolean;
  83135. /**
  83136. * Animates the particle system for this frame.
  83137. */
  83138. animate(): void;
  83139. /**
  83140. * Renders the particle system in its current state.
  83141. * @returns the current number of particles
  83142. */
  83143. render(): number;
  83144. /**
  83145. * Dispose the particle system and frees its associated resources.
  83146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83147. */
  83148. dispose(disposeTexture?: boolean): void;
  83149. /**
  83150. * Clones the particle system.
  83151. * @param name The name of the cloned object
  83152. * @param newEmitter The new emitter to use
  83153. * @returns the cloned particle system
  83154. */
  83155. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83156. /**
  83157. * Serializes the particle system to a JSON object.
  83158. * @returns the JSON object
  83159. */
  83160. serialize(): any;
  83161. /**
  83162. * Rebuild the particle system
  83163. */
  83164. rebuild(): void;
  83165. /**
  83166. * Starts the particle system and begins to emit
  83167. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83168. */
  83169. start(delay?: number): void;
  83170. /**
  83171. * Stops the particle system.
  83172. */
  83173. stop(): void;
  83174. /**
  83175. * Remove all active particles
  83176. */
  83177. reset(): void;
  83178. /**
  83179. * Is this system ready to be used/rendered
  83180. * @return true if the system is ready
  83181. */
  83182. isReady(): boolean;
  83183. /**
  83184. * Adds a new color gradient
  83185. * @param gradient defines the gradient to use (between 0 and 1)
  83186. * @param color1 defines the color to affect to the specified gradient
  83187. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83188. * @returns the current particle system
  83189. */
  83190. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83191. /**
  83192. * Remove a specific color gradient
  83193. * @param gradient defines the gradient to remove
  83194. * @returns the current particle system
  83195. */
  83196. removeColorGradient(gradient: number): IParticleSystem;
  83197. /**
  83198. * Adds a new size gradient
  83199. * @param gradient defines the gradient to use (between 0 and 1)
  83200. * @param factor defines the size factor to affect to the specified gradient
  83201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83202. * @returns the current particle system
  83203. */
  83204. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83205. /**
  83206. * Remove a specific size gradient
  83207. * @param gradient defines the gradient to remove
  83208. * @returns the current particle system
  83209. */
  83210. removeSizeGradient(gradient: number): IParticleSystem;
  83211. /**
  83212. * Gets the current list of color gradients.
  83213. * You must use addColorGradient and removeColorGradient to udpate this list
  83214. * @returns the list of color gradients
  83215. */
  83216. getColorGradients(): Nullable<Array<ColorGradient>>;
  83217. /**
  83218. * Gets the current list of size gradients.
  83219. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83220. * @returns the list of size gradients
  83221. */
  83222. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83223. /**
  83224. * Gets the current list of angular speed gradients.
  83225. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83226. * @returns the list of angular speed gradients
  83227. */
  83228. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83229. /**
  83230. * Adds a new angular speed gradient
  83231. * @param gradient defines the gradient to use (between 0 and 1)
  83232. * @param factor defines the angular speed to affect to the specified gradient
  83233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83234. * @returns the current particle system
  83235. */
  83236. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83237. /**
  83238. * Remove a specific angular speed gradient
  83239. * @param gradient defines the gradient to remove
  83240. * @returns the current particle system
  83241. */
  83242. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83243. /**
  83244. * Gets the current list of velocity gradients.
  83245. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83246. * @returns the list of velocity gradients
  83247. */
  83248. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83249. /**
  83250. * Adds a new velocity gradient
  83251. * @param gradient defines the gradient to use (between 0 and 1)
  83252. * @param factor defines the velocity to affect to the specified gradient
  83253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83254. * @returns the current particle system
  83255. */
  83256. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83257. /**
  83258. * Remove a specific velocity gradient
  83259. * @param gradient defines the gradient to remove
  83260. * @returns the current particle system
  83261. */
  83262. removeVelocityGradient(gradient: number): IParticleSystem;
  83263. /**
  83264. * Gets the current list of limit velocity gradients.
  83265. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83266. * @returns the list of limit velocity gradients
  83267. */
  83268. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83269. /**
  83270. * Adds a new limit velocity gradient
  83271. * @param gradient defines the gradient to use (between 0 and 1)
  83272. * @param factor defines the limit velocity to affect to the specified gradient
  83273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83274. * @returns the current particle system
  83275. */
  83276. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83277. /**
  83278. * Remove a specific limit velocity gradient
  83279. * @param gradient defines the gradient to remove
  83280. * @returns the current particle system
  83281. */
  83282. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83283. /**
  83284. * Adds a new drag gradient
  83285. * @param gradient defines the gradient to use (between 0 and 1)
  83286. * @param factor defines the drag to affect to the specified gradient
  83287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83288. * @returns the current particle system
  83289. */
  83290. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83291. /**
  83292. * Remove a specific drag gradient
  83293. * @param gradient defines the gradient to remove
  83294. * @returns the current particle system
  83295. */
  83296. removeDragGradient(gradient: number): IParticleSystem;
  83297. /**
  83298. * Gets the current list of drag gradients.
  83299. * You must use addDragGradient and removeDragGradient to udpate this list
  83300. * @returns the list of drag gradients
  83301. */
  83302. getDragGradients(): Nullable<Array<FactorGradient>>;
  83303. /**
  83304. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83305. * @param gradient defines the gradient to use (between 0 and 1)
  83306. * @param factor defines the emit rate to affect to the specified gradient
  83307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83308. * @returns the current particle system
  83309. */
  83310. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83311. /**
  83312. * Remove a specific emit rate gradient
  83313. * @param gradient defines the gradient to remove
  83314. * @returns the current particle system
  83315. */
  83316. removeEmitRateGradient(gradient: number): IParticleSystem;
  83317. /**
  83318. * Gets the current list of emit rate gradients.
  83319. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83320. * @returns the list of emit rate gradients
  83321. */
  83322. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83323. /**
  83324. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83325. * @param gradient defines the gradient to use (between 0 and 1)
  83326. * @param factor defines the start size to affect to the specified gradient
  83327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83328. * @returns the current particle system
  83329. */
  83330. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83331. /**
  83332. * Remove a specific start size gradient
  83333. * @param gradient defines the gradient to remove
  83334. * @returns the current particle system
  83335. */
  83336. removeStartSizeGradient(gradient: number): IParticleSystem;
  83337. /**
  83338. * Gets the current list of start size gradients.
  83339. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83340. * @returns the list of start size gradients
  83341. */
  83342. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83343. /**
  83344. * Adds a new life time gradient
  83345. * @param gradient defines the gradient to use (between 0 and 1)
  83346. * @param factor defines the life time factor to affect to the specified gradient
  83347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83348. * @returns the current particle system
  83349. */
  83350. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83351. /**
  83352. * Remove a specific life time gradient
  83353. * @param gradient defines the gradient to remove
  83354. * @returns the current particle system
  83355. */
  83356. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83357. /**
  83358. * Gets the current list of life time gradients.
  83359. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83360. * @returns the list of life time gradients
  83361. */
  83362. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83363. /**
  83364. * Gets the current list of color gradients.
  83365. * You must use addColorGradient and removeColorGradient to udpate this list
  83366. * @returns the list of color gradients
  83367. */
  83368. getColorGradients(): Nullable<Array<ColorGradient>>;
  83369. /**
  83370. * Adds a new ramp gradient used to remap particle colors
  83371. * @param gradient defines the gradient to use (between 0 and 1)
  83372. * @param color defines the color to affect to the specified gradient
  83373. * @returns the current particle system
  83374. */
  83375. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83376. /**
  83377. * Gets the current list of ramp gradients.
  83378. * You must use addRampGradient and removeRampGradient to udpate this list
  83379. * @returns the list of ramp gradients
  83380. */
  83381. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83382. /** Gets or sets a boolean indicating that ramp gradients must be used
  83383. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83384. */
  83385. useRampGradients: boolean;
  83386. /**
  83387. * Adds a new color remap gradient
  83388. * @param gradient defines the gradient to use (between 0 and 1)
  83389. * @param min defines the color remap minimal range
  83390. * @param max defines the color remap maximal range
  83391. * @returns the current particle system
  83392. */
  83393. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83394. /**
  83395. * Gets the current list of color remap gradients.
  83396. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83397. * @returns the list of color remap gradients
  83398. */
  83399. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83400. /**
  83401. * Adds a new alpha remap gradient
  83402. * @param gradient defines the gradient to use (between 0 and 1)
  83403. * @param min defines the alpha remap minimal range
  83404. * @param max defines the alpha remap maximal range
  83405. * @returns the current particle system
  83406. */
  83407. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83408. /**
  83409. * Gets the current list of alpha remap gradients.
  83410. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83411. * @returns the list of alpha remap gradients
  83412. */
  83413. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83414. /**
  83415. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83416. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83417. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83418. * @returns the emitter
  83419. */
  83420. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83421. /**
  83422. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83423. * @param radius The radius of the hemisphere to emit from
  83424. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83425. * @returns the emitter
  83426. */
  83427. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83428. /**
  83429. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83430. * @param radius The radius of the sphere to emit from
  83431. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83432. * @returns the emitter
  83433. */
  83434. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83435. /**
  83436. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83437. * @param radius The radius of the sphere to emit from
  83438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83440. * @returns the emitter
  83441. */
  83442. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83443. /**
  83444. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83445. * @param radius The radius of the emission cylinder
  83446. * @param height The height of the emission cylinder
  83447. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83448. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83449. * @returns the emitter
  83450. */
  83451. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83452. /**
  83453. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83454. * @param radius The radius of the cylinder to emit from
  83455. * @param height The height of the emission cylinder
  83456. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83459. * @returns the emitter
  83460. */
  83461. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83462. /**
  83463. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83464. * @param radius The radius of the cone to emit from
  83465. * @param angle The base angle of the cone
  83466. * @returns the emitter
  83467. */
  83468. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83469. /**
  83470. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83473. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83474. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83475. * @returns the emitter
  83476. */
  83477. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83478. /**
  83479. * Get hosting scene
  83480. * @returns the scene
  83481. */
  83482. getScene(): Scene;
  83483. }
  83484. }
  83485. declare module BABYLON {
  83486. /**
  83487. * Creates an instance based on a source mesh.
  83488. */
  83489. export class InstancedMesh extends AbstractMesh {
  83490. private _sourceMesh;
  83491. private _currentLOD;
  83492. /** @hidden */
  83493. _indexInSourceMeshInstanceArray: number;
  83494. constructor(name: string, source: Mesh);
  83495. /**
  83496. * Returns the string "InstancedMesh".
  83497. */
  83498. getClassName(): string;
  83499. /** Gets the list of lights affecting that mesh */
  83500. readonly lightSources: Light[];
  83501. _resyncLightSources(): void;
  83502. _resyncLighSource(light: Light): void;
  83503. _removeLightSource(light: Light): void;
  83504. /**
  83505. * If the source mesh receives shadows
  83506. */
  83507. readonly receiveShadows: boolean;
  83508. /**
  83509. * The material of the source mesh
  83510. */
  83511. readonly material: Nullable<Material>;
  83512. /**
  83513. * Visibility of the source mesh
  83514. */
  83515. readonly visibility: number;
  83516. /**
  83517. * Skeleton of the source mesh
  83518. */
  83519. readonly skeleton: Nullable<Skeleton>;
  83520. /**
  83521. * Rendering ground id of the source mesh
  83522. */
  83523. renderingGroupId: number;
  83524. /**
  83525. * Returns the total number of vertices (integer).
  83526. */
  83527. getTotalVertices(): number;
  83528. /**
  83529. * Returns a positive integer : the total number of indices in this mesh geometry.
  83530. * @returns the numner of indices or zero if the mesh has no geometry.
  83531. */
  83532. getTotalIndices(): number;
  83533. /**
  83534. * The source mesh of the instance
  83535. */
  83536. readonly sourceMesh: Mesh;
  83537. /**
  83538. * Is this node ready to be used/rendered
  83539. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83540. * @return {boolean} is it ready
  83541. */
  83542. isReady(completeCheck?: boolean): boolean;
  83543. /**
  83544. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83545. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83546. * @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.
  83547. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83548. */
  83549. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83550. /**
  83551. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83552. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83553. * The `data` are either a numeric array either a Float32Array.
  83554. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83555. * 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).
  83556. * Note that a new underlying VertexBuffer object is created each call.
  83557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83558. *
  83559. * Possible `kind` values :
  83560. * - VertexBuffer.PositionKind
  83561. * - VertexBuffer.UVKind
  83562. * - VertexBuffer.UV2Kind
  83563. * - VertexBuffer.UV3Kind
  83564. * - VertexBuffer.UV4Kind
  83565. * - VertexBuffer.UV5Kind
  83566. * - VertexBuffer.UV6Kind
  83567. * - VertexBuffer.ColorKind
  83568. * - VertexBuffer.MatricesIndicesKind
  83569. * - VertexBuffer.MatricesIndicesExtraKind
  83570. * - VertexBuffer.MatricesWeightsKind
  83571. * - VertexBuffer.MatricesWeightsExtraKind
  83572. *
  83573. * Returns the Mesh.
  83574. */
  83575. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83576. /**
  83577. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83578. * If the mesh has no geometry, it is simply returned as it is.
  83579. * The `data` are either a numeric array either a Float32Array.
  83580. * No new underlying VertexBuffer object is created.
  83581. * 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.
  83582. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83583. *
  83584. * Possible `kind` values :
  83585. * - VertexBuffer.PositionKind
  83586. * - VertexBuffer.UVKind
  83587. * - VertexBuffer.UV2Kind
  83588. * - VertexBuffer.UV3Kind
  83589. * - VertexBuffer.UV4Kind
  83590. * - VertexBuffer.UV5Kind
  83591. * - VertexBuffer.UV6Kind
  83592. * - VertexBuffer.ColorKind
  83593. * - VertexBuffer.MatricesIndicesKind
  83594. * - VertexBuffer.MatricesIndicesExtraKind
  83595. * - VertexBuffer.MatricesWeightsKind
  83596. * - VertexBuffer.MatricesWeightsExtraKind
  83597. *
  83598. * Returns the Mesh.
  83599. */
  83600. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83601. /**
  83602. * Sets the mesh indices.
  83603. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83604. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83605. * This method creates a new index buffer each call.
  83606. * Returns the Mesh.
  83607. */
  83608. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83609. /**
  83610. * Boolean : True if the mesh owns the requested kind of data.
  83611. */
  83612. isVerticesDataPresent(kind: string): boolean;
  83613. /**
  83614. * Returns an array of indices (IndicesArray).
  83615. */
  83616. getIndices(): Nullable<IndicesArray>;
  83617. readonly _positions: Nullable<Vector3[]>;
  83618. /**
  83619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83620. * This means the mesh underlying bounding box and sphere are recomputed.
  83621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83622. * @returns the current mesh
  83623. */
  83624. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83625. /** @hidden */
  83626. _preActivate(): InstancedMesh;
  83627. /** @hidden */
  83628. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83629. /** @hidden */
  83630. _postActivate(): void;
  83631. getWorldMatrix(): Matrix;
  83632. readonly isAnInstance: boolean;
  83633. /**
  83634. * Returns the current associated LOD AbstractMesh.
  83635. */
  83636. getLOD(camera: Camera): AbstractMesh;
  83637. /** @hidden */
  83638. _syncSubMeshes(): InstancedMesh;
  83639. /** @hidden */
  83640. _generatePointsArray(): boolean;
  83641. /**
  83642. * Creates a new InstancedMesh from the current mesh.
  83643. * - name (string) : the cloned mesh name
  83644. * - newParent (optional Node) : the optional Node to parent the clone to.
  83645. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83646. *
  83647. * Returns the clone.
  83648. */
  83649. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83650. /**
  83651. * Disposes the InstancedMesh.
  83652. * Returns nothing.
  83653. */
  83654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83655. }
  83656. }
  83657. declare module BABYLON {
  83658. /**
  83659. * Defines the options associated with the creation of a shader material.
  83660. */
  83661. export interface IShaderMaterialOptions {
  83662. /**
  83663. * Does the material work in alpha blend mode
  83664. */
  83665. needAlphaBlending: boolean;
  83666. /**
  83667. * Does the material work in alpha test mode
  83668. */
  83669. needAlphaTesting: boolean;
  83670. /**
  83671. * The list of attribute names used in the shader
  83672. */
  83673. attributes: string[];
  83674. /**
  83675. * The list of unifrom names used in the shader
  83676. */
  83677. uniforms: string[];
  83678. /**
  83679. * The list of UBO names used in the shader
  83680. */
  83681. uniformBuffers: string[];
  83682. /**
  83683. * The list of sampler names used in the shader
  83684. */
  83685. samplers: string[];
  83686. /**
  83687. * The list of defines used in the shader
  83688. */
  83689. defines: string[];
  83690. }
  83691. /**
  83692. * 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.
  83693. *
  83694. * This returned material effects how the mesh will look based on the code in the shaders.
  83695. *
  83696. * @see http://doc.babylonjs.com/how_to/shader_material
  83697. */
  83698. export class ShaderMaterial extends Material {
  83699. private _shaderPath;
  83700. private _options;
  83701. private _textures;
  83702. private _textureArrays;
  83703. private _floats;
  83704. private _ints;
  83705. private _floatsArrays;
  83706. private _colors3;
  83707. private _colors3Arrays;
  83708. private _colors4;
  83709. private _colors4Arrays;
  83710. private _vectors2;
  83711. private _vectors3;
  83712. private _vectors4;
  83713. private _matrices;
  83714. private _matrices3x3;
  83715. private _matrices2x2;
  83716. private _vectors2Arrays;
  83717. private _vectors3Arrays;
  83718. private _vectors4Arrays;
  83719. private _cachedWorldViewMatrix;
  83720. private _cachedWorldViewProjectionMatrix;
  83721. private _renderId;
  83722. /**
  83723. * Instantiate a new shader material.
  83724. * 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.
  83725. * This returned material effects how the mesh will look based on the code in the shaders.
  83726. * @see http://doc.babylonjs.com/how_to/shader_material
  83727. * @param name Define the name of the material in the scene
  83728. * @param scene Define the scene the material belongs to
  83729. * @param shaderPath Defines the route to the shader code in one of three ways:
  83730. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83731. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83732. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83733. * @param options Define the options used to create the shader
  83734. */
  83735. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83736. /**
  83737. * Gets the options used to compile the shader.
  83738. * They can be modified to trigger a new compilation
  83739. */
  83740. readonly options: IShaderMaterialOptions;
  83741. /**
  83742. * Gets the current class name of the material e.g. "ShaderMaterial"
  83743. * Mainly use in serialization.
  83744. * @returns the class name
  83745. */
  83746. getClassName(): string;
  83747. /**
  83748. * Specifies if the material will require alpha blending
  83749. * @returns a boolean specifying if alpha blending is needed
  83750. */
  83751. needAlphaBlending(): boolean;
  83752. /**
  83753. * Specifies if this material should be rendered in alpha test mode
  83754. * @returns a boolean specifying if an alpha test is needed.
  83755. */
  83756. needAlphaTesting(): boolean;
  83757. private _checkUniform;
  83758. /**
  83759. * Set a texture in the shader.
  83760. * @param name Define the name of the uniform samplers as defined in the shader
  83761. * @param texture Define the texture to bind to this sampler
  83762. * @return the material itself allowing "fluent" like uniform updates
  83763. */
  83764. setTexture(name: string, texture: Texture): ShaderMaterial;
  83765. /**
  83766. * Set a texture array in the shader.
  83767. * @param name Define the name of the uniform sampler array as defined in the shader
  83768. * @param textures Define the list of textures to bind to this sampler
  83769. * @return the material itself allowing "fluent" like uniform updates
  83770. */
  83771. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83772. /**
  83773. * Set a float in the shader.
  83774. * @param name Define the name of the uniform as defined in the shader
  83775. * @param value Define the value to give to the uniform
  83776. * @return the material itself allowing "fluent" like uniform updates
  83777. */
  83778. setFloat(name: string, value: number): ShaderMaterial;
  83779. /**
  83780. * Set a int in the shader.
  83781. * @param name Define the name of the uniform as defined in the shader
  83782. * @param value Define the value to give to the uniform
  83783. * @return the material itself allowing "fluent" like uniform updates
  83784. */
  83785. setInt(name: string, value: number): ShaderMaterial;
  83786. /**
  83787. * Set an array of floats in the shader.
  83788. * @param name Define the name of the uniform as defined in the shader
  83789. * @param value Define the value to give to the uniform
  83790. * @return the material itself allowing "fluent" like uniform updates
  83791. */
  83792. setFloats(name: string, value: number[]): ShaderMaterial;
  83793. /**
  83794. * Set a vec3 in the shader from a Color3.
  83795. * @param name Define the name of the uniform as defined in the shader
  83796. * @param value Define the value to give to the uniform
  83797. * @return the material itself allowing "fluent" like uniform updates
  83798. */
  83799. setColor3(name: string, value: Color3): ShaderMaterial;
  83800. /**
  83801. * Set a vec3 array in the shader from a Color3 array.
  83802. * @param name Define the name of the uniform as defined in the shader
  83803. * @param value Define the value to give to the uniform
  83804. * @return the material itself allowing "fluent" like uniform updates
  83805. */
  83806. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83807. /**
  83808. * Set a vec4 in the shader from a Color4.
  83809. * @param name Define the name of the uniform as defined in the shader
  83810. * @param value Define the value to give to the uniform
  83811. * @return the material itself allowing "fluent" like uniform updates
  83812. */
  83813. setColor4(name: string, value: Color4): ShaderMaterial;
  83814. /**
  83815. * Set a vec4 array in the shader from a Color4 array.
  83816. * @param name Define the name of the uniform as defined in the shader
  83817. * @param value Define the value to give to the uniform
  83818. * @return the material itself allowing "fluent" like uniform updates
  83819. */
  83820. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83821. /**
  83822. * Set a vec2 in the shader from a Vector2.
  83823. * @param name Define the name of the uniform as defined in the shader
  83824. * @param value Define the value to give to the uniform
  83825. * @return the material itself allowing "fluent" like uniform updates
  83826. */
  83827. setVector2(name: string, value: Vector2): ShaderMaterial;
  83828. /**
  83829. * Set a vec3 in the shader from a Vector3.
  83830. * @param name Define the name of the uniform as defined in the shader
  83831. * @param value Define the value to give to the uniform
  83832. * @return the material itself allowing "fluent" like uniform updates
  83833. */
  83834. setVector3(name: string, value: Vector3): ShaderMaterial;
  83835. /**
  83836. * Set a vec4 in the shader from a Vector4.
  83837. * @param name Define the name of the uniform as defined in the shader
  83838. * @param value Define the value to give to the uniform
  83839. * @return the material itself allowing "fluent" like uniform updates
  83840. */
  83841. setVector4(name: string, value: Vector4): ShaderMaterial;
  83842. /**
  83843. * Set a mat4 in the shader from a Matrix.
  83844. * @param name Define the name of the uniform as defined in the shader
  83845. * @param value Define the value to give to the uniform
  83846. * @return the material itself allowing "fluent" like uniform updates
  83847. */
  83848. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83849. /**
  83850. * Set a mat3 in the shader from a Float32Array.
  83851. * @param name Define the name of the uniform as defined in the shader
  83852. * @param value Define the value to give to the uniform
  83853. * @return the material itself allowing "fluent" like uniform updates
  83854. */
  83855. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83856. /**
  83857. * Set a mat2 in the shader from a Float32Array.
  83858. * @param name Define the name of the uniform as defined in the shader
  83859. * @param value Define the value to give to the uniform
  83860. * @return the material itself allowing "fluent" like uniform updates
  83861. */
  83862. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83863. /**
  83864. * Set a vec2 array in the shader from a number array.
  83865. * @param name Define the name of the uniform as defined in the shader
  83866. * @param value Define the value to give to the uniform
  83867. * @return the material itself allowing "fluent" like uniform updates
  83868. */
  83869. setArray2(name: string, value: number[]): ShaderMaterial;
  83870. /**
  83871. * Set a vec3 array in the shader from a number array.
  83872. * @param name Define the name of the uniform as defined in the shader
  83873. * @param value Define the value to give to the uniform
  83874. * @return the material itself allowing "fluent" like uniform updates
  83875. */
  83876. setArray3(name: string, value: number[]): ShaderMaterial;
  83877. /**
  83878. * Set a vec4 array in the shader from a number array.
  83879. * @param name Define the name of the uniform as defined in the shader
  83880. * @param value Define the value to give to the uniform
  83881. * @return the material itself allowing "fluent" like uniform updates
  83882. */
  83883. setArray4(name: string, value: number[]): ShaderMaterial;
  83884. private _checkCache;
  83885. /**
  83886. * Specifies that the submesh is ready to be used
  83887. * @param mesh defines the mesh to check
  83888. * @param subMesh defines which submesh to check
  83889. * @param useInstances specifies that instances should be used
  83890. * @returns a boolean indicating that the submesh is ready or not
  83891. */
  83892. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83893. /**
  83894. * Checks if the material is ready to render the requested mesh
  83895. * @param mesh Define the mesh to render
  83896. * @param useInstances Define whether or not the material is used with instances
  83897. * @returns true if ready, otherwise false
  83898. */
  83899. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83900. /**
  83901. * Binds the world matrix to the material
  83902. * @param world defines the world transformation matrix
  83903. */
  83904. bindOnlyWorldMatrix(world: Matrix): void;
  83905. /**
  83906. * Binds the material to the mesh
  83907. * @param world defines the world transformation matrix
  83908. * @param mesh defines the mesh to bind the material to
  83909. */
  83910. bind(world: Matrix, mesh?: Mesh): void;
  83911. /**
  83912. * Gets the active textures from the material
  83913. * @returns an array of textures
  83914. */
  83915. getActiveTextures(): BaseTexture[];
  83916. /**
  83917. * Specifies if the material uses a texture
  83918. * @param texture defines the texture to check against the material
  83919. * @returns a boolean specifying if the material uses the texture
  83920. */
  83921. hasTexture(texture: BaseTexture): boolean;
  83922. /**
  83923. * Makes a duplicate of the material, and gives it a new name
  83924. * @param name defines the new name for the duplicated material
  83925. * @returns the cloned material
  83926. */
  83927. clone(name: string): ShaderMaterial;
  83928. /**
  83929. * Disposes the material
  83930. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83931. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83932. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83933. */
  83934. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83935. /**
  83936. * Serializes this material in a JSON representation
  83937. * @returns the serialized material object
  83938. */
  83939. serialize(): any;
  83940. /**
  83941. * Creates a shader material from parsed shader material data
  83942. * @param source defines the JSON represnetation of the material
  83943. * @param scene defines the hosting scene
  83944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83945. * @returns a new material
  83946. */
  83947. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83948. }
  83949. }
  83950. declare module BABYLON {
  83951. /** @hidden */
  83952. export var colorPixelShader: {
  83953. name: string;
  83954. shader: string;
  83955. };
  83956. }
  83957. declare module BABYLON {
  83958. /** @hidden */
  83959. export var colorVertexShader: {
  83960. name: string;
  83961. shader: string;
  83962. };
  83963. }
  83964. declare module BABYLON {
  83965. /**
  83966. * Line mesh
  83967. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83968. */
  83969. export class LinesMesh extends Mesh {
  83970. /**
  83971. * If vertex color should be applied to the mesh
  83972. */
  83973. readonly useVertexColor?: boolean | undefined;
  83974. /**
  83975. * If vertex alpha should be applied to the mesh
  83976. */
  83977. readonly useVertexAlpha?: boolean | undefined;
  83978. /**
  83979. * Color of the line (Default: White)
  83980. */
  83981. color: Color3;
  83982. /**
  83983. * Alpha of the line (Default: 1)
  83984. */
  83985. alpha: number;
  83986. /**
  83987. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83988. * This margin is expressed in world space coordinates, so its value may vary.
  83989. * Default value is 0.1
  83990. */
  83991. intersectionThreshold: number;
  83992. private _colorShader;
  83993. private color4;
  83994. /**
  83995. * Creates a new LinesMesh
  83996. * @param name defines the name
  83997. * @param scene defines the hosting scene
  83998. * @param parent defines the parent mesh if any
  83999. * @param source defines the optional source LinesMesh used to clone data from
  84000. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84001. * When false, achieved by calling a clone(), also passing False.
  84002. * This will make creation of children, recursive.
  84003. * @param useVertexColor defines if this LinesMesh supports vertex color
  84004. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84005. */
  84006. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84007. /**
  84008. * If vertex color should be applied to the mesh
  84009. */
  84010. useVertexColor?: boolean | undefined,
  84011. /**
  84012. * If vertex alpha should be applied to the mesh
  84013. */
  84014. useVertexAlpha?: boolean | undefined);
  84015. private _addClipPlaneDefine;
  84016. private _removeClipPlaneDefine;
  84017. isReady(): boolean;
  84018. /**
  84019. * Returns the string "LineMesh"
  84020. */
  84021. getClassName(): string;
  84022. /**
  84023. * @hidden
  84024. */
  84025. /**
  84026. * @hidden
  84027. */
  84028. material: Material;
  84029. /**
  84030. * @hidden
  84031. */
  84032. readonly checkCollisions: boolean;
  84033. /** @hidden */
  84034. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84035. /** @hidden */
  84036. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84037. /**
  84038. * Disposes of the line mesh
  84039. * @param doNotRecurse If children should be disposed
  84040. */
  84041. dispose(doNotRecurse?: boolean): void;
  84042. /**
  84043. * Returns a new LineMesh object cloned from the current one.
  84044. */
  84045. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84046. /**
  84047. * Creates a new InstancedLinesMesh object from the mesh model.
  84048. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84049. * @param name defines the name of the new instance
  84050. * @returns a new InstancedLinesMesh
  84051. */
  84052. createInstance(name: string): InstancedLinesMesh;
  84053. }
  84054. /**
  84055. * Creates an instance based on a source LinesMesh
  84056. */
  84057. export class InstancedLinesMesh extends InstancedMesh {
  84058. /**
  84059. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84060. * This margin is expressed in world space coordinates, so its value may vary.
  84061. * Initilized with the intersectionThreshold value of the source LinesMesh
  84062. */
  84063. intersectionThreshold: number;
  84064. constructor(name: string, source: LinesMesh);
  84065. /**
  84066. * Returns the string "InstancedLinesMesh".
  84067. */
  84068. getClassName(): string;
  84069. }
  84070. }
  84071. declare module BABYLON {
  84072. /** @hidden */
  84073. export var linePixelShader: {
  84074. name: string;
  84075. shader: string;
  84076. };
  84077. }
  84078. declare module BABYLON {
  84079. /** @hidden */
  84080. export var lineVertexShader: {
  84081. name: string;
  84082. shader: string;
  84083. };
  84084. }
  84085. declare module BABYLON {
  84086. interface AbstractMesh {
  84087. /**
  84088. * Gets the edgesRenderer associated with the mesh
  84089. */
  84090. edgesRenderer: Nullable<EdgesRenderer>;
  84091. }
  84092. interface LinesMesh {
  84093. /**
  84094. * Enables the edge rendering mode on the mesh.
  84095. * This mode makes the mesh edges visible
  84096. * @param epsilon defines the maximal distance between two angles to detect a face
  84097. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84098. * @returns the currentAbstractMesh
  84099. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84100. */
  84101. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84102. }
  84103. interface InstancedLinesMesh {
  84104. /**
  84105. * Enables the edge rendering mode on the mesh.
  84106. * This mode makes the mesh edges visible
  84107. * @param epsilon defines the maximal distance between two angles to detect a face
  84108. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84109. * @returns the current InstancedLinesMesh
  84110. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84111. */
  84112. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84113. }
  84114. /**
  84115. * Defines the minimum contract an Edges renderer should follow.
  84116. */
  84117. export interface IEdgesRenderer extends IDisposable {
  84118. /**
  84119. * Gets or sets a boolean indicating if the edgesRenderer is active
  84120. */
  84121. isEnabled: boolean;
  84122. /**
  84123. * Renders the edges of the attached mesh,
  84124. */
  84125. render(): void;
  84126. /**
  84127. * Checks wether or not the edges renderer is ready to render.
  84128. * @return true if ready, otherwise false.
  84129. */
  84130. isReady(): boolean;
  84131. }
  84132. /**
  84133. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84134. */
  84135. export class EdgesRenderer implements IEdgesRenderer {
  84136. /**
  84137. * Define the size of the edges with an orthographic camera
  84138. */
  84139. edgesWidthScalerForOrthographic: number;
  84140. /**
  84141. * Define the size of the edges with a perspective camera
  84142. */
  84143. edgesWidthScalerForPerspective: number;
  84144. protected _source: AbstractMesh;
  84145. protected _linesPositions: number[];
  84146. protected _linesNormals: number[];
  84147. protected _linesIndices: number[];
  84148. protected _epsilon: number;
  84149. protected _indicesCount: number;
  84150. protected _lineShader: ShaderMaterial;
  84151. protected _ib: DataBuffer;
  84152. protected _buffers: {
  84153. [key: string]: Nullable<VertexBuffer>;
  84154. };
  84155. protected _checkVerticesInsteadOfIndices: boolean;
  84156. private _meshRebuildObserver;
  84157. private _meshDisposeObserver;
  84158. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84159. isEnabled: boolean;
  84160. /**
  84161. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84162. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84163. * @param source Mesh used to create edges
  84164. * @param epsilon sum of angles in adjacency to check for edge
  84165. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84166. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84167. */
  84168. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84169. protected _prepareRessources(): void;
  84170. /** @hidden */
  84171. _rebuild(): void;
  84172. /**
  84173. * Releases the required resources for the edges renderer
  84174. */
  84175. dispose(): void;
  84176. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84177. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84178. /**
  84179. * Checks if the pair of p0 and p1 is en edge
  84180. * @param faceIndex
  84181. * @param edge
  84182. * @param faceNormals
  84183. * @param p0
  84184. * @param p1
  84185. * @private
  84186. */
  84187. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84188. /**
  84189. * push line into the position, normal and index buffer
  84190. * @protected
  84191. */
  84192. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84193. /**
  84194. * Generates lines edges from adjacencjes
  84195. * @private
  84196. */
  84197. _generateEdgesLines(): void;
  84198. /**
  84199. * Checks wether or not the edges renderer is ready to render.
  84200. * @return true if ready, otherwise false.
  84201. */
  84202. isReady(): boolean;
  84203. /**
  84204. * Renders the edges of the attached mesh,
  84205. */
  84206. render(): void;
  84207. }
  84208. /**
  84209. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84210. */
  84211. export class LineEdgesRenderer extends EdgesRenderer {
  84212. /**
  84213. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84214. * @param source LineMesh used to generate edges
  84215. * @param epsilon not important (specified angle for edge detection)
  84216. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84217. */
  84218. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84219. /**
  84220. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84221. */
  84222. _generateEdgesLines(): void;
  84223. }
  84224. }
  84225. declare module BABYLON {
  84226. /**
  84227. * This represents the object necessary to create a rendering group.
  84228. * This is exclusively used and created by the rendering manager.
  84229. * To modify the behavior, you use the available helpers in your scene or meshes.
  84230. * @hidden
  84231. */
  84232. export class RenderingGroup {
  84233. index: number;
  84234. private static _zeroVector;
  84235. private _scene;
  84236. private _opaqueSubMeshes;
  84237. private _transparentSubMeshes;
  84238. private _alphaTestSubMeshes;
  84239. private _depthOnlySubMeshes;
  84240. private _particleSystems;
  84241. private _spriteManagers;
  84242. private _opaqueSortCompareFn;
  84243. private _alphaTestSortCompareFn;
  84244. private _transparentSortCompareFn;
  84245. private _renderOpaque;
  84246. private _renderAlphaTest;
  84247. private _renderTransparent;
  84248. /** @hidden */
  84249. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84250. onBeforeTransparentRendering: () => void;
  84251. /**
  84252. * Set the opaque sort comparison function.
  84253. * If null the sub meshes will be render in the order they were created
  84254. */
  84255. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84256. /**
  84257. * Set the alpha test sort comparison function.
  84258. * If null the sub meshes will be render in the order they were created
  84259. */
  84260. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84261. /**
  84262. * Set the transparent sort comparison function.
  84263. * If null the sub meshes will be render in the order they were created
  84264. */
  84265. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84266. /**
  84267. * Creates a new rendering group.
  84268. * @param index The rendering group index
  84269. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84270. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84271. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84272. */
  84273. 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>);
  84274. /**
  84275. * Render all the sub meshes contained in the group.
  84276. * @param customRenderFunction Used to override the default render behaviour of the group.
  84277. * @returns true if rendered some submeshes.
  84278. */
  84279. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84280. /**
  84281. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84282. * @param subMeshes The submeshes to render
  84283. */
  84284. private renderOpaqueSorted;
  84285. /**
  84286. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84287. * @param subMeshes The submeshes to render
  84288. */
  84289. private renderAlphaTestSorted;
  84290. /**
  84291. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84292. * @param subMeshes The submeshes to render
  84293. */
  84294. private renderTransparentSorted;
  84295. /**
  84296. * Renders the submeshes in a specified order.
  84297. * @param subMeshes The submeshes to sort before render
  84298. * @param sortCompareFn The comparison function use to sort
  84299. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84300. * @param transparent Specifies to activate blending if true
  84301. */
  84302. private static renderSorted;
  84303. /**
  84304. * Renders the submeshes in the order they were dispatched (no sort applied).
  84305. * @param subMeshes The submeshes to render
  84306. */
  84307. private static renderUnsorted;
  84308. /**
  84309. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84310. * are rendered back to front if in the same alpha index.
  84311. *
  84312. * @param a The first submesh
  84313. * @param b The second submesh
  84314. * @returns The result of the comparison
  84315. */
  84316. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84317. /**
  84318. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84319. * are rendered back to front.
  84320. *
  84321. * @param a The first submesh
  84322. * @param b The second submesh
  84323. * @returns The result of the comparison
  84324. */
  84325. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84326. /**
  84327. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84328. * are rendered front to back (prevent overdraw).
  84329. *
  84330. * @param a The first submesh
  84331. * @param b The second submesh
  84332. * @returns The result of the comparison
  84333. */
  84334. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84335. /**
  84336. * Resets the different lists of submeshes to prepare a new frame.
  84337. */
  84338. prepare(): void;
  84339. dispose(): void;
  84340. /**
  84341. * Inserts the submesh in its correct queue depending on its material.
  84342. * @param subMesh The submesh to dispatch
  84343. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84344. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84345. */
  84346. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84347. dispatchSprites(spriteManager: ISpriteManager): void;
  84348. dispatchParticles(particleSystem: IParticleSystem): void;
  84349. private _renderParticles;
  84350. private _renderSprites;
  84351. }
  84352. }
  84353. declare module BABYLON {
  84354. /**
  84355. * Interface describing the different options available in the rendering manager
  84356. * regarding Auto Clear between groups.
  84357. */
  84358. export interface IRenderingManagerAutoClearSetup {
  84359. /**
  84360. * Defines whether or not autoclear is enable.
  84361. */
  84362. autoClear: boolean;
  84363. /**
  84364. * Defines whether or not to autoclear the depth buffer.
  84365. */
  84366. depth: boolean;
  84367. /**
  84368. * Defines whether or not to autoclear the stencil buffer.
  84369. */
  84370. stencil: boolean;
  84371. }
  84372. /**
  84373. * This class is used by the onRenderingGroupObservable
  84374. */
  84375. export class RenderingGroupInfo {
  84376. /**
  84377. * The Scene that being rendered
  84378. */
  84379. scene: Scene;
  84380. /**
  84381. * The camera currently used for the rendering pass
  84382. */
  84383. camera: Nullable<Camera>;
  84384. /**
  84385. * The ID of the renderingGroup being processed
  84386. */
  84387. renderingGroupId: number;
  84388. }
  84389. /**
  84390. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84391. * It is enable to manage the different groups as well as the different necessary sort functions.
  84392. * This should not be used directly aside of the few static configurations
  84393. */
  84394. export class RenderingManager {
  84395. /**
  84396. * The max id used for rendering groups (not included)
  84397. */
  84398. static MAX_RENDERINGGROUPS: number;
  84399. /**
  84400. * The min id used for rendering groups (included)
  84401. */
  84402. static MIN_RENDERINGGROUPS: number;
  84403. /**
  84404. * Used to globally prevent autoclearing scenes.
  84405. */
  84406. static AUTOCLEAR: boolean;
  84407. /**
  84408. * @hidden
  84409. */
  84410. _useSceneAutoClearSetup: boolean;
  84411. private _scene;
  84412. private _renderingGroups;
  84413. private _depthStencilBufferAlreadyCleaned;
  84414. private _autoClearDepthStencil;
  84415. private _customOpaqueSortCompareFn;
  84416. private _customAlphaTestSortCompareFn;
  84417. private _customTransparentSortCompareFn;
  84418. private _renderingGroupInfo;
  84419. /**
  84420. * Instantiates a new rendering group for a particular scene
  84421. * @param scene Defines the scene the groups belongs to
  84422. */
  84423. constructor(scene: Scene);
  84424. private _clearDepthStencilBuffer;
  84425. /**
  84426. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84427. * @hidden
  84428. */
  84429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84430. /**
  84431. * Resets the different information of the group to prepare a new frame
  84432. * @hidden
  84433. */
  84434. reset(): void;
  84435. /**
  84436. * Dispose and release the group and its associated resources.
  84437. * @hidden
  84438. */
  84439. dispose(): void;
  84440. /**
  84441. * Clear the info related to rendering groups preventing retention points during dispose.
  84442. */
  84443. freeRenderingGroups(): void;
  84444. private _prepareRenderingGroup;
  84445. /**
  84446. * Add a sprite manager to the rendering manager in order to render it this frame.
  84447. * @param spriteManager Define the sprite manager to render
  84448. */
  84449. dispatchSprites(spriteManager: ISpriteManager): void;
  84450. /**
  84451. * Add a particle system to the rendering manager in order to render it this frame.
  84452. * @param particleSystem Define the particle system to render
  84453. */
  84454. dispatchParticles(particleSystem: IParticleSystem): void;
  84455. /**
  84456. * Add a submesh to the manager in order to render it this frame
  84457. * @param subMesh The submesh to dispatch
  84458. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84459. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84460. */
  84461. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84462. /**
  84463. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84464. * This allowed control for front to back rendering or reversly depending of the special needs.
  84465. *
  84466. * @param renderingGroupId The rendering group id corresponding to its index
  84467. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84468. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84469. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84470. */
  84471. 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;
  84472. /**
  84473. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84474. *
  84475. * @param renderingGroupId The rendering group id corresponding to its index
  84476. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84477. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84478. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84479. */
  84480. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84481. /**
  84482. * Gets the current auto clear configuration for one rendering group of the rendering
  84483. * manager.
  84484. * @param index the rendering group index to get the information for
  84485. * @returns The auto clear setup for the requested rendering group
  84486. */
  84487. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84488. }
  84489. }
  84490. declare module BABYLON {
  84491. /**
  84492. * This Helps creating a texture that will be created from a camera in your scene.
  84493. * It is basically a dynamic texture that could be used to create special effects for instance.
  84494. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84495. */
  84496. export class RenderTargetTexture extends Texture {
  84497. isCube: boolean;
  84498. /**
  84499. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84500. */
  84501. static readonly REFRESHRATE_RENDER_ONCE: number;
  84502. /**
  84503. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84504. */
  84505. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84506. /**
  84507. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84508. * the central point of your effect and can save a lot of performances.
  84509. */
  84510. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84511. /**
  84512. * Use this predicate to dynamically define the list of mesh you want to render.
  84513. * If set, the renderList property will be overwritten.
  84514. */
  84515. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84516. private _renderList;
  84517. /**
  84518. * Use this list to define the list of mesh you want to render.
  84519. */
  84520. renderList: Nullable<Array<AbstractMesh>>;
  84521. private _hookArray;
  84522. /**
  84523. * Define if particles should be rendered in your texture.
  84524. */
  84525. renderParticles: boolean;
  84526. /**
  84527. * Define if sprites should be rendered in your texture.
  84528. */
  84529. renderSprites: boolean;
  84530. /**
  84531. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84532. */
  84533. coordinatesMode: number;
  84534. /**
  84535. * Define the camera used to render the texture.
  84536. */
  84537. activeCamera: Nullable<Camera>;
  84538. /**
  84539. * Override the render function of the texture with your own one.
  84540. */
  84541. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84542. /**
  84543. * Define if camera post processes should be use while rendering the texture.
  84544. */
  84545. useCameraPostProcesses: boolean;
  84546. /**
  84547. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84548. */
  84549. ignoreCameraViewport: boolean;
  84550. private _postProcessManager;
  84551. private _postProcesses;
  84552. private _resizeObserver;
  84553. /**
  84554. * An event triggered when the texture is unbind.
  84555. */
  84556. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84557. /**
  84558. * An event triggered when the texture is unbind.
  84559. */
  84560. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84561. private _onAfterUnbindObserver;
  84562. /**
  84563. * Set a after unbind callback in the texture.
  84564. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84565. */
  84566. onAfterUnbind: () => void;
  84567. /**
  84568. * An event triggered before rendering the texture
  84569. */
  84570. onBeforeRenderObservable: Observable<number>;
  84571. private _onBeforeRenderObserver;
  84572. /**
  84573. * Set a before render callback in the texture.
  84574. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84575. */
  84576. onBeforeRender: (faceIndex: number) => void;
  84577. /**
  84578. * An event triggered after rendering the texture
  84579. */
  84580. onAfterRenderObservable: Observable<number>;
  84581. private _onAfterRenderObserver;
  84582. /**
  84583. * Set a after render callback in the texture.
  84584. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84585. */
  84586. onAfterRender: (faceIndex: number) => void;
  84587. /**
  84588. * An event triggered after the texture clear
  84589. */
  84590. onClearObservable: Observable<Engine>;
  84591. private _onClearObserver;
  84592. /**
  84593. * Set a clear callback in the texture.
  84594. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84595. */
  84596. onClear: (Engine: Engine) => void;
  84597. /**
  84598. * An event triggered when the texture is resized.
  84599. */
  84600. onResizeObservable: Observable<RenderTargetTexture>;
  84601. /**
  84602. * Define the clear color of the Render Target if it should be different from the scene.
  84603. */
  84604. clearColor: Color4;
  84605. protected _size: number | {
  84606. width: number;
  84607. height: number;
  84608. };
  84609. protected _initialSizeParameter: number | {
  84610. width: number;
  84611. height: number;
  84612. } | {
  84613. ratio: number;
  84614. };
  84615. protected _sizeRatio: Nullable<number>;
  84616. /** @hidden */
  84617. _generateMipMaps: boolean;
  84618. protected _renderingManager: RenderingManager;
  84619. /** @hidden */
  84620. _waitingRenderList: string[];
  84621. protected _doNotChangeAspectRatio: boolean;
  84622. protected _currentRefreshId: number;
  84623. protected _refreshRate: number;
  84624. protected _textureMatrix: Matrix;
  84625. protected _samples: number;
  84626. protected _renderTargetOptions: RenderTargetCreationOptions;
  84627. /**
  84628. * Gets render target creation options that were used.
  84629. */
  84630. readonly renderTargetOptions: RenderTargetCreationOptions;
  84631. protected _engine: Engine;
  84632. protected _onRatioRescale(): void;
  84633. /**
  84634. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84635. * It must define where the camera used to render the texture is set
  84636. */
  84637. boundingBoxPosition: Vector3;
  84638. private _boundingBoxSize;
  84639. /**
  84640. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84641. * When defined, the cubemap will switch to local mode
  84642. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84643. * @example https://www.babylonjs-playground.com/#RNASML
  84644. */
  84645. boundingBoxSize: Vector3;
  84646. /**
  84647. * In case the RTT has been created with a depth texture, get the associated
  84648. * depth texture.
  84649. * Otherwise, return null.
  84650. */
  84651. depthStencilTexture: Nullable<InternalTexture>;
  84652. /**
  84653. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84654. * or used a shadow, depth texture...
  84655. * @param name The friendly name of the texture
  84656. * @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)
  84657. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84658. * @param generateMipMaps True if mip maps need to be generated after render.
  84659. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84660. * @param type The type of the buffer in the RTT (int, half float, float...)
  84661. * @param isCube True if a cube texture needs to be created
  84662. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84663. * @param generateDepthBuffer True to generate a depth buffer
  84664. * @param generateStencilBuffer True to generate a stencil buffer
  84665. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84666. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84667. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84668. */
  84669. constructor(name: string, size: number | {
  84670. width: number;
  84671. height: number;
  84672. } | {
  84673. ratio: number;
  84674. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84675. /**
  84676. * Creates a depth stencil texture.
  84677. * This is only available in WebGL 2 or with the depth texture extension available.
  84678. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84679. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84680. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84681. */
  84682. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84683. private _processSizeParameter;
  84684. /**
  84685. * Define the number of samples to use in case of MSAA.
  84686. * It defaults to one meaning no MSAA has been enabled.
  84687. */
  84688. samples: number;
  84689. /**
  84690. * Resets the refresh counter of the texture and start bak from scratch.
  84691. * Could be useful to regenerate the texture if it is setup to render only once.
  84692. */
  84693. resetRefreshCounter(): void;
  84694. /**
  84695. * Define the refresh rate of the texture or the rendering frequency.
  84696. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84697. */
  84698. refreshRate: number;
  84699. /**
  84700. * Adds a post process to the render target rendering passes.
  84701. * @param postProcess define the post process to add
  84702. */
  84703. addPostProcess(postProcess: PostProcess): void;
  84704. /**
  84705. * Clear all the post processes attached to the render target
  84706. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84707. */
  84708. clearPostProcesses(dispose?: boolean): void;
  84709. /**
  84710. * Remove one of the post process from the list of attached post processes to the texture
  84711. * @param postProcess define the post process to remove from the list
  84712. */
  84713. removePostProcess(postProcess: PostProcess): void;
  84714. /** @hidden */
  84715. _shouldRender(): boolean;
  84716. /**
  84717. * Gets the actual render size of the texture.
  84718. * @returns the width of the render size
  84719. */
  84720. getRenderSize(): number;
  84721. /**
  84722. * Gets the actual render width of the texture.
  84723. * @returns the width of the render size
  84724. */
  84725. getRenderWidth(): number;
  84726. /**
  84727. * Gets the actual render height of the texture.
  84728. * @returns the height of the render size
  84729. */
  84730. getRenderHeight(): number;
  84731. /**
  84732. * Get if the texture can be rescaled or not.
  84733. */
  84734. readonly canRescale: boolean;
  84735. /**
  84736. * Resize the texture using a ratio.
  84737. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84738. */
  84739. scale(ratio: number): void;
  84740. /**
  84741. * Get the texture reflection matrix used to rotate/transform the reflection.
  84742. * @returns the reflection matrix
  84743. */
  84744. getReflectionTextureMatrix(): Matrix;
  84745. /**
  84746. * Resize the texture to a new desired size.
  84747. * Be carrefull as it will recreate all the data in the new texture.
  84748. * @param size Define the new size. It can be:
  84749. * - a number for squared texture,
  84750. * - an object containing { width: number, height: number }
  84751. * - or an object containing a ratio { ratio: number }
  84752. */
  84753. resize(size: number | {
  84754. width: number;
  84755. height: number;
  84756. } | {
  84757. ratio: number;
  84758. }): void;
  84759. /**
  84760. * Renders all the objects from the render list into the texture.
  84761. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84762. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84763. */
  84764. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84765. private _bestReflectionRenderTargetDimension;
  84766. /**
  84767. * @hidden
  84768. * @param faceIndex face index to bind to if this is a cubetexture
  84769. */
  84770. _bindFrameBuffer(faceIndex?: number): void;
  84771. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84772. private renderToTarget;
  84773. /**
  84774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84775. * This allowed control for front to back rendering or reversly depending of the special needs.
  84776. *
  84777. * @param renderingGroupId The rendering group id corresponding to its index
  84778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84781. */
  84782. 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;
  84783. /**
  84784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84785. *
  84786. * @param renderingGroupId The rendering group id corresponding to its index
  84787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84788. */
  84789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84790. /**
  84791. * Clones the texture.
  84792. * @returns the cloned texture
  84793. */
  84794. clone(): RenderTargetTexture;
  84795. /**
  84796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84797. * @returns The JSON representation of the texture
  84798. */
  84799. serialize(): any;
  84800. /**
  84801. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84802. */
  84803. disposeFramebufferObjects(): void;
  84804. /**
  84805. * Dispose the texture and release its associated resources.
  84806. */
  84807. dispose(): void;
  84808. /** @hidden */
  84809. _rebuild(): void;
  84810. /**
  84811. * Clear the info related to rendering groups preventing retention point in material dispose.
  84812. */
  84813. freeRenderingGroups(): void;
  84814. /**
  84815. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84816. * @returns the view count
  84817. */
  84818. getViewCount(): number;
  84819. }
  84820. }
  84821. declare module BABYLON {
  84822. /**
  84823. * Base class for the main features of a material in Babylon.js
  84824. */
  84825. export class Material implements IAnimatable {
  84826. /**
  84827. * Returns the triangle fill mode
  84828. */
  84829. static readonly TriangleFillMode: number;
  84830. /**
  84831. * Returns the wireframe mode
  84832. */
  84833. static readonly WireFrameFillMode: number;
  84834. /**
  84835. * Returns the point fill mode
  84836. */
  84837. static readonly PointFillMode: number;
  84838. /**
  84839. * Returns the point list draw mode
  84840. */
  84841. static readonly PointListDrawMode: number;
  84842. /**
  84843. * Returns the line list draw mode
  84844. */
  84845. static readonly LineListDrawMode: number;
  84846. /**
  84847. * Returns the line loop draw mode
  84848. */
  84849. static readonly LineLoopDrawMode: number;
  84850. /**
  84851. * Returns the line strip draw mode
  84852. */
  84853. static readonly LineStripDrawMode: number;
  84854. /**
  84855. * Returns the triangle strip draw mode
  84856. */
  84857. static readonly TriangleStripDrawMode: number;
  84858. /**
  84859. * Returns the triangle fan draw mode
  84860. */
  84861. static readonly TriangleFanDrawMode: number;
  84862. /**
  84863. * Stores the clock-wise side orientation
  84864. */
  84865. static readonly ClockWiseSideOrientation: number;
  84866. /**
  84867. * Stores the counter clock-wise side orientation
  84868. */
  84869. static readonly CounterClockWiseSideOrientation: number;
  84870. /**
  84871. * The dirty texture flag value
  84872. */
  84873. static readonly TextureDirtyFlag: number;
  84874. /**
  84875. * The dirty light flag value
  84876. */
  84877. static readonly LightDirtyFlag: number;
  84878. /**
  84879. * The dirty fresnel flag value
  84880. */
  84881. static readonly FresnelDirtyFlag: number;
  84882. /**
  84883. * The dirty attribute flag value
  84884. */
  84885. static readonly AttributesDirtyFlag: number;
  84886. /**
  84887. * The dirty misc flag value
  84888. */
  84889. static readonly MiscDirtyFlag: number;
  84890. /**
  84891. * The all dirty flag value
  84892. */
  84893. static readonly AllDirtyFlag: number;
  84894. /**
  84895. * The ID of the material
  84896. */
  84897. id: string;
  84898. /**
  84899. * Gets or sets the unique id of the material
  84900. */
  84901. uniqueId: number;
  84902. /**
  84903. * The name of the material
  84904. */
  84905. name: string;
  84906. /**
  84907. * Gets or sets user defined metadata
  84908. */
  84909. metadata: any;
  84910. /**
  84911. * For internal use only. Please do not use.
  84912. */
  84913. reservedDataStore: any;
  84914. /**
  84915. * Specifies if the ready state should be checked on each call
  84916. */
  84917. checkReadyOnEveryCall: boolean;
  84918. /**
  84919. * Specifies if the ready state should be checked once
  84920. */
  84921. checkReadyOnlyOnce: boolean;
  84922. /**
  84923. * The state of the material
  84924. */
  84925. state: string;
  84926. /**
  84927. * The alpha value of the material
  84928. */
  84929. protected _alpha: number;
  84930. /**
  84931. * List of inspectable custom properties (used by the Inspector)
  84932. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84933. */
  84934. inspectableCustomProperties: IInspectable[];
  84935. /**
  84936. * Sets the alpha value of the material
  84937. */
  84938. /**
  84939. * Gets the alpha value of the material
  84940. */
  84941. alpha: number;
  84942. /**
  84943. * Specifies if back face culling is enabled
  84944. */
  84945. protected _backFaceCulling: boolean;
  84946. /**
  84947. * Sets the back-face culling state
  84948. */
  84949. /**
  84950. * Gets the back-face culling state
  84951. */
  84952. backFaceCulling: boolean;
  84953. /**
  84954. * Stores the value for side orientation
  84955. */
  84956. sideOrientation: number;
  84957. /**
  84958. * Callback triggered when the material is compiled
  84959. */
  84960. onCompiled: Nullable<(effect: Effect) => void>;
  84961. /**
  84962. * Callback triggered when an error occurs
  84963. */
  84964. onError: Nullable<(effect: Effect, errors: string) => void>;
  84965. /**
  84966. * Callback triggered to get the render target textures
  84967. */
  84968. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84969. /**
  84970. * Gets a boolean indicating that current material needs to register RTT
  84971. */
  84972. readonly hasRenderTargetTextures: boolean;
  84973. /**
  84974. * Specifies if the material should be serialized
  84975. */
  84976. doNotSerialize: boolean;
  84977. /**
  84978. * @hidden
  84979. */
  84980. _storeEffectOnSubMeshes: boolean;
  84981. /**
  84982. * Stores the animations for the material
  84983. */
  84984. animations: Nullable<Array<Animation>>;
  84985. /**
  84986. * An event triggered when the material is disposed
  84987. */
  84988. onDisposeObservable: Observable<Material>;
  84989. /**
  84990. * An observer which watches for dispose events
  84991. */
  84992. private _onDisposeObserver;
  84993. private _onUnBindObservable;
  84994. /**
  84995. * Called during a dispose event
  84996. */
  84997. onDispose: () => void;
  84998. private _onBindObservable;
  84999. /**
  85000. * An event triggered when the material is bound
  85001. */
  85002. readonly onBindObservable: Observable<AbstractMesh>;
  85003. /**
  85004. * An observer which watches for bind events
  85005. */
  85006. private _onBindObserver;
  85007. /**
  85008. * Called during a bind event
  85009. */
  85010. onBind: (Mesh: AbstractMesh) => void;
  85011. /**
  85012. * An event triggered when the material is unbound
  85013. */
  85014. readonly onUnBindObservable: Observable<Material>;
  85015. /**
  85016. * Stores the value of the alpha mode
  85017. */
  85018. private _alphaMode;
  85019. /**
  85020. * Sets the value of the alpha mode.
  85021. *
  85022. * | Value | Type | Description |
  85023. * | --- | --- | --- |
  85024. * | 0 | ALPHA_DISABLE | |
  85025. * | 1 | ALPHA_ADD | |
  85026. * | 2 | ALPHA_COMBINE | |
  85027. * | 3 | ALPHA_SUBTRACT | |
  85028. * | 4 | ALPHA_MULTIPLY | |
  85029. * | 5 | ALPHA_MAXIMIZED | |
  85030. * | 6 | ALPHA_ONEONE | |
  85031. * | 7 | ALPHA_PREMULTIPLIED | |
  85032. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85033. * | 9 | ALPHA_INTERPOLATE | |
  85034. * | 10 | ALPHA_SCREENMODE | |
  85035. *
  85036. */
  85037. /**
  85038. * Gets the value of the alpha mode
  85039. */
  85040. alphaMode: number;
  85041. /**
  85042. * Stores the state of the need depth pre-pass value
  85043. */
  85044. private _needDepthPrePass;
  85045. /**
  85046. * Sets the need depth pre-pass value
  85047. */
  85048. /**
  85049. * Gets the depth pre-pass value
  85050. */
  85051. needDepthPrePass: boolean;
  85052. /**
  85053. * Specifies if depth writing should be disabled
  85054. */
  85055. disableDepthWrite: boolean;
  85056. /**
  85057. * Specifies if depth writing should be forced
  85058. */
  85059. forceDepthWrite: boolean;
  85060. /**
  85061. * Specifies if there should be a separate pass for culling
  85062. */
  85063. separateCullingPass: boolean;
  85064. /**
  85065. * Stores the state specifing if fog should be enabled
  85066. */
  85067. private _fogEnabled;
  85068. /**
  85069. * Sets the state for enabling fog
  85070. */
  85071. /**
  85072. * Gets the value of the fog enabled state
  85073. */
  85074. fogEnabled: boolean;
  85075. /**
  85076. * Stores the size of points
  85077. */
  85078. pointSize: number;
  85079. /**
  85080. * Stores the z offset value
  85081. */
  85082. zOffset: number;
  85083. /**
  85084. * Gets a value specifying if wireframe mode is enabled
  85085. */
  85086. /**
  85087. * Sets the state of wireframe mode
  85088. */
  85089. wireframe: boolean;
  85090. /**
  85091. * Gets the value specifying if point clouds are enabled
  85092. */
  85093. /**
  85094. * Sets the state of point cloud mode
  85095. */
  85096. pointsCloud: boolean;
  85097. /**
  85098. * Gets the material fill mode
  85099. */
  85100. /**
  85101. * Sets the material fill mode
  85102. */
  85103. fillMode: number;
  85104. /**
  85105. * @hidden
  85106. * Stores the effects for the material
  85107. */
  85108. _effect: Nullable<Effect>;
  85109. /**
  85110. * @hidden
  85111. * Specifies if the material was previously ready
  85112. */
  85113. _wasPreviouslyReady: boolean;
  85114. /**
  85115. * Specifies if uniform buffers should be used
  85116. */
  85117. private _useUBO;
  85118. /**
  85119. * Stores a reference to the scene
  85120. */
  85121. private _scene;
  85122. /**
  85123. * Stores the fill mode state
  85124. */
  85125. private _fillMode;
  85126. /**
  85127. * Specifies if the depth write state should be cached
  85128. */
  85129. private _cachedDepthWriteState;
  85130. /**
  85131. * Stores the uniform buffer
  85132. */
  85133. protected _uniformBuffer: UniformBuffer;
  85134. /** @hidden */
  85135. _indexInSceneMaterialArray: number;
  85136. /** @hidden */
  85137. meshMap: Nullable<{
  85138. [id: string]: AbstractMesh | undefined;
  85139. }>;
  85140. /**
  85141. * Creates a material instance
  85142. * @param name defines the name of the material
  85143. * @param scene defines the scene to reference
  85144. * @param doNotAdd specifies if the material should be added to the scene
  85145. */
  85146. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85147. /**
  85148. * Returns a string representation of the current material
  85149. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85150. * @returns a string with material information
  85151. */
  85152. toString(fullDetails?: boolean): string;
  85153. /**
  85154. * Gets the class name of the material
  85155. * @returns a string with the class name of the material
  85156. */
  85157. getClassName(): string;
  85158. /**
  85159. * Specifies if updates for the material been locked
  85160. */
  85161. readonly isFrozen: boolean;
  85162. /**
  85163. * Locks updates for the material
  85164. */
  85165. freeze(): void;
  85166. /**
  85167. * Unlocks updates for the material
  85168. */
  85169. unfreeze(): void;
  85170. /**
  85171. * Specifies if the material is ready to be used
  85172. * @param mesh defines the mesh to check
  85173. * @param useInstances specifies if instances should be used
  85174. * @returns a boolean indicating if the material is ready to be used
  85175. */
  85176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85177. /**
  85178. * Specifies that the submesh is ready to be used
  85179. * @param mesh defines the mesh to check
  85180. * @param subMesh defines which submesh to check
  85181. * @param useInstances specifies that instances should be used
  85182. * @returns a boolean indicating that the submesh is ready or not
  85183. */
  85184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85185. /**
  85186. * Returns the material effect
  85187. * @returns the effect associated with the material
  85188. */
  85189. getEffect(): Nullable<Effect>;
  85190. /**
  85191. * Returns the current scene
  85192. * @returns a Scene
  85193. */
  85194. getScene(): Scene;
  85195. /**
  85196. * Specifies if the material will require alpha blending
  85197. * @returns a boolean specifying if alpha blending is needed
  85198. */
  85199. needAlphaBlending(): boolean;
  85200. /**
  85201. * Specifies if the mesh will require alpha blending
  85202. * @param mesh defines the mesh to check
  85203. * @returns a boolean specifying if alpha blending is needed for the mesh
  85204. */
  85205. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85206. /**
  85207. * Specifies if this material should be rendered in alpha test mode
  85208. * @returns a boolean specifying if an alpha test is needed.
  85209. */
  85210. needAlphaTesting(): boolean;
  85211. /**
  85212. * Gets the texture used for the alpha test
  85213. * @returns the texture to use for alpha testing
  85214. */
  85215. getAlphaTestTexture(): Nullable<BaseTexture>;
  85216. /**
  85217. * Marks the material to indicate that it needs to be re-calculated
  85218. */
  85219. markDirty(): void;
  85220. /** @hidden */
  85221. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85222. /**
  85223. * Binds the material to the mesh
  85224. * @param world defines the world transformation matrix
  85225. * @param mesh defines the mesh to bind the material to
  85226. */
  85227. bind(world: Matrix, mesh?: Mesh): void;
  85228. /**
  85229. * Binds the submesh to the material
  85230. * @param world defines the world transformation matrix
  85231. * @param mesh defines the mesh containing the submesh
  85232. * @param subMesh defines the submesh to bind the material to
  85233. */
  85234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85235. /**
  85236. * Binds the world matrix to the material
  85237. * @param world defines the world transformation matrix
  85238. */
  85239. bindOnlyWorldMatrix(world: Matrix): void;
  85240. /**
  85241. * Binds the scene's uniform buffer to the effect.
  85242. * @param effect defines the effect to bind to the scene uniform buffer
  85243. * @param sceneUbo defines the uniform buffer storing scene data
  85244. */
  85245. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85246. /**
  85247. * Binds the view matrix to the effect
  85248. * @param effect defines the effect to bind the view matrix to
  85249. */
  85250. bindView(effect: Effect): void;
  85251. /**
  85252. * Binds the view projection matrix to the effect
  85253. * @param effect defines the effect to bind the view projection matrix to
  85254. */
  85255. bindViewProjection(effect: Effect): void;
  85256. /**
  85257. * Specifies if material alpha testing should be turned on for the mesh
  85258. * @param mesh defines the mesh to check
  85259. */
  85260. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85261. /**
  85262. * Processes to execute after binding the material to a mesh
  85263. * @param mesh defines the rendered mesh
  85264. */
  85265. protected _afterBind(mesh?: Mesh): void;
  85266. /**
  85267. * Unbinds the material from the mesh
  85268. */
  85269. unbind(): void;
  85270. /**
  85271. * Gets the active textures from the material
  85272. * @returns an array of textures
  85273. */
  85274. getActiveTextures(): BaseTexture[];
  85275. /**
  85276. * Specifies if the material uses a texture
  85277. * @param texture defines the texture to check against the material
  85278. * @returns a boolean specifying if the material uses the texture
  85279. */
  85280. hasTexture(texture: BaseTexture): boolean;
  85281. /**
  85282. * Makes a duplicate of the material, and gives it a new name
  85283. * @param name defines the new name for the duplicated material
  85284. * @returns the cloned material
  85285. */
  85286. clone(name: string): Nullable<Material>;
  85287. /**
  85288. * Gets the meshes bound to the material
  85289. * @returns an array of meshes bound to the material
  85290. */
  85291. getBindedMeshes(): AbstractMesh[];
  85292. /**
  85293. * Force shader compilation
  85294. * @param mesh defines the mesh associated with this material
  85295. * @param onCompiled defines a function to execute once the material is compiled
  85296. * @param options defines the options to configure the compilation
  85297. */
  85298. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85299. clipPlane: boolean;
  85300. }>): void;
  85301. /**
  85302. * Force shader compilation
  85303. * @param mesh defines the mesh that will use this material
  85304. * @param options defines additional options for compiling the shaders
  85305. * @returns a promise that resolves when the compilation completes
  85306. */
  85307. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85308. clipPlane: boolean;
  85309. }>): Promise<void>;
  85310. private static readonly _AllDirtyCallBack;
  85311. private static readonly _ImageProcessingDirtyCallBack;
  85312. private static readonly _TextureDirtyCallBack;
  85313. private static readonly _FresnelDirtyCallBack;
  85314. private static readonly _MiscDirtyCallBack;
  85315. private static readonly _LightsDirtyCallBack;
  85316. private static readonly _AttributeDirtyCallBack;
  85317. private static _FresnelAndMiscDirtyCallBack;
  85318. private static _TextureAndMiscDirtyCallBack;
  85319. private static readonly _DirtyCallbackArray;
  85320. private static readonly _RunDirtyCallBacks;
  85321. /**
  85322. * Marks a define in the material to indicate that it needs to be re-computed
  85323. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85324. */
  85325. markAsDirty(flag: number): void;
  85326. /**
  85327. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85328. * @param func defines a function which checks material defines against the submeshes
  85329. */
  85330. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85331. /**
  85332. * Indicates that we need to re-calculated for all submeshes
  85333. */
  85334. protected _markAllSubMeshesAsAllDirty(): void;
  85335. /**
  85336. * Indicates that image processing needs to be re-calculated for all submeshes
  85337. */
  85338. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85339. /**
  85340. * Indicates that textures need to be re-calculated for all submeshes
  85341. */
  85342. protected _markAllSubMeshesAsTexturesDirty(): void;
  85343. /**
  85344. * Indicates that fresnel needs to be re-calculated for all submeshes
  85345. */
  85346. protected _markAllSubMeshesAsFresnelDirty(): void;
  85347. /**
  85348. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85349. */
  85350. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85351. /**
  85352. * Indicates that lights need to be re-calculated for all submeshes
  85353. */
  85354. protected _markAllSubMeshesAsLightsDirty(): void;
  85355. /**
  85356. * Indicates that attributes need to be re-calculated for all submeshes
  85357. */
  85358. protected _markAllSubMeshesAsAttributesDirty(): void;
  85359. /**
  85360. * Indicates that misc needs to be re-calculated for all submeshes
  85361. */
  85362. protected _markAllSubMeshesAsMiscDirty(): void;
  85363. /**
  85364. * Indicates that textures and misc need to be re-calculated for all submeshes
  85365. */
  85366. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85367. /**
  85368. * Disposes the material
  85369. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85370. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85371. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85372. */
  85373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85374. /** @hidden */
  85375. private releaseVertexArrayObject;
  85376. /**
  85377. * Serializes this material
  85378. * @returns the serialized material object
  85379. */
  85380. serialize(): any;
  85381. /**
  85382. * Creates a material from parsed material data
  85383. * @param parsedMaterial defines parsed material data
  85384. * @param scene defines the hosting scene
  85385. * @param rootUrl defines the root URL to use to load textures
  85386. * @returns a new material
  85387. */
  85388. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85389. }
  85390. }
  85391. declare module BABYLON {
  85392. /**
  85393. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85394. * separate meshes. This can be use to improve performances.
  85395. * @see http://doc.babylonjs.com/how_to/multi_materials
  85396. */
  85397. export class MultiMaterial extends Material {
  85398. private _subMaterials;
  85399. /**
  85400. * Gets or Sets the list of Materials used within the multi material.
  85401. * They need to be ordered according to the submeshes order in the associated mesh
  85402. */
  85403. subMaterials: Nullable<Material>[];
  85404. /**
  85405. * Function used to align with Node.getChildren()
  85406. * @returns the list of Materials used within the multi material
  85407. */
  85408. getChildren(): Nullable<Material>[];
  85409. /**
  85410. * Instantiates a new Multi Material
  85411. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85412. * separate meshes. This can be use to improve performances.
  85413. * @see http://doc.babylonjs.com/how_to/multi_materials
  85414. * @param name Define the name in the scene
  85415. * @param scene Define the scene the material belongs to
  85416. */
  85417. constructor(name: string, scene: Scene);
  85418. private _hookArray;
  85419. /**
  85420. * Get one of the submaterial by its index in the submaterials array
  85421. * @param index The index to look the sub material at
  85422. * @returns The Material if the index has been defined
  85423. */
  85424. getSubMaterial(index: number): Nullable<Material>;
  85425. /**
  85426. * Get the list of active textures for the whole sub materials list.
  85427. * @returns All the textures that will be used during the rendering
  85428. */
  85429. getActiveTextures(): BaseTexture[];
  85430. /**
  85431. * Gets the current class name of the material e.g. "MultiMaterial"
  85432. * Mainly use in serialization.
  85433. * @returns the class name
  85434. */
  85435. getClassName(): string;
  85436. /**
  85437. * Checks if the material is ready to render the requested sub mesh
  85438. * @param mesh Define the mesh the submesh belongs to
  85439. * @param subMesh Define the sub mesh to look readyness for
  85440. * @param useInstances Define whether or not the material is used with instances
  85441. * @returns true if ready, otherwise false
  85442. */
  85443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85444. /**
  85445. * Clones the current material and its related sub materials
  85446. * @param name Define the name of the newly cloned material
  85447. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85448. * @returns the cloned material
  85449. */
  85450. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85451. /**
  85452. * Serializes the materials into a JSON representation.
  85453. * @returns the JSON representation
  85454. */
  85455. serialize(): any;
  85456. /**
  85457. * Dispose the material and release its associated resources
  85458. * @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)
  85459. * @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)
  85460. * @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)
  85461. */
  85462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85463. /**
  85464. * Creates a MultiMaterial from parsed MultiMaterial data.
  85465. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85466. * @param scene defines the hosting scene
  85467. * @returns a new MultiMaterial
  85468. */
  85469. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85470. }
  85471. }
  85472. declare module BABYLON {
  85473. /**
  85474. * Base class for submeshes
  85475. */
  85476. export class BaseSubMesh {
  85477. /** @hidden */
  85478. _materialDefines: Nullable<MaterialDefines>;
  85479. /** @hidden */
  85480. _materialEffect: Nullable<Effect>;
  85481. /**
  85482. * Gets associated effect
  85483. */
  85484. readonly effect: Nullable<Effect>;
  85485. /**
  85486. * Sets associated effect (effect used to render this submesh)
  85487. * @param effect defines the effect to associate with
  85488. * @param defines defines the set of defines used to compile this effect
  85489. */
  85490. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85491. }
  85492. /**
  85493. * Defines a subdivision inside a mesh
  85494. */
  85495. export class SubMesh extends BaseSubMesh implements ICullable {
  85496. /** the material index to use */
  85497. materialIndex: number;
  85498. /** vertex index start */
  85499. verticesStart: number;
  85500. /** vertices count */
  85501. verticesCount: number;
  85502. /** index start */
  85503. indexStart: number;
  85504. /** indices count */
  85505. indexCount: number;
  85506. /** @hidden */
  85507. _linesIndexCount: number;
  85508. private _mesh;
  85509. private _renderingMesh;
  85510. private _boundingInfo;
  85511. private _linesIndexBuffer;
  85512. /** @hidden */
  85513. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85514. /** @hidden */
  85515. _trianglePlanes: Plane[];
  85516. /** @hidden */
  85517. _lastColliderTransformMatrix: Nullable<Matrix>;
  85518. /** @hidden */
  85519. _renderId: number;
  85520. /** @hidden */
  85521. _alphaIndex: number;
  85522. /** @hidden */
  85523. _distanceToCamera: number;
  85524. /** @hidden */
  85525. _id: number;
  85526. private _currentMaterial;
  85527. /**
  85528. * Add a new submesh to a mesh
  85529. * @param materialIndex defines the material index to use
  85530. * @param verticesStart defines vertex index start
  85531. * @param verticesCount defines vertices count
  85532. * @param indexStart defines index start
  85533. * @param indexCount defines indices count
  85534. * @param mesh defines the parent mesh
  85535. * @param renderingMesh defines an optional rendering mesh
  85536. * @param createBoundingBox defines if bounding box should be created for this submesh
  85537. * @returns the new submesh
  85538. */
  85539. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85540. /**
  85541. * Creates a new submesh
  85542. * @param materialIndex defines the material index to use
  85543. * @param verticesStart defines vertex index start
  85544. * @param verticesCount defines vertices count
  85545. * @param indexStart defines index start
  85546. * @param indexCount defines indices count
  85547. * @param mesh defines the parent mesh
  85548. * @param renderingMesh defines an optional rendering mesh
  85549. * @param createBoundingBox defines if bounding box should be created for this submesh
  85550. */
  85551. constructor(
  85552. /** the material index to use */
  85553. materialIndex: number,
  85554. /** vertex index start */
  85555. verticesStart: number,
  85556. /** vertices count */
  85557. verticesCount: number,
  85558. /** index start */
  85559. indexStart: number,
  85560. /** indices count */
  85561. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85562. /**
  85563. * Returns true if this submesh covers the entire parent mesh
  85564. * @ignorenaming
  85565. */
  85566. readonly IsGlobal: boolean;
  85567. /**
  85568. * Returns the submesh BoudingInfo object
  85569. * @returns current bounding info (or mesh's one if the submesh is global)
  85570. */
  85571. getBoundingInfo(): BoundingInfo;
  85572. /**
  85573. * Sets the submesh BoundingInfo
  85574. * @param boundingInfo defines the new bounding info to use
  85575. * @returns the SubMesh
  85576. */
  85577. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85578. /**
  85579. * Returns the mesh of the current submesh
  85580. * @return the parent mesh
  85581. */
  85582. getMesh(): AbstractMesh;
  85583. /**
  85584. * Returns the rendering mesh of the submesh
  85585. * @returns the rendering mesh (could be different from parent mesh)
  85586. */
  85587. getRenderingMesh(): Mesh;
  85588. /**
  85589. * Returns the submesh material
  85590. * @returns null or the current material
  85591. */
  85592. getMaterial(): Nullable<Material>;
  85593. /**
  85594. * Sets a new updated BoundingInfo object to the submesh
  85595. * @param data defines an optional position array to use to determine the bounding info
  85596. * @returns the SubMesh
  85597. */
  85598. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85599. /** @hidden */
  85600. _checkCollision(collider: Collider): boolean;
  85601. /**
  85602. * Updates the submesh BoundingInfo
  85603. * @param world defines the world matrix to use to update the bounding info
  85604. * @returns the submesh
  85605. */
  85606. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85607. /**
  85608. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85609. * @param frustumPlanes defines the frustum planes
  85610. * @returns true if the submesh is intersecting with the frustum
  85611. */
  85612. isInFrustum(frustumPlanes: Plane[]): boolean;
  85613. /**
  85614. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85615. * @param frustumPlanes defines the frustum planes
  85616. * @returns true if the submesh is inside the frustum
  85617. */
  85618. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85619. /**
  85620. * Renders the submesh
  85621. * @param enableAlphaMode defines if alpha needs to be used
  85622. * @returns the submesh
  85623. */
  85624. render(enableAlphaMode: boolean): SubMesh;
  85625. /**
  85626. * @hidden
  85627. */
  85628. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85629. /**
  85630. * Checks if the submesh intersects with a ray
  85631. * @param ray defines the ray to test
  85632. * @returns true is the passed ray intersects the submesh bounding box
  85633. */
  85634. canIntersects(ray: Ray): boolean;
  85635. /**
  85636. * Intersects current submesh with a ray
  85637. * @param ray defines the ray to test
  85638. * @param positions defines mesh's positions array
  85639. * @param indices defines mesh's indices array
  85640. * @param fastCheck defines if only bounding info should be used
  85641. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85642. * @returns intersection info or null if no intersection
  85643. */
  85644. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85645. /** @hidden */
  85646. private _intersectLines;
  85647. /** @hidden */
  85648. private _intersectUnIndexedLines;
  85649. /** @hidden */
  85650. private _intersectTriangles;
  85651. /** @hidden */
  85652. private _intersectUnIndexedTriangles;
  85653. /** @hidden */
  85654. _rebuild(): void;
  85655. /**
  85656. * Creates a new submesh from the passed mesh
  85657. * @param newMesh defines the new hosting mesh
  85658. * @param newRenderingMesh defines an optional rendering mesh
  85659. * @returns the new submesh
  85660. */
  85661. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85662. /**
  85663. * Release associated resources
  85664. */
  85665. dispose(): void;
  85666. /**
  85667. * Gets the class name
  85668. * @returns the string "SubMesh".
  85669. */
  85670. getClassName(): string;
  85671. /**
  85672. * Creates a new submesh from indices data
  85673. * @param materialIndex the index of the main mesh material
  85674. * @param startIndex the index where to start the copy in the mesh indices array
  85675. * @param indexCount the number of indices to copy then from the startIndex
  85676. * @param mesh the main mesh to create the submesh from
  85677. * @param renderingMesh the optional rendering mesh
  85678. * @returns a new submesh
  85679. */
  85680. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85681. }
  85682. }
  85683. declare module BABYLON {
  85684. /**
  85685. * Class used to represent data loading progression
  85686. */
  85687. export class SceneLoaderFlags {
  85688. private static _ForceFullSceneLoadingForIncremental;
  85689. private static _ShowLoadingScreen;
  85690. private static _CleanBoneMatrixWeights;
  85691. private static _loggingLevel;
  85692. /**
  85693. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85694. */
  85695. static ForceFullSceneLoadingForIncremental: boolean;
  85696. /**
  85697. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85698. */
  85699. static ShowLoadingScreen: boolean;
  85700. /**
  85701. * Defines the current logging level (while loading the scene)
  85702. * @ignorenaming
  85703. */
  85704. static loggingLevel: number;
  85705. /**
  85706. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85707. */
  85708. static CleanBoneMatrixWeights: boolean;
  85709. }
  85710. }
  85711. declare module BABYLON {
  85712. /**
  85713. * Class used to store geometry data (vertex buffers + index buffer)
  85714. */
  85715. export class Geometry implements IGetSetVerticesData {
  85716. /**
  85717. * Gets or sets the ID of the geometry
  85718. */
  85719. id: string;
  85720. /**
  85721. * Gets or sets the unique ID of the geometry
  85722. */
  85723. uniqueId: number;
  85724. /**
  85725. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85726. */
  85727. delayLoadState: number;
  85728. /**
  85729. * Gets the file containing the data to load when running in delay load state
  85730. */
  85731. delayLoadingFile: Nullable<string>;
  85732. /**
  85733. * Callback called when the geometry is updated
  85734. */
  85735. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85736. private _scene;
  85737. private _engine;
  85738. private _meshes;
  85739. private _totalVertices;
  85740. /** @hidden */
  85741. _indices: IndicesArray;
  85742. /** @hidden */
  85743. _vertexBuffers: {
  85744. [key: string]: VertexBuffer;
  85745. };
  85746. private _isDisposed;
  85747. private _extend;
  85748. private _boundingBias;
  85749. /** @hidden */
  85750. _delayInfo: Array<string>;
  85751. private _indexBuffer;
  85752. private _indexBufferIsUpdatable;
  85753. /** @hidden */
  85754. _boundingInfo: Nullable<BoundingInfo>;
  85755. /** @hidden */
  85756. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85757. /** @hidden */
  85758. _softwareSkinningFrameId: number;
  85759. private _vertexArrayObjects;
  85760. private _updatable;
  85761. /** @hidden */
  85762. _positions: Nullable<Vector3[]>;
  85763. /**
  85764. * 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
  85765. */
  85766. /**
  85767. * 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
  85768. */
  85769. boundingBias: Vector2;
  85770. /**
  85771. * Static function used to attach a new empty geometry to a mesh
  85772. * @param mesh defines the mesh to attach the geometry to
  85773. * @returns the new Geometry
  85774. */
  85775. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85776. /**
  85777. * Creates a new geometry
  85778. * @param id defines the unique ID
  85779. * @param scene defines the hosting scene
  85780. * @param vertexData defines the VertexData used to get geometry data
  85781. * @param updatable defines if geometry must be updatable (false by default)
  85782. * @param mesh defines the mesh that will be associated with the geometry
  85783. */
  85784. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85785. /**
  85786. * Gets the current extend of the geometry
  85787. */
  85788. readonly extend: {
  85789. minimum: Vector3;
  85790. maximum: Vector3;
  85791. };
  85792. /**
  85793. * Gets the hosting scene
  85794. * @returns the hosting Scene
  85795. */
  85796. getScene(): Scene;
  85797. /**
  85798. * Gets the hosting engine
  85799. * @returns the hosting Engine
  85800. */
  85801. getEngine(): Engine;
  85802. /**
  85803. * Defines if the geometry is ready to use
  85804. * @returns true if the geometry is ready to be used
  85805. */
  85806. isReady(): boolean;
  85807. /**
  85808. * Gets a value indicating that the geometry should not be serialized
  85809. */
  85810. readonly doNotSerialize: boolean;
  85811. /** @hidden */
  85812. _rebuild(): void;
  85813. /**
  85814. * Affects all geometry data in one call
  85815. * @param vertexData defines the geometry data
  85816. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85817. */
  85818. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85819. /**
  85820. * Set specific vertex data
  85821. * @param kind defines the data kind (Position, normal, etc...)
  85822. * @param data defines the vertex data to use
  85823. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85824. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85825. */
  85826. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85827. /**
  85828. * Removes a specific vertex data
  85829. * @param kind defines the data kind (Position, normal, etc...)
  85830. */
  85831. removeVerticesData(kind: string): void;
  85832. /**
  85833. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85834. * @param buffer defines the vertex buffer to use
  85835. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85836. */
  85837. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85838. /**
  85839. * Update a specific vertex buffer
  85840. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85841. * It will do nothing if the buffer is not updatable
  85842. * @param kind defines the data kind (Position, normal, etc...)
  85843. * @param data defines the data to use
  85844. * @param offset defines the offset in the target buffer where to store the data
  85845. * @param useBytes set to true if the offset is in bytes
  85846. */
  85847. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85848. /**
  85849. * Update a specific vertex buffer
  85850. * This function will create a new buffer if the current one is not updatable
  85851. * @param kind defines the data kind (Position, normal, etc...)
  85852. * @param data defines the data to use
  85853. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85854. */
  85855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85856. private _updateBoundingInfo;
  85857. /** @hidden */
  85858. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85859. /**
  85860. * Gets total number of vertices
  85861. * @returns the total number of vertices
  85862. */
  85863. getTotalVertices(): number;
  85864. /**
  85865. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85866. * @param kind defines the data kind (Position, normal, etc...)
  85867. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85868. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85869. * @returns a float array containing vertex data
  85870. */
  85871. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85872. /**
  85873. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85874. * @param kind defines the data kind (Position, normal, etc...)
  85875. * @returns true if the vertex buffer with the specified kind is updatable
  85876. */
  85877. isVertexBufferUpdatable(kind: string): boolean;
  85878. /**
  85879. * Gets a specific vertex buffer
  85880. * @param kind defines the data kind (Position, normal, etc...)
  85881. * @returns a VertexBuffer
  85882. */
  85883. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85884. /**
  85885. * Returns all vertex buffers
  85886. * @return an object holding all vertex buffers indexed by kind
  85887. */
  85888. getVertexBuffers(): Nullable<{
  85889. [key: string]: VertexBuffer;
  85890. }>;
  85891. /**
  85892. * Gets a boolean indicating if specific vertex buffer is present
  85893. * @param kind defines the data kind (Position, normal, etc...)
  85894. * @returns true if data is present
  85895. */
  85896. isVerticesDataPresent(kind: string): boolean;
  85897. /**
  85898. * Gets a list of all attached data kinds (Position, normal, etc...)
  85899. * @returns a list of string containing all kinds
  85900. */
  85901. getVerticesDataKinds(): string[];
  85902. /**
  85903. * Update index buffer
  85904. * @param indices defines the indices to store in the index buffer
  85905. * @param offset defines the offset in the target buffer where to store the data
  85906. * @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)
  85907. */
  85908. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85909. /**
  85910. * Creates a new index buffer
  85911. * @param indices defines the indices to store in the index buffer
  85912. * @param totalVertices defines the total number of vertices (could be null)
  85913. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85914. */
  85915. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85916. /**
  85917. * Return the total number of indices
  85918. * @returns the total number of indices
  85919. */
  85920. getTotalIndices(): number;
  85921. /**
  85922. * Gets the index buffer array
  85923. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85924. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85925. * @returns the index buffer array
  85926. */
  85927. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85928. /**
  85929. * Gets the index buffer
  85930. * @return the index buffer
  85931. */
  85932. getIndexBuffer(): Nullable<DataBuffer>;
  85933. /** @hidden */
  85934. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85935. /**
  85936. * Release the associated resources for a specific mesh
  85937. * @param mesh defines the source mesh
  85938. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85939. */
  85940. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85941. /**
  85942. * Apply current geometry to a given mesh
  85943. * @param mesh defines the mesh to apply geometry to
  85944. */
  85945. applyToMesh(mesh: Mesh): void;
  85946. private _updateExtend;
  85947. private _applyToMesh;
  85948. private notifyUpdate;
  85949. /**
  85950. * Load the geometry if it was flagged as delay loaded
  85951. * @param scene defines the hosting scene
  85952. * @param onLoaded defines a callback called when the geometry is loaded
  85953. */
  85954. load(scene: Scene, onLoaded?: () => void): void;
  85955. private _queueLoad;
  85956. /**
  85957. * Invert the geometry to move from a right handed system to a left handed one.
  85958. */
  85959. toLeftHanded(): void;
  85960. /** @hidden */
  85961. _resetPointsArrayCache(): void;
  85962. /** @hidden */
  85963. _generatePointsArray(): boolean;
  85964. /**
  85965. * Gets a value indicating if the geometry is disposed
  85966. * @returns true if the geometry was disposed
  85967. */
  85968. isDisposed(): boolean;
  85969. private _disposeVertexArrayObjects;
  85970. /**
  85971. * Free all associated resources
  85972. */
  85973. dispose(): void;
  85974. /**
  85975. * Clone the current geometry into a new geometry
  85976. * @param id defines the unique ID of the new geometry
  85977. * @returns a new geometry object
  85978. */
  85979. copy(id: string): Geometry;
  85980. /**
  85981. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85982. * @return a JSON representation of the current geometry data (without the vertices data)
  85983. */
  85984. serialize(): any;
  85985. private toNumberArray;
  85986. /**
  85987. * Serialize all vertices data into a JSON oject
  85988. * @returns a JSON representation of the current geometry data
  85989. */
  85990. serializeVerticeData(): any;
  85991. /**
  85992. * Extracts a clone of a mesh geometry
  85993. * @param mesh defines the source mesh
  85994. * @param id defines the unique ID of the new geometry object
  85995. * @returns the new geometry object
  85996. */
  85997. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85998. /**
  85999. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86000. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86001. * Be aware Math.random() could cause collisions, but:
  86002. * "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"
  86003. * @returns a string containing a new GUID
  86004. */
  86005. static RandomId(): string;
  86006. /** @hidden */
  86007. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86008. private static _CleanMatricesWeights;
  86009. /**
  86010. * Create a new geometry from persisted data (Using .babylon file format)
  86011. * @param parsedVertexData defines the persisted data
  86012. * @param scene defines the hosting scene
  86013. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86014. * @returns the new geometry object
  86015. */
  86016. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86017. }
  86018. }
  86019. declare module BABYLON {
  86020. /**
  86021. * Define an interface for all classes that will get and set the data on vertices
  86022. */
  86023. export interface IGetSetVerticesData {
  86024. /**
  86025. * Gets a boolean indicating if specific vertex data is present
  86026. * @param kind defines the vertex data kind to use
  86027. * @returns true is data kind is present
  86028. */
  86029. isVerticesDataPresent(kind: string): boolean;
  86030. /**
  86031. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86032. * @param kind defines the data kind (Position, normal, etc...)
  86033. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86034. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86035. * @returns a float array containing vertex data
  86036. */
  86037. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86038. /**
  86039. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86040. * @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.
  86041. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86042. * @returns the indices array or an empty array if the mesh has no geometry
  86043. */
  86044. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86045. /**
  86046. * Set specific vertex data
  86047. * @param kind defines the data kind (Position, normal, etc...)
  86048. * @param data defines the vertex data to use
  86049. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86050. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86051. */
  86052. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86053. /**
  86054. * Update a specific associated vertex buffer
  86055. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86056. * - VertexBuffer.PositionKind
  86057. * - VertexBuffer.UVKind
  86058. * - VertexBuffer.UV2Kind
  86059. * - VertexBuffer.UV3Kind
  86060. * - VertexBuffer.UV4Kind
  86061. * - VertexBuffer.UV5Kind
  86062. * - VertexBuffer.UV6Kind
  86063. * - VertexBuffer.ColorKind
  86064. * - VertexBuffer.MatricesIndicesKind
  86065. * - VertexBuffer.MatricesIndicesExtraKind
  86066. * - VertexBuffer.MatricesWeightsKind
  86067. * - VertexBuffer.MatricesWeightsExtraKind
  86068. * @param data defines the data source
  86069. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86070. * @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)
  86071. */
  86072. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86073. /**
  86074. * Creates a new index buffer
  86075. * @param indices defines the indices to store in the index buffer
  86076. * @param totalVertices defines the total number of vertices (could be null)
  86077. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86078. */
  86079. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86080. }
  86081. /**
  86082. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86083. */
  86084. export class VertexData {
  86085. /**
  86086. * Mesh side orientation : usually the external or front surface
  86087. */
  86088. static readonly FRONTSIDE: number;
  86089. /**
  86090. * Mesh side orientation : usually the internal or back surface
  86091. */
  86092. static readonly BACKSIDE: number;
  86093. /**
  86094. * Mesh side orientation : both internal and external or front and back surfaces
  86095. */
  86096. static readonly DOUBLESIDE: number;
  86097. /**
  86098. * Mesh side orientation : by default, `FRONTSIDE`
  86099. */
  86100. static readonly DEFAULTSIDE: number;
  86101. /**
  86102. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86103. */
  86104. positions: Nullable<FloatArray>;
  86105. /**
  86106. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86107. */
  86108. normals: Nullable<FloatArray>;
  86109. /**
  86110. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86111. */
  86112. tangents: Nullable<FloatArray>;
  86113. /**
  86114. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86115. */
  86116. uvs: Nullable<FloatArray>;
  86117. /**
  86118. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86119. */
  86120. uvs2: Nullable<FloatArray>;
  86121. /**
  86122. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86123. */
  86124. uvs3: Nullable<FloatArray>;
  86125. /**
  86126. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86127. */
  86128. uvs4: Nullable<FloatArray>;
  86129. /**
  86130. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86131. */
  86132. uvs5: Nullable<FloatArray>;
  86133. /**
  86134. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86135. */
  86136. uvs6: Nullable<FloatArray>;
  86137. /**
  86138. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86139. */
  86140. colors: Nullable<FloatArray>;
  86141. /**
  86142. * 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).
  86143. */
  86144. matricesIndices: Nullable<FloatArray>;
  86145. /**
  86146. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86147. */
  86148. matricesWeights: Nullable<FloatArray>;
  86149. /**
  86150. * An array extending the number of possible indices
  86151. */
  86152. matricesIndicesExtra: Nullable<FloatArray>;
  86153. /**
  86154. * An array extending the number of possible weights when the number of indices is extended
  86155. */
  86156. matricesWeightsExtra: Nullable<FloatArray>;
  86157. /**
  86158. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86159. */
  86160. indices: Nullable<IndicesArray>;
  86161. /**
  86162. * Uses the passed data array to set the set the values for the specified kind of data
  86163. * @param data a linear array of floating numbers
  86164. * @param kind the type of data that is being set, eg positions, colors etc
  86165. */
  86166. set(data: FloatArray, kind: string): void;
  86167. /**
  86168. * Associates the vertexData to the passed Mesh.
  86169. * Sets it as updatable or not (default `false`)
  86170. * @param mesh the mesh the vertexData is applied to
  86171. * @param updatable when used and having the value true allows new data to update the vertexData
  86172. * @returns the VertexData
  86173. */
  86174. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86175. /**
  86176. * Associates the vertexData to the passed Geometry.
  86177. * Sets it as updatable or not (default `false`)
  86178. * @param geometry the geometry the vertexData is applied to
  86179. * @param updatable when used and having the value true allows new data to update the vertexData
  86180. * @returns VertexData
  86181. */
  86182. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86183. /**
  86184. * Updates the associated mesh
  86185. * @param mesh the mesh to be updated
  86186. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86187. * @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
  86188. * @returns VertexData
  86189. */
  86190. updateMesh(mesh: Mesh): VertexData;
  86191. /**
  86192. * Updates the associated geometry
  86193. * @param geometry the geometry to be updated
  86194. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86195. * @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
  86196. * @returns VertexData.
  86197. */
  86198. updateGeometry(geometry: Geometry): VertexData;
  86199. private _applyTo;
  86200. private _update;
  86201. /**
  86202. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86203. * @param matrix the transforming matrix
  86204. * @returns the VertexData
  86205. */
  86206. transform(matrix: Matrix): VertexData;
  86207. /**
  86208. * Merges the passed VertexData into the current one
  86209. * @param other the VertexData to be merged into the current one
  86210. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86211. * @returns the modified VertexData
  86212. */
  86213. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86214. private _mergeElement;
  86215. private _validate;
  86216. /**
  86217. * Serializes the VertexData
  86218. * @returns a serialized object
  86219. */
  86220. serialize(): any;
  86221. /**
  86222. * Extracts the vertexData from a mesh
  86223. * @param mesh the mesh from which to extract the VertexData
  86224. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86225. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86226. * @returns the object VertexData associated to the passed mesh
  86227. */
  86228. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86229. /**
  86230. * Extracts the vertexData from the geometry
  86231. * @param geometry the geometry from which to extract the VertexData
  86232. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86233. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86234. * @returns the object VertexData associated to the passed mesh
  86235. */
  86236. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86237. private static _ExtractFrom;
  86238. /**
  86239. * Creates the VertexData for a Ribbon
  86240. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86241. * * pathArray array of paths, each of which an array of successive Vector3
  86242. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86243. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86244. * * 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
  86245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86246. * * 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)
  86247. * * 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)
  86248. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86249. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86250. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86251. * @returns the VertexData of the ribbon
  86252. */
  86253. static CreateRibbon(options: {
  86254. pathArray: Vector3[][];
  86255. closeArray?: boolean;
  86256. closePath?: boolean;
  86257. offset?: number;
  86258. sideOrientation?: number;
  86259. frontUVs?: Vector4;
  86260. backUVs?: Vector4;
  86261. invertUV?: boolean;
  86262. uvs?: Vector2[];
  86263. colors?: Color4[];
  86264. }): VertexData;
  86265. /**
  86266. * Creates the VertexData for a box
  86267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86268. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86269. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86270. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86271. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86272. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86273. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86275. * * 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)
  86276. * * 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)
  86277. * @returns the VertexData of the box
  86278. */
  86279. static CreateBox(options: {
  86280. size?: number;
  86281. width?: number;
  86282. height?: number;
  86283. depth?: number;
  86284. faceUV?: Vector4[];
  86285. faceColors?: Color4[];
  86286. sideOrientation?: number;
  86287. frontUVs?: Vector4;
  86288. backUVs?: Vector4;
  86289. }): VertexData;
  86290. /**
  86291. * Creates the VertexData for a tiled box
  86292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86293. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86294. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86295. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86297. * @returns the VertexData of the box
  86298. */
  86299. static CreateTiledBox(options: {
  86300. pattern?: number;
  86301. width?: number;
  86302. height?: number;
  86303. depth?: number;
  86304. tileSize?: number;
  86305. tileWidth?: number;
  86306. tileHeight?: number;
  86307. alignHorizontal?: number;
  86308. alignVertical?: number;
  86309. faceUV?: Vector4[];
  86310. faceColors?: Color4[];
  86311. sideOrientation?: number;
  86312. }): VertexData;
  86313. /**
  86314. * Creates the VertexData for a tiled plane
  86315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86316. * * pattern a limited pattern arrangement depending on the number
  86317. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86318. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86319. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86321. * * 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)
  86322. * * 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)
  86323. * @returns the VertexData of the tiled plane
  86324. */
  86325. static CreateTiledPlane(options: {
  86326. pattern?: number;
  86327. tileSize?: number;
  86328. tileWidth?: number;
  86329. tileHeight?: number;
  86330. size?: number;
  86331. width?: number;
  86332. height?: number;
  86333. alignHorizontal?: number;
  86334. alignVertical?: number;
  86335. sideOrientation?: number;
  86336. frontUVs?: Vector4;
  86337. backUVs?: Vector4;
  86338. }): VertexData;
  86339. /**
  86340. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86341. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86342. * * segments sets the number of horizontal strips optional, default 32
  86343. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86344. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86345. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86346. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86347. * * 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
  86348. * * 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
  86349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86350. * * 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)
  86351. * * 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)
  86352. * @returns the VertexData of the ellipsoid
  86353. */
  86354. static CreateSphere(options: {
  86355. segments?: number;
  86356. diameter?: number;
  86357. diameterX?: number;
  86358. diameterY?: number;
  86359. diameterZ?: number;
  86360. arc?: number;
  86361. slice?: number;
  86362. sideOrientation?: number;
  86363. frontUVs?: Vector4;
  86364. backUVs?: Vector4;
  86365. }): VertexData;
  86366. /**
  86367. * Creates the VertexData for a cylinder, cone or prism
  86368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86369. * * height sets the height (y direction) of the cylinder, optional, default 2
  86370. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86371. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86372. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86373. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86374. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86375. * * 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
  86376. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86377. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86378. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86379. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86381. * * 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)
  86382. * * 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)
  86383. * @returns the VertexData of the cylinder, cone or prism
  86384. */
  86385. static CreateCylinder(options: {
  86386. height?: number;
  86387. diameterTop?: number;
  86388. diameterBottom?: number;
  86389. diameter?: number;
  86390. tessellation?: number;
  86391. subdivisions?: number;
  86392. arc?: number;
  86393. faceColors?: Color4[];
  86394. faceUV?: Vector4[];
  86395. hasRings?: boolean;
  86396. enclose?: boolean;
  86397. sideOrientation?: number;
  86398. frontUVs?: Vector4;
  86399. backUVs?: Vector4;
  86400. }): VertexData;
  86401. /**
  86402. * Creates the VertexData for a torus
  86403. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86404. * * diameter the diameter of the torus, optional default 1
  86405. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86406. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86408. * * 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)
  86409. * * 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)
  86410. * @returns the VertexData of the torus
  86411. */
  86412. static CreateTorus(options: {
  86413. diameter?: number;
  86414. thickness?: number;
  86415. tessellation?: number;
  86416. sideOrientation?: number;
  86417. frontUVs?: Vector4;
  86418. backUVs?: Vector4;
  86419. }): VertexData;
  86420. /**
  86421. * Creates the VertexData of the LineSystem
  86422. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86423. * - lines an array of lines, each line being an array of successive Vector3
  86424. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86425. * @returns the VertexData of the LineSystem
  86426. */
  86427. static CreateLineSystem(options: {
  86428. lines: Vector3[][];
  86429. colors?: Nullable<Color4[][]>;
  86430. }): VertexData;
  86431. /**
  86432. * Create the VertexData for a DashedLines
  86433. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86434. * - points an array successive Vector3
  86435. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86436. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86437. * - dashNb the intended total number of dashes, optional, default 200
  86438. * @returns the VertexData for the DashedLines
  86439. */
  86440. static CreateDashedLines(options: {
  86441. points: Vector3[];
  86442. dashSize?: number;
  86443. gapSize?: number;
  86444. dashNb?: number;
  86445. }): VertexData;
  86446. /**
  86447. * Creates the VertexData for a Ground
  86448. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86449. * - width the width (x direction) of the ground, optional, default 1
  86450. * - height the height (z direction) of the ground, optional, default 1
  86451. * - subdivisions the number of subdivisions per side, optional, default 1
  86452. * @returns the VertexData of the Ground
  86453. */
  86454. static CreateGround(options: {
  86455. width?: number;
  86456. height?: number;
  86457. subdivisions?: number;
  86458. subdivisionsX?: number;
  86459. subdivisionsY?: number;
  86460. }): VertexData;
  86461. /**
  86462. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86463. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86464. * * xmin the ground minimum X coordinate, optional, default -1
  86465. * * zmin the ground minimum Z coordinate, optional, default -1
  86466. * * xmax the ground maximum X coordinate, optional, default 1
  86467. * * zmax the ground maximum Z coordinate, optional, default 1
  86468. * * 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}
  86469. * * 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}
  86470. * @returns the VertexData of the TiledGround
  86471. */
  86472. static CreateTiledGround(options: {
  86473. xmin: number;
  86474. zmin: number;
  86475. xmax: number;
  86476. zmax: number;
  86477. subdivisions?: {
  86478. w: number;
  86479. h: number;
  86480. };
  86481. precision?: {
  86482. w: number;
  86483. h: number;
  86484. };
  86485. }): VertexData;
  86486. /**
  86487. * Creates the VertexData of the Ground designed from a heightmap
  86488. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86489. * * width the width (x direction) of the ground
  86490. * * height the height (z direction) of the ground
  86491. * * subdivisions the number of subdivisions per side
  86492. * * minHeight the minimum altitude on the ground, optional, default 0
  86493. * * maxHeight the maximum altitude on the ground, optional default 1
  86494. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86495. * * buffer the array holding the image color data
  86496. * * bufferWidth the width of image
  86497. * * bufferHeight the height of image
  86498. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86499. * @returns the VertexData of the Ground designed from a heightmap
  86500. */
  86501. static CreateGroundFromHeightMap(options: {
  86502. width: number;
  86503. height: number;
  86504. subdivisions: number;
  86505. minHeight: number;
  86506. maxHeight: number;
  86507. colorFilter: Color3;
  86508. buffer: Uint8Array;
  86509. bufferWidth: number;
  86510. bufferHeight: number;
  86511. alphaFilter: number;
  86512. }): VertexData;
  86513. /**
  86514. * Creates the VertexData for a Plane
  86515. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86516. * * size sets the width and height of the plane to the value of size, optional default 1
  86517. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86518. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86520. * * 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)
  86521. * * 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)
  86522. * @returns the VertexData of the box
  86523. */
  86524. static CreatePlane(options: {
  86525. size?: number;
  86526. width?: number;
  86527. height?: number;
  86528. sideOrientation?: number;
  86529. frontUVs?: Vector4;
  86530. backUVs?: Vector4;
  86531. }): VertexData;
  86532. /**
  86533. * Creates the VertexData of the Disc or regular Polygon
  86534. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86535. * * radius the radius of the disc, optional default 0.5
  86536. * * tessellation the number of polygon sides, optional, default 64
  86537. * * 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
  86538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86539. * * 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)
  86540. * * 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)
  86541. * @returns the VertexData of the box
  86542. */
  86543. static CreateDisc(options: {
  86544. radius?: number;
  86545. tessellation?: number;
  86546. arc?: number;
  86547. sideOrientation?: number;
  86548. frontUVs?: Vector4;
  86549. backUVs?: Vector4;
  86550. }): VertexData;
  86551. /**
  86552. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86553. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86554. * @param polygon a mesh built from polygonTriangulation.build()
  86555. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86556. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86557. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86558. * @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)
  86559. * @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)
  86560. * @returns the VertexData of the Polygon
  86561. */
  86562. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86563. /**
  86564. * Creates the VertexData of the IcoSphere
  86565. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86566. * * radius the radius of the IcoSphere, optional default 1
  86567. * * radiusX allows stretching in the x direction, optional, default radius
  86568. * * radiusY allows stretching in the y direction, optional, default radius
  86569. * * radiusZ allows stretching in the z direction, optional, default radius
  86570. * * flat when true creates a flat shaded mesh, optional, default true
  86571. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86573. * * 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)
  86574. * * 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)
  86575. * @returns the VertexData of the IcoSphere
  86576. */
  86577. static CreateIcoSphere(options: {
  86578. radius?: number;
  86579. radiusX?: number;
  86580. radiusY?: number;
  86581. radiusZ?: number;
  86582. flat?: boolean;
  86583. subdivisions?: number;
  86584. sideOrientation?: number;
  86585. frontUVs?: Vector4;
  86586. backUVs?: Vector4;
  86587. }): VertexData;
  86588. /**
  86589. * Creates the VertexData for a Polyhedron
  86590. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86591. * * type provided types are:
  86592. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86593. * * 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)
  86594. * * size the size of the IcoSphere, optional default 1
  86595. * * sizeX allows stretching in the x direction, optional, default size
  86596. * * sizeY allows stretching in the y direction, optional, default size
  86597. * * sizeZ allows stretching in the z direction, optional, default size
  86598. * * 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
  86599. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86600. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86601. * * flat when true creates a flat shaded mesh, optional, default true
  86602. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86604. * * 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)
  86605. * * 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)
  86606. * @returns the VertexData of the Polyhedron
  86607. */
  86608. static CreatePolyhedron(options: {
  86609. type?: number;
  86610. size?: number;
  86611. sizeX?: number;
  86612. sizeY?: number;
  86613. sizeZ?: number;
  86614. custom?: any;
  86615. faceUV?: Vector4[];
  86616. faceColors?: Color4[];
  86617. flat?: boolean;
  86618. sideOrientation?: number;
  86619. frontUVs?: Vector4;
  86620. backUVs?: Vector4;
  86621. }): VertexData;
  86622. /**
  86623. * Creates the VertexData for a TorusKnot
  86624. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86625. * * radius the radius of the torus knot, optional, default 2
  86626. * * tube the thickness of the tube, optional, default 0.5
  86627. * * radialSegments the number of sides on each tube segments, optional, default 32
  86628. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86629. * * p the number of windings around the z axis, optional, default 2
  86630. * * q the number of windings around the x axis, optional, default 3
  86631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86632. * * 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)
  86633. * * 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)
  86634. * @returns the VertexData of the Torus Knot
  86635. */
  86636. static CreateTorusKnot(options: {
  86637. radius?: number;
  86638. tube?: number;
  86639. radialSegments?: number;
  86640. tubularSegments?: number;
  86641. p?: number;
  86642. q?: number;
  86643. sideOrientation?: number;
  86644. frontUVs?: Vector4;
  86645. backUVs?: Vector4;
  86646. }): VertexData;
  86647. /**
  86648. * Compute normals for given positions and indices
  86649. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86650. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86651. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86652. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86653. * * facetNormals : optional array of facet normals (vector3)
  86654. * * facetPositions : optional array of facet positions (vector3)
  86655. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86656. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86657. * * bInfo : optional bounding info, required for facetPartitioning computation
  86658. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86659. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86660. * * useRightHandedSystem: optional boolean to for right handed system computation
  86661. * * depthSort : optional boolean to enable the facet depth sort computation
  86662. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86663. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86664. */
  86665. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86666. facetNormals?: any;
  86667. facetPositions?: any;
  86668. facetPartitioning?: any;
  86669. ratio?: number;
  86670. bInfo?: any;
  86671. bbSize?: Vector3;
  86672. subDiv?: any;
  86673. useRightHandedSystem?: boolean;
  86674. depthSort?: boolean;
  86675. distanceTo?: Vector3;
  86676. depthSortedFacets?: any;
  86677. }): void;
  86678. /** @hidden */
  86679. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86680. /**
  86681. * Applies VertexData created from the imported parameters to the geometry
  86682. * @param parsedVertexData the parsed data from an imported file
  86683. * @param geometry the geometry to apply the VertexData to
  86684. */
  86685. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86686. }
  86687. }
  86688. declare module BABYLON {
  86689. /**
  86690. * Defines a target to use with MorphTargetManager
  86691. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86692. */
  86693. export class MorphTarget implements IAnimatable {
  86694. /** defines the name of the target */
  86695. name: string;
  86696. /**
  86697. * Gets or sets the list of animations
  86698. */
  86699. animations: Animation[];
  86700. private _scene;
  86701. private _positions;
  86702. private _normals;
  86703. private _tangents;
  86704. private _uvs;
  86705. private _influence;
  86706. /**
  86707. * Observable raised when the influence changes
  86708. */
  86709. onInfluenceChanged: Observable<boolean>;
  86710. /** @hidden */
  86711. _onDataLayoutChanged: Observable<void>;
  86712. /**
  86713. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86714. */
  86715. influence: number;
  86716. /**
  86717. * Gets or sets the id of the morph Target
  86718. */
  86719. id: string;
  86720. private _animationPropertiesOverride;
  86721. /**
  86722. * Gets or sets the animation properties override
  86723. */
  86724. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86725. /**
  86726. * Creates a new MorphTarget
  86727. * @param name defines the name of the target
  86728. * @param influence defines the influence to use
  86729. * @param scene defines the scene the morphtarget belongs to
  86730. */
  86731. constructor(
  86732. /** defines the name of the target */
  86733. name: string, influence?: number, scene?: Nullable<Scene>);
  86734. /**
  86735. * Gets a boolean defining if the target contains position data
  86736. */
  86737. readonly hasPositions: boolean;
  86738. /**
  86739. * Gets a boolean defining if the target contains normal data
  86740. */
  86741. readonly hasNormals: boolean;
  86742. /**
  86743. * Gets a boolean defining if the target contains tangent data
  86744. */
  86745. readonly hasTangents: boolean;
  86746. /**
  86747. * Gets a boolean defining if the target contains texture coordinates data
  86748. */
  86749. readonly hasUVs: boolean;
  86750. /**
  86751. * Affects position data to this target
  86752. * @param data defines the position data to use
  86753. */
  86754. setPositions(data: Nullable<FloatArray>): void;
  86755. /**
  86756. * Gets the position data stored in this target
  86757. * @returns a FloatArray containing the position data (or null if not present)
  86758. */
  86759. getPositions(): Nullable<FloatArray>;
  86760. /**
  86761. * Affects normal data to this target
  86762. * @param data defines the normal data to use
  86763. */
  86764. setNormals(data: Nullable<FloatArray>): void;
  86765. /**
  86766. * Gets the normal data stored in this target
  86767. * @returns a FloatArray containing the normal data (or null if not present)
  86768. */
  86769. getNormals(): Nullable<FloatArray>;
  86770. /**
  86771. * Affects tangent data to this target
  86772. * @param data defines the tangent data to use
  86773. */
  86774. setTangents(data: Nullable<FloatArray>): void;
  86775. /**
  86776. * Gets the tangent data stored in this target
  86777. * @returns a FloatArray containing the tangent data (or null if not present)
  86778. */
  86779. getTangents(): Nullable<FloatArray>;
  86780. /**
  86781. * Affects texture coordinates data to this target
  86782. * @param data defines the texture coordinates data to use
  86783. */
  86784. setUVs(data: Nullable<FloatArray>): void;
  86785. /**
  86786. * Gets the texture coordinates data stored in this target
  86787. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86788. */
  86789. getUVs(): Nullable<FloatArray>;
  86790. /**
  86791. * Serializes the current target into a Serialization object
  86792. * @returns the serialized object
  86793. */
  86794. serialize(): any;
  86795. /**
  86796. * Returns the string "MorphTarget"
  86797. * @returns "MorphTarget"
  86798. */
  86799. getClassName(): string;
  86800. /**
  86801. * Creates a new target from serialized data
  86802. * @param serializationObject defines the serialized data to use
  86803. * @returns a new MorphTarget
  86804. */
  86805. static Parse(serializationObject: any): MorphTarget;
  86806. /**
  86807. * Creates a MorphTarget from mesh data
  86808. * @param mesh defines the source mesh
  86809. * @param name defines the name to use for the new target
  86810. * @param influence defines the influence to attach to the target
  86811. * @returns a new MorphTarget
  86812. */
  86813. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86814. }
  86815. }
  86816. declare module BABYLON {
  86817. /**
  86818. * This class is used to deform meshes using morphing between different targets
  86819. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86820. */
  86821. export class MorphTargetManager {
  86822. private _targets;
  86823. private _targetInfluenceChangedObservers;
  86824. private _targetDataLayoutChangedObservers;
  86825. private _activeTargets;
  86826. private _scene;
  86827. private _influences;
  86828. private _supportsNormals;
  86829. private _supportsTangents;
  86830. private _supportsUVs;
  86831. private _vertexCount;
  86832. private _uniqueId;
  86833. private _tempInfluences;
  86834. /**
  86835. * Gets or sets a boolean indicating if normals must be morphed
  86836. */
  86837. enableNormalMorphing: boolean;
  86838. /**
  86839. * Gets or sets a boolean indicating if tangents must be morphed
  86840. */
  86841. enableTangentMorphing: boolean;
  86842. /**
  86843. * Gets or sets a boolean indicating if UV must be morphed
  86844. */
  86845. enableUVMorphing: boolean;
  86846. /**
  86847. * Creates a new MorphTargetManager
  86848. * @param scene defines the current scene
  86849. */
  86850. constructor(scene?: Nullable<Scene>);
  86851. /**
  86852. * Gets the unique ID of this manager
  86853. */
  86854. readonly uniqueId: number;
  86855. /**
  86856. * Gets the number of vertices handled by this manager
  86857. */
  86858. readonly vertexCount: number;
  86859. /**
  86860. * Gets a boolean indicating if this manager supports morphing of normals
  86861. */
  86862. readonly supportsNormals: boolean;
  86863. /**
  86864. * Gets a boolean indicating if this manager supports morphing of tangents
  86865. */
  86866. readonly supportsTangents: boolean;
  86867. /**
  86868. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86869. */
  86870. readonly supportsUVs: boolean;
  86871. /**
  86872. * Gets the number of targets stored in this manager
  86873. */
  86874. readonly numTargets: number;
  86875. /**
  86876. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86877. */
  86878. readonly numInfluencers: number;
  86879. /**
  86880. * Gets the list of influences (one per target)
  86881. */
  86882. readonly influences: Float32Array;
  86883. /**
  86884. * Gets the active target at specified index. An active target is a target with an influence > 0
  86885. * @param index defines the index to check
  86886. * @returns the requested target
  86887. */
  86888. getActiveTarget(index: number): MorphTarget;
  86889. /**
  86890. * Gets the target at specified index
  86891. * @param index defines the index to check
  86892. * @returns the requested target
  86893. */
  86894. getTarget(index: number): MorphTarget;
  86895. /**
  86896. * Add a new target to this manager
  86897. * @param target defines the target to add
  86898. */
  86899. addTarget(target: MorphTarget): void;
  86900. /**
  86901. * Removes a target from the manager
  86902. * @param target defines the target to remove
  86903. */
  86904. removeTarget(target: MorphTarget): void;
  86905. /**
  86906. * Serializes the current manager into a Serialization object
  86907. * @returns the serialized object
  86908. */
  86909. serialize(): any;
  86910. private _syncActiveTargets;
  86911. /**
  86912. * Syncrhonize the targets with all the meshes using this morph target manager
  86913. */
  86914. synchronize(): void;
  86915. /**
  86916. * Creates a new MorphTargetManager from serialized data
  86917. * @param serializationObject defines the serialized data
  86918. * @param scene defines the hosting scene
  86919. * @returns the new MorphTargetManager
  86920. */
  86921. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86922. }
  86923. }
  86924. declare module BABYLON {
  86925. /**
  86926. * Class used to represent a specific level of detail of a mesh
  86927. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86928. */
  86929. export class MeshLODLevel {
  86930. /** Defines the distance where this level should star being displayed */
  86931. distance: number;
  86932. /** Defines the mesh to use to render this level */
  86933. mesh: Nullable<Mesh>;
  86934. /**
  86935. * Creates a new LOD level
  86936. * @param distance defines the distance where this level should star being displayed
  86937. * @param mesh defines the mesh to use to render this level
  86938. */
  86939. constructor(
  86940. /** Defines the distance where this level should star being displayed */
  86941. distance: number,
  86942. /** Defines the mesh to use to render this level */
  86943. mesh: Nullable<Mesh>);
  86944. }
  86945. }
  86946. declare module BABYLON {
  86947. /**
  86948. * Mesh representing the gorund
  86949. */
  86950. export class GroundMesh extends Mesh {
  86951. /** If octree should be generated */
  86952. generateOctree: boolean;
  86953. private _heightQuads;
  86954. /** @hidden */
  86955. _subdivisionsX: number;
  86956. /** @hidden */
  86957. _subdivisionsY: number;
  86958. /** @hidden */
  86959. _width: number;
  86960. /** @hidden */
  86961. _height: number;
  86962. /** @hidden */
  86963. _minX: number;
  86964. /** @hidden */
  86965. _maxX: number;
  86966. /** @hidden */
  86967. _minZ: number;
  86968. /** @hidden */
  86969. _maxZ: number;
  86970. constructor(name: string, scene: Scene);
  86971. /**
  86972. * "GroundMesh"
  86973. * @returns "GroundMesh"
  86974. */
  86975. getClassName(): string;
  86976. /**
  86977. * The minimum of x and y subdivisions
  86978. */
  86979. readonly subdivisions: number;
  86980. /**
  86981. * X subdivisions
  86982. */
  86983. readonly subdivisionsX: number;
  86984. /**
  86985. * Y subdivisions
  86986. */
  86987. readonly subdivisionsY: number;
  86988. /**
  86989. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86990. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86991. * @param chunksCount the number of subdivisions for x and y
  86992. * @param octreeBlocksSize (Default: 32)
  86993. */
  86994. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86995. /**
  86996. * Returns a height (y) value in the Worl system :
  86997. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86998. * @param x x coordinate
  86999. * @param z z coordinate
  87000. * @returns the ground y position if (x, z) are outside the ground surface.
  87001. */
  87002. getHeightAtCoordinates(x: number, z: number): number;
  87003. /**
  87004. * Returns a normalized vector (Vector3) orthogonal to the ground
  87005. * at the ground coordinates (x, z) expressed in the World system.
  87006. * @param x x coordinate
  87007. * @param z z coordinate
  87008. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87009. */
  87010. getNormalAtCoordinates(x: number, z: number): Vector3;
  87011. /**
  87012. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87013. * at the ground coordinates (x, z) expressed in the World system.
  87014. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87015. * @param x x coordinate
  87016. * @param z z coordinate
  87017. * @param ref vector to store the result
  87018. * @returns the GroundMesh.
  87019. */
  87020. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87021. /**
  87022. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87023. * if the ground has been updated.
  87024. * This can be used in the render loop.
  87025. * @returns the GroundMesh.
  87026. */
  87027. updateCoordinateHeights(): GroundMesh;
  87028. private _getFacetAt;
  87029. private _initHeightQuads;
  87030. private _computeHeightQuads;
  87031. /**
  87032. * Serializes this ground mesh
  87033. * @param serializationObject object to write serialization to
  87034. */
  87035. serialize(serializationObject: any): void;
  87036. /**
  87037. * Parses a serialized ground mesh
  87038. * @param parsedMesh the serialized mesh
  87039. * @param scene the scene to create the ground mesh in
  87040. * @returns the created ground mesh
  87041. */
  87042. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87043. }
  87044. }
  87045. declare module BABYLON {
  87046. /**
  87047. * Interface for Physics-Joint data
  87048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87049. */
  87050. export interface PhysicsJointData {
  87051. /**
  87052. * The main pivot of the joint
  87053. */
  87054. mainPivot?: Vector3;
  87055. /**
  87056. * The connected pivot of the joint
  87057. */
  87058. connectedPivot?: Vector3;
  87059. /**
  87060. * The main axis of the joint
  87061. */
  87062. mainAxis?: Vector3;
  87063. /**
  87064. * The connected axis of the joint
  87065. */
  87066. connectedAxis?: Vector3;
  87067. /**
  87068. * The collision of the joint
  87069. */
  87070. collision?: boolean;
  87071. /**
  87072. * Native Oimo/Cannon/Energy data
  87073. */
  87074. nativeParams?: any;
  87075. }
  87076. /**
  87077. * This is a holder class for the physics joint created by the physics plugin
  87078. * It holds a set of functions to control the underlying joint
  87079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87080. */
  87081. export class PhysicsJoint {
  87082. /**
  87083. * The type of the physics joint
  87084. */
  87085. type: number;
  87086. /**
  87087. * The data for the physics joint
  87088. */
  87089. jointData: PhysicsJointData;
  87090. private _physicsJoint;
  87091. protected _physicsPlugin: IPhysicsEnginePlugin;
  87092. /**
  87093. * Initializes the physics joint
  87094. * @param type The type of the physics joint
  87095. * @param jointData The data for the physics joint
  87096. */
  87097. constructor(
  87098. /**
  87099. * The type of the physics joint
  87100. */
  87101. type: number,
  87102. /**
  87103. * The data for the physics joint
  87104. */
  87105. jointData: PhysicsJointData);
  87106. /**
  87107. * Gets the physics joint
  87108. */
  87109. /**
  87110. * Sets the physics joint
  87111. */
  87112. physicsJoint: any;
  87113. /**
  87114. * Sets the physics plugin
  87115. */
  87116. physicsPlugin: IPhysicsEnginePlugin;
  87117. /**
  87118. * Execute a function that is physics-plugin specific.
  87119. * @param {Function} func the function that will be executed.
  87120. * It accepts two parameters: the physics world and the physics joint
  87121. */
  87122. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87123. /**
  87124. * Distance-Joint type
  87125. */
  87126. static DistanceJoint: number;
  87127. /**
  87128. * Hinge-Joint type
  87129. */
  87130. static HingeJoint: number;
  87131. /**
  87132. * Ball-and-Socket joint type
  87133. */
  87134. static BallAndSocketJoint: number;
  87135. /**
  87136. * Wheel-Joint type
  87137. */
  87138. static WheelJoint: number;
  87139. /**
  87140. * Slider-Joint type
  87141. */
  87142. static SliderJoint: number;
  87143. /**
  87144. * Prismatic-Joint type
  87145. */
  87146. static PrismaticJoint: number;
  87147. /**
  87148. * Universal-Joint type
  87149. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87150. */
  87151. static UniversalJoint: number;
  87152. /**
  87153. * Hinge-Joint 2 type
  87154. */
  87155. static Hinge2Joint: number;
  87156. /**
  87157. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87158. */
  87159. static PointToPointJoint: number;
  87160. /**
  87161. * Spring-Joint type
  87162. */
  87163. static SpringJoint: number;
  87164. /**
  87165. * Lock-Joint type
  87166. */
  87167. static LockJoint: number;
  87168. }
  87169. /**
  87170. * A class representing a physics distance joint
  87171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87172. */
  87173. export class DistanceJoint extends PhysicsJoint {
  87174. /**
  87175. *
  87176. * @param jointData The data for the Distance-Joint
  87177. */
  87178. constructor(jointData: DistanceJointData);
  87179. /**
  87180. * Update the predefined distance.
  87181. * @param maxDistance The maximum preferred distance
  87182. * @param minDistance The minimum preferred distance
  87183. */
  87184. updateDistance(maxDistance: number, minDistance?: number): void;
  87185. }
  87186. /**
  87187. * Represents a Motor-Enabled Joint
  87188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87189. */
  87190. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87191. /**
  87192. * Initializes the Motor-Enabled Joint
  87193. * @param type The type of the joint
  87194. * @param jointData The physica joint data for the joint
  87195. */
  87196. constructor(type: number, jointData: PhysicsJointData);
  87197. /**
  87198. * Set the motor values.
  87199. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87200. * @param force the force to apply
  87201. * @param maxForce max force for this motor.
  87202. */
  87203. setMotor(force?: number, maxForce?: number): void;
  87204. /**
  87205. * Set the motor's limits.
  87206. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87207. * @param upperLimit The upper limit of the motor
  87208. * @param lowerLimit The lower limit of the motor
  87209. */
  87210. setLimit(upperLimit: number, lowerLimit?: number): void;
  87211. }
  87212. /**
  87213. * This class represents a single physics Hinge-Joint
  87214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87215. */
  87216. export class HingeJoint extends MotorEnabledJoint {
  87217. /**
  87218. * Initializes the Hinge-Joint
  87219. * @param jointData The joint data for the Hinge-Joint
  87220. */
  87221. constructor(jointData: PhysicsJointData);
  87222. /**
  87223. * Set the motor values.
  87224. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87225. * @param {number} force the force to apply
  87226. * @param {number} maxForce max force for this motor.
  87227. */
  87228. setMotor(force?: number, maxForce?: number): void;
  87229. /**
  87230. * Set the motor's limits.
  87231. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87232. * @param upperLimit The upper limit of the motor
  87233. * @param lowerLimit The lower limit of the motor
  87234. */
  87235. setLimit(upperLimit: number, lowerLimit?: number): void;
  87236. }
  87237. /**
  87238. * This class represents a dual hinge physics joint (same as wheel joint)
  87239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87240. */
  87241. export class Hinge2Joint extends MotorEnabledJoint {
  87242. /**
  87243. * Initializes the Hinge2-Joint
  87244. * @param jointData The joint data for the Hinge2-Joint
  87245. */
  87246. constructor(jointData: PhysicsJointData);
  87247. /**
  87248. * Set the motor values.
  87249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87250. * @param {number} targetSpeed the speed the motor is to reach
  87251. * @param {number} maxForce max force for this motor.
  87252. * @param {motorIndex} the motor's index, 0 or 1.
  87253. */
  87254. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87255. /**
  87256. * Set the motor limits.
  87257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87258. * @param {number} upperLimit the upper limit
  87259. * @param {number} lowerLimit lower limit
  87260. * @param {motorIndex} the motor's index, 0 or 1.
  87261. */
  87262. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87263. }
  87264. /**
  87265. * Interface for a motor enabled joint
  87266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87267. */
  87268. export interface IMotorEnabledJoint {
  87269. /**
  87270. * Physics joint
  87271. */
  87272. physicsJoint: any;
  87273. /**
  87274. * Sets the motor of the motor-enabled joint
  87275. * @param force The force of the motor
  87276. * @param maxForce The maximum force of the motor
  87277. * @param motorIndex The index of the motor
  87278. */
  87279. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87280. /**
  87281. * Sets the limit of the motor
  87282. * @param upperLimit The upper limit of the motor
  87283. * @param lowerLimit The lower limit of the motor
  87284. * @param motorIndex The index of the motor
  87285. */
  87286. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87287. }
  87288. /**
  87289. * Joint data for a Distance-Joint
  87290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87291. */
  87292. export interface DistanceJointData extends PhysicsJointData {
  87293. /**
  87294. * Max distance the 2 joint objects can be apart
  87295. */
  87296. maxDistance: number;
  87297. }
  87298. /**
  87299. * Joint data from a spring joint
  87300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87301. */
  87302. export interface SpringJointData extends PhysicsJointData {
  87303. /**
  87304. * Length of the spring
  87305. */
  87306. length: number;
  87307. /**
  87308. * Stiffness of the spring
  87309. */
  87310. stiffness: number;
  87311. /**
  87312. * Damping of the spring
  87313. */
  87314. damping: number;
  87315. /** this callback will be called when applying the force to the impostors. */
  87316. forceApplicationCallback: () => void;
  87317. }
  87318. }
  87319. declare module BABYLON {
  87320. /**
  87321. * Holds the data for the raycast result
  87322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87323. */
  87324. export class PhysicsRaycastResult {
  87325. private _hasHit;
  87326. private _hitDistance;
  87327. private _hitNormalWorld;
  87328. private _hitPointWorld;
  87329. private _rayFromWorld;
  87330. private _rayToWorld;
  87331. /**
  87332. * Gets if there was a hit
  87333. */
  87334. readonly hasHit: boolean;
  87335. /**
  87336. * Gets the distance from the hit
  87337. */
  87338. readonly hitDistance: number;
  87339. /**
  87340. * Gets the hit normal/direction in the world
  87341. */
  87342. readonly hitNormalWorld: Vector3;
  87343. /**
  87344. * Gets the hit point in the world
  87345. */
  87346. readonly hitPointWorld: Vector3;
  87347. /**
  87348. * Gets the ray "start point" of the ray in the world
  87349. */
  87350. readonly rayFromWorld: Vector3;
  87351. /**
  87352. * Gets the ray "end point" of the ray in the world
  87353. */
  87354. readonly rayToWorld: Vector3;
  87355. /**
  87356. * Sets the hit data (normal & point in world space)
  87357. * @param hitNormalWorld defines the normal in world space
  87358. * @param hitPointWorld defines the point in world space
  87359. */
  87360. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87361. /**
  87362. * Sets the distance from the start point to the hit point
  87363. * @param distance
  87364. */
  87365. setHitDistance(distance: number): void;
  87366. /**
  87367. * Calculates the distance manually
  87368. */
  87369. calculateHitDistance(): void;
  87370. /**
  87371. * Resets all the values to default
  87372. * @param from The from point on world space
  87373. * @param to The to point on world space
  87374. */
  87375. reset(from?: Vector3, to?: Vector3): void;
  87376. }
  87377. /**
  87378. * Interface for the size containing width and height
  87379. */
  87380. interface IXYZ {
  87381. /**
  87382. * X
  87383. */
  87384. x: number;
  87385. /**
  87386. * Y
  87387. */
  87388. y: number;
  87389. /**
  87390. * Z
  87391. */
  87392. z: number;
  87393. }
  87394. }
  87395. declare module BABYLON {
  87396. /**
  87397. * Interface used to describe a physics joint
  87398. */
  87399. export interface PhysicsImpostorJoint {
  87400. /** Defines the main impostor to which the joint is linked */
  87401. mainImpostor: PhysicsImpostor;
  87402. /** Defines the impostor that is connected to the main impostor using this joint */
  87403. connectedImpostor: PhysicsImpostor;
  87404. /** Defines the joint itself */
  87405. joint: PhysicsJoint;
  87406. }
  87407. /** @hidden */
  87408. export interface IPhysicsEnginePlugin {
  87409. world: any;
  87410. name: string;
  87411. setGravity(gravity: Vector3): void;
  87412. setTimeStep(timeStep: number): void;
  87413. getTimeStep(): number;
  87414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  87415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87416. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87417. generatePhysicsBody(impostor: PhysicsImpostor): void;
  87418. removePhysicsBody(impostor: PhysicsImpostor): void;
  87419. generateJoint(joint: PhysicsImpostorJoint): void;
  87420. removeJoint(joint: PhysicsImpostorJoint): void;
  87421. isSupported(): boolean;
  87422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87423. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87424. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87425. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87426. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87429. getBodyMass(impostor: PhysicsImpostor): number;
  87430. getBodyFriction(impostor: PhysicsImpostor): number;
  87431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87432. getBodyRestitution(impostor: PhysicsImpostor): number;
  87433. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87434. getBodyPressure?(impostor: PhysicsImpostor): number;
  87435. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87436. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87437. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87438. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87439. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87440. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87441. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87442. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87443. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87444. sleepBody(impostor: PhysicsImpostor): void;
  87445. wakeUpBody(impostor: PhysicsImpostor): void;
  87446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87447. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87448. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87449. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87450. getRadius(impostor: PhysicsImpostor): number;
  87451. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87452. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87453. dispose(): void;
  87454. }
  87455. /**
  87456. * Interface used to define a physics engine
  87457. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87458. */
  87459. export interface IPhysicsEngine {
  87460. /**
  87461. * Gets the gravity vector used by the simulation
  87462. */
  87463. gravity: Vector3;
  87464. /**
  87465. * Sets the gravity vector used by the simulation
  87466. * @param gravity defines the gravity vector to use
  87467. */
  87468. setGravity(gravity: Vector3): void;
  87469. /**
  87470. * Set the time step of the physics engine.
  87471. * Default is 1/60.
  87472. * To slow it down, enter 1/600 for example.
  87473. * To speed it up, 1/30
  87474. * @param newTimeStep the new timestep to apply to this world.
  87475. */
  87476. setTimeStep(newTimeStep: number): void;
  87477. /**
  87478. * Get the time step of the physics engine.
  87479. * @returns the current time step
  87480. */
  87481. getTimeStep(): number;
  87482. /**
  87483. * Release all resources
  87484. */
  87485. dispose(): void;
  87486. /**
  87487. * Gets the name of the current physics plugin
  87488. * @returns the name of the plugin
  87489. */
  87490. getPhysicsPluginName(): string;
  87491. /**
  87492. * Adding a new impostor for the impostor tracking.
  87493. * This will be done by the impostor itself.
  87494. * @param impostor the impostor to add
  87495. */
  87496. addImpostor(impostor: PhysicsImpostor): void;
  87497. /**
  87498. * Remove an impostor from the engine.
  87499. * This impostor and its mesh will not longer be updated by the physics engine.
  87500. * @param impostor the impostor to remove
  87501. */
  87502. removeImpostor(impostor: PhysicsImpostor): void;
  87503. /**
  87504. * Add a joint to the physics engine
  87505. * @param mainImpostor defines the main impostor to which the joint is added.
  87506. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87507. * @param joint defines the joint that will connect both impostors.
  87508. */
  87509. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87510. /**
  87511. * Removes a joint from the simulation
  87512. * @param mainImpostor defines the impostor used with the joint
  87513. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87514. * @param joint defines the joint to remove
  87515. */
  87516. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87517. /**
  87518. * Gets the current plugin used to run the simulation
  87519. * @returns current plugin
  87520. */
  87521. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87522. /**
  87523. * Gets the list of physic impostors
  87524. * @returns an array of PhysicsImpostor
  87525. */
  87526. getImpostors(): Array<PhysicsImpostor>;
  87527. /**
  87528. * Gets the impostor for a physics enabled object
  87529. * @param object defines the object impersonated by the impostor
  87530. * @returns the PhysicsImpostor or null if not found
  87531. */
  87532. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87533. /**
  87534. * Gets the impostor for a physics body object
  87535. * @param body defines physics body used by the impostor
  87536. * @returns the PhysicsImpostor or null if not found
  87537. */
  87538. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87539. /**
  87540. * Does a raycast in the physics world
  87541. * @param from when should the ray start?
  87542. * @param to when should the ray end?
  87543. * @returns PhysicsRaycastResult
  87544. */
  87545. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87546. /**
  87547. * Called by the scene. No need to call it.
  87548. * @param delta defines the timespam between frames
  87549. */
  87550. _step(delta: number): void;
  87551. }
  87552. }
  87553. declare module BABYLON {
  87554. /**
  87555. * The interface for the physics imposter parameters
  87556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87557. */
  87558. export interface PhysicsImpostorParameters {
  87559. /**
  87560. * The mass of the physics imposter
  87561. */
  87562. mass: number;
  87563. /**
  87564. * The friction of the physics imposter
  87565. */
  87566. friction?: number;
  87567. /**
  87568. * The coefficient of restitution of the physics imposter
  87569. */
  87570. restitution?: number;
  87571. /**
  87572. * The native options of the physics imposter
  87573. */
  87574. nativeOptions?: any;
  87575. /**
  87576. * Specifies if the parent should be ignored
  87577. */
  87578. ignoreParent?: boolean;
  87579. /**
  87580. * Specifies if bi-directional transformations should be disabled
  87581. */
  87582. disableBidirectionalTransformation?: boolean;
  87583. /**
  87584. * The pressure inside the physics imposter, soft object only
  87585. */
  87586. pressure?: number;
  87587. /**
  87588. * The stiffness the physics imposter, soft object only
  87589. */
  87590. stiffness?: number;
  87591. /**
  87592. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87593. */
  87594. velocityIterations?: number;
  87595. /**
  87596. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87597. */
  87598. positionIterations?: number;
  87599. /**
  87600. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87601. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87602. * Add to fix multiple points
  87603. */
  87604. fixedPoints?: number;
  87605. /**
  87606. * The collision margin around a soft object
  87607. */
  87608. margin?: number;
  87609. /**
  87610. * The collision margin around a soft object
  87611. */
  87612. damping?: number;
  87613. /**
  87614. * The path for a rope based on an extrusion
  87615. */
  87616. path?: any;
  87617. /**
  87618. * The shape of an extrusion used for a rope based on an extrusion
  87619. */
  87620. shape?: any;
  87621. }
  87622. /**
  87623. * Interface for a physics-enabled object
  87624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87625. */
  87626. export interface IPhysicsEnabledObject {
  87627. /**
  87628. * The position of the physics-enabled object
  87629. */
  87630. position: Vector3;
  87631. /**
  87632. * The rotation of the physics-enabled object
  87633. */
  87634. rotationQuaternion: Nullable<Quaternion>;
  87635. /**
  87636. * The scale of the physics-enabled object
  87637. */
  87638. scaling: Vector3;
  87639. /**
  87640. * The rotation of the physics-enabled object
  87641. */
  87642. rotation?: Vector3;
  87643. /**
  87644. * The parent of the physics-enabled object
  87645. */
  87646. parent?: any;
  87647. /**
  87648. * The bounding info of the physics-enabled object
  87649. * @returns The bounding info of the physics-enabled object
  87650. */
  87651. getBoundingInfo(): BoundingInfo;
  87652. /**
  87653. * Computes the world matrix
  87654. * @param force Specifies if the world matrix should be computed by force
  87655. * @returns A world matrix
  87656. */
  87657. computeWorldMatrix(force: boolean): Matrix;
  87658. /**
  87659. * Gets the world matrix
  87660. * @returns A world matrix
  87661. */
  87662. getWorldMatrix?(): Matrix;
  87663. /**
  87664. * Gets the child meshes
  87665. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87666. * @returns An array of abstract meshes
  87667. */
  87668. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87669. /**
  87670. * Gets the vertex data
  87671. * @param kind The type of vertex data
  87672. * @returns A nullable array of numbers, or a float32 array
  87673. */
  87674. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87675. /**
  87676. * Gets the indices from the mesh
  87677. * @returns A nullable array of index arrays
  87678. */
  87679. getIndices?(): Nullable<IndicesArray>;
  87680. /**
  87681. * Gets the scene from the mesh
  87682. * @returns the indices array or null
  87683. */
  87684. getScene?(): Scene;
  87685. /**
  87686. * Gets the absolute position from the mesh
  87687. * @returns the absolute position
  87688. */
  87689. getAbsolutePosition(): Vector3;
  87690. /**
  87691. * Gets the absolute pivot point from the mesh
  87692. * @returns the absolute pivot point
  87693. */
  87694. getAbsolutePivotPoint(): Vector3;
  87695. /**
  87696. * Rotates the mesh
  87697. * @param axis The axis of rotation
  87698. * @param amount The amount of rotation
  87699. * @param space The space of the rotation
  87700. * @returns The rotation transform node
  87701. */
  87702. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87703. /**
  87704. * Translates the mesh
  87705. * @param axis The axis of translation
  87706. * @param distance The distance of translation
  87707. * @param space The space of the translation
  87708. * @returns The transform node
  87709. */
  87710. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87711. /**
  87712. * Sets the absolute position of the mesh
  87713. * @param absolutePosition The absolute position of the mesh
  87714. * @returns The transform node
  87715. */
  87716. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87717. /**
  87718. * Gets the class name of the mesh
  87719. * @returns The class name
  87720. */
  87721. getClassName(): string;
  87722. }
  87723. /**
  87724. * Represents a physics imposter
  87725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87726. */
  87727. export class PhysicsImpostor {
  87728. /**
  87729. * The physics-enabled object used as the physics imposter
  87730. */
  87731. object: IPhysicsEnabledObject;
  87732. /**
  87733. * The type of the physics imposter
  87734. */
  87735. type: number;
  87736. private _options;
  87737. private _scene?;
  87738. /**
  87739. * The default object size of the imposter
  87740. */
  87741. static DEFAULT_OBJECT_SIZE: Vector3;
  87742. /**
  87743. * The identity quaternion of the imposter
  87744. */
  87745. static IDENTITY_QUATERNION: Quaternion;
  87746. /** @hidden */
  87747. _pluginData: any;
  87748. private _physicsEngine;
  87749. private _physicsBody;
  87750. private _bodyUpdateRequired;
  87751. private _onBeforePhysicsStepCallbacks;
  87752. private _onAfterPhysicsStepCallbacks;
  87753. /** @hidden */
  87754. _onPhysicsCollideCallbacks: Array<{
  87755. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87756. otherImpostors: Array<PhysicsImpostor>;
  87757. }>;
  87758. private _deltaPosition;
  87759. private _deltaRotation;
  87760. private _deltaRotationConjugated;
  87761. /** @hidden */
  87762. _isFromLine: boolean;
  87763. private _parent;
  87764. private _isDisposed;
  87765. private static _tmpVecs;
  87766. private static _tmpQuat;
  87767. /**
  87768. * Specifies if the physics imposter is disposed
  87769. */
  87770. readonly isDisposed: boolean;
  87771. /**
  87772. * Gets the mass of the physics imposter
  87773. */
  87774. mass: number;
  87775. /**
  87776. * Gets the coefficient of friction
  87777. */
  87778. /**
  87779. * Sets the coefficient of friction
  87780. */
  87781. friction: number;
  87782. /**
  87783. * Gets the coefficient of restitution
  87784. */
  87785. /**
  87786. * Sets the coefficient of restitution
  87787. */
  87788. restitution: number;
  87789. /**
  87790. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87791. */
  87792. /**
  87793. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87794. */
  87795. pressure: number;
  87796. /**
  87797. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87798. */
  87799. /**
  87800. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87801. */
  87802. stiffness: number;
  87803. /**
  87804. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87805. */
  87806. /**
  87807. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87808. */
  87809. velocityIterations: number;
  87810. /**
  87811. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87812. */
  87813. /**
  87814. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87815. */
  87816. positionIterations: number;
  87817. /**
  87818. * The unique id of the physics imposter
  87819. * set by the physics engine when adding this impostor to the array
  87820. */
  87821. uniqueId: number;
  87822. /**
  87823. * @hidden
  87824. */
  87825. soft: boolean;
  87826. /**
  87827. * @hidden
  87828. */
  87829. segments: number;
  87830. private _joints;
  87831. /**
  87832. * Initializes the physics imposter
  87833. * @param object The physics-enabled object used as the physics imposter
  87834. * @param type The type of the physics imposter
  87835. * @param _options The options for the physics imposter
  87836. * @param _scene The Babylon scene
  87837. */
  87838. constructor(
  87839. /**
  87840. * The physics-enabled object used as the physics imposter
  87841. */
  87842. object: IPhysicsEnabledObject,
  87843. /**
  87844. * The type of the physics imposter
  87845. */
  87846. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87847. /**
  87848. * This function will completly initialize this impostor.
  87849. * It will create a new body - but only if this mesh has no parent.
  87850. * If it has, this impostor will not be used other than to define the impostor
  87851. * of the child mesh.
  87852. * @hidden
  87853. */
  87854. _init(): void;
  87855. private _getPhysicsParent;
  87856. /**
  87857. * Should a new body be generated.
  87858. * @returns boolean specifying if body initialization is required
  87859. */
  87860. isBodyInitRequired(): boolean;
  87861. /**
  87862. * Sets the updated scaling
  87863. * @param updated Specifies if the scaling is updated
  87864. */
  87865. setScalingUpdated(): void;
  87866. /**
  87867. * Force a regeneration of this or the parent's impostor's body.
  87868. * Use under cautious - This will remove all joints already implemented.
  87869. */
  87870. forceUpdate(): void;
  87871. /**
  87872. * Gets the body that holds this impostor. Either its own, or its parent.
  87873. */
  87874. /**
  87875. * Set the physics body. Used mainly by the physics engine/plugin
  87876. */
  87877. physicsBody: any;
  87878. /**
  87879. * Get the parent of the physics imposter
  87880. * @returns Physics imposter or null
  87881. */
  87882. /**
  87883. * Sets the parent of the physics imposter
  87884. */
  87885. parent: Nullable<PhysicsImpostor>;
  87886. /**
  87887. * Resets the update flags
  87888. */
  87889. resetUpdateFlags(): void;
  87890. /**
  87891. * Gets the object extend size
  87892. * @returns the object extend size
  87893. */
  87894. getObjectExtendSize(): Vector3;
  87895. /**
  87896. * Gets the object center
  87897. * @returns The object center
  87898. */
  87899. getObjectCenter(): Vector3;
  87900. /**
  87901. * Get a specific parametes from the options parameter
  87902. * @param paramName The object parameter name
  87903. * @returns The object parameter
  87904. */
  87905. getParam(paramName: string): any;
  87906. /**
  87907. * Sets a specific parameter in the options given to the physics plugin
  87908. * @param paramName The parameter name
  87909. * @param value The value of the parameter
  87910. */
  87911. setParam(paramName: string, value: number): void;
  87912. /**
  87913. * Specifically change the body's mass option. Won't recreate the physics body object
  87914. * @param mass The mass of the physics imposter
  87915. */
  87916. setMass(mass: number): void;
  87917. /**
  87918. * Gets the linear velocity
  87919. * @returns linear velocity or null
  87920. */
  87921. getLinearVelocity(): Nullable<Vector3>;
  87922. /**
  87923. * Sets the linear velocity
  87924. * @param velocity linear velocity or null
  87925. */
  87926. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87927. /**
  87928. * Gets the angular velocity
  87929. * @returns angular velocity or null
  87930. */
  87931. getAngularVelocity(): Nullable<Vector3>;
  87932. /**
  87933. * Sets the angular velocity
  87934. * @param velocity The velocity or null
  87935. */
  87936. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87937. /**
  87938. * Execute a function with the physics plugin native code
  87939. * Provide a function the will have two variables - the world object and the physics body object
  87940. * @param func The function to execute with the physics plugin native code
  87941. */
  87942. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87943. /**
  87944. * Register a function that will be executed before the physics world is stepping forward
  87945. * @param func The function to execute before the physics world is stepped forward
  87946. */
  87947. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87948. /**
  87949. * Unregister a function that will be executed before the physics world is stepping forward
  87950. * @param func The function to execute before the physics world is stepped forward
  87951. */
  87952. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87953. /**
  87954. * Register a function that will be executed after the physics step
  87955. * @param func The function to execute after physics step
  87956. */
  87957. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87958. /**
  87959. * Unregisters a function that will be executed after the physics step
  87960. * @param func The function to execute after physics step
  87961. */
  87962. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87963. /**
  87964. * register a function that will be executed when this impostor collides against a different body
  87965. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87966. * @param func Callback that is executed on collision
  87967. */
  87968. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87969. /**
  87970. * Unregisters the physics imposter on contact
  87971. * @param collideAgainst The physics object to collide against
  87972. * @param func Callback to execute on collision
  87973. */
  87974. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87975. private _tmpQuat;
  87976. private _tmpQuat2;
  87977. /**
  87978. * Get the parent rotation
  87979. * @returns The parent rotation
  87980. */
  87981. getParentsRotation(): Quaternion;
  87982. /**
  87983. * this function is executed by the physics engine.
  87984. */
  87985. beforeStep: () => void;
  87986. /**
  87987. * this function is executed by the physics engine
  87988. */
  87989. afterStep: () => void;
  87990. /**
  87991. * Legacy collision detection event support
  87992. */
  87993. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87994. /**
  87995. * event and body object due to cannon's event-based architecture.
  87996. */
  87997. onCollide: (e: {
  87998. body: any;
  87999. }) => void;
  88000. /**
  88001. * Apply a force
  88002. * @param force The force to apply
  88003. * @param contactPoint The contact point for the force
  88004. * @returns The physics imposter
  88005. */
  88006. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88007. /**
  88008. * Apply an impulse
  88009. * @param force The impulse force
  88010. * @param contactPoint The contact point for the impulse force
  88011. * @returns The physics imposter
  88012. */
  88013. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88014. /**
  88015. * A help function to create a joint
  88016. * @param otherImpostor A physics imposter used to create a joint
  88017. * @param jointType The type of joint
  88018. * @param jointData The data for the joint
  88019. * @returns The physics imposter
  88020. */
  88021. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88022. /**
  88023. * Add a joint to this impostor with a different impostor
  88024. * @param otherImpostor A physics imposter used to add a joint
  88025. * @param joint The joint to add
  88026. * @returns The physics imposter
  88027. */
  88028. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88029. /**
  88030. * Add an anchor to a cloth impostor
  88031. * @param otherImpostor rigid impostor to anchor to
  88032. * @param width ratio across width from 0 to 1
  88033. * @param height ratio up height from 0 to 1
  88034. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88035. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88036. * @returns impostor the soft imposter
  88037. */
  88038. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88039. /**
  88040. * Add a hook to a rope impostor
  88041. * @param otherImpostor rigid impostor to anchor to
  88042. * @param length ratio across rope from 0 to 1
  88043. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88044. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88045. * @returns impostor the rope imposter
  88046. */
  88047. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88048. /**
  88049. * Will keep this body still, in a sleep mode.
  88050. * @returns the physics imposter
  88051. */
  88052. sleep(): PhysicsImpostor;
  88053. /**
  88054. * Wake the body up.
  88055. * @returns The physics imposter
  88056. */
  88057. wakeUp(): PhysicsImpostor;
  88058. /**
  88059. * Clones the physics imposter
  88060. * @param newObject The physics imposter clones to this physics-enabled object
  88061. * @returns A nullable physics imposter
  88062. */
  88063. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88064. /**
  88065. * Disposes the physics imposter
  88066. */
  88067. dispose(): void;
  88068. /**
  88069. * Sets the delta position
  88070. * @param position The delta position amount
  88071. */
  88072. setDeltaPosition(position: Vector3): void;
  88073. /**
  88074. * Sets the delta rotation
  88075. * @param rotation The delta rotation amount
  88076. */
  88077. setDeltaRotation(rotation: Quaternion): void;
  88078. /**
  88079. * Gets the box size of the physics imposter and stores the result in the input parameter
  88080. * @param result Stores the box size
  88081. * @returns The physics imposter
  88082. */
  88083. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88084. /**
  88085. * Gets the radius of the physics imposter
  88086. * @returns Radius of the physics imposter
  88087. */
  88088. getRadius(): number;
  88089. /**
  88090. * Sync a bone with this impostor
  88091. * @param bone The bone to sync to the impostor.
  88092. * @param boneMesh The mesh that the bone is influencing.
  88093. * @param jointPivot The pivot of the joint / bone in local space.
  88094. * @param distToJoint Optional distance from the impostor to the joint.
  88095. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88096. */
  88097. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88098. /**
  88099. * Sync impostor to a bone
  88100. * @param bone The bone that the impostor will be synced to.
  88101. * @param boneMesh The mesh that the bone is influencing.
  88102. * @param jointPivot The pivot of the joint / bone in local space.
  88103. * @param distToJoint Optional distance from the impostor to the joint.
  88104. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88105. * @param boneAxis Optional vector3 axis the bone is aligned with
  88106. */
  88107. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88108. /**
  88109. * No-Imposter type
  88110. */
  88111. static NoImpostor: number;
  88112. /**
  88113. * Sphere-Imposter type
  88114. */
  88115. static SphereImpostor: number;
  88116. /**
  88117. * Box-Imposter type
  88118. */
  88119. static BoxImpostor: number;
  88120. /**
  88121. * Plane-Imposter type
  88122. */
  88123. static PlaneImpostor: number;
  88124. /**
  88125. * Mesh-imposter type
  88126. */
  88127. static MeshImpostor: number;
  88128. /**
  88129. * Capsule-Impostor type (Ammo.js plugin only)
  88130. */
  88131. static CapsuleImpostor: number;
  88132. /**
  88133. * Cylinder-Imposter type
  88134. */
  88135. static CylinderImpostor: number;
  88136. /**
  88137. * Particle-Imposter type
  88138. */
  88139. static ParticleImpostor: number;
  88140. /**
  88141. * Heightmap-Imposter type
  88142. */
  88143. static HeightmapImpostor: number;
  88144. /**
  88145. * ConvexHull-Impostor type (Ammo.js plugin only)
  88146. */
  88147. static ConvexHullImpostor: number;
  88148. /**
  88149. * Rope-Imposter type
  88150. */
  88151. static RopeImpostor: number;
  88152. /**
  88153. * Cloth-Imposter type
  88154. */
  88155. static ClothImpostor: number;
  88156. /**
  88157. * Softbody-Imposter type
  88158. */
  88159. static SoftbodyImpostor: number;
  88160. }
  88161. }
  88162. declare module BABYLON {
  88163. /**
  88164. * @hidden
  88165. **/
  88166. export class _CreationDataStorage {
  88167. closePath?: boolean;
  88168. closeArray?: boolean;
  88169. idx: number[];
  88170. dashSize: number;
  88171. gapSize: number;
  88172. path3D: Path3D;
  88173. pathArray: Vector3[][];
  88174. arc: number;
  88175. radius: number;
  88176. cap: number;
  88177. tessellation: number;
  88178. }
  88179. /**
  88180. * @hidden
  88181. **/
  88182. class _InstanceDataStorage {
  88183. visibleInstances: any;
  88184. batchCache: _InstancesBatch;
  88185. instancesBufferSize: number;
  88186. instancesBuffer: Nullable<Buffer>;
  88187. instancesData: Float32Array;
  88188. overridenInstanceCount: number;
  88189. isFrozen: boolean;
  88190. previousBatch: Nullable<_InstancesBatch>;
  88191. hardwareInstancedRendering: boolean;
  88192. sideOrientation: number;
  88193. }
  88194. /**
  88195. * @hidden
  88196. **/
  88197. export class _InstancesBatch {
  88198. mustReturn: boolean;
  88199. visibleInstances: Nullable<InstancedMesh[]>[];
  88200. renderSelf: boolean[];
  88201. hardwareInstancedRendering: boolean[];
  88202. }
  88203. /**
  88204. * Class used to represent renderable models
  88205. */
  88206. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88207. /**
  88208. * Mesh side orientation : usually the external or front surface
  88209. */
  88210. static readonly FRONTSIDE: number;
  88211. /**
  88212. * Mesh side orientation : usually the internal or back surface
  88213. */
  88214. static readonly BACKSIDE: number;
  88215. /**
  88216. * Mesh side orientation : both internal and external or front and back surfaces
  88217. */
  88218. static readonly DOUBLESIDE: number;
  88219. /**
  88220. * Mesh side orientation : by default, `FRONTSIDE`
  88221. */
  88222. static readonly DEFAULTSIDE: number;
  88223. /**
  88224. * Mesh cap setting : no cap
  88225. */
  88226. static readonly NO_CAP: number;
  88227. /**
  88228. * Mesh cap setting : one cap at the beginning of the mesh
  88229. */
  88230. static readonly CAP_START: number;
  88231. /**
  88232. * Mesh cap setting : one cap at the end of the mesh
  88233. */
  88234. static readonly CAP_END: number;
  88235. /**
  88236. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88237. */
  88238. static readonly CAP_ALL: number;
  88239. /**
  88240. * Mesh pattern setting : no flip or rotate
  88241. */
  88242. static readonly NO_FLIP: number;
  88243. /**
  88244. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88245. */
  88246. static readonly FLIP_TILE: number;
  88247. /**
  88248. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88249. */
  88250. static readonly ROTATE_TILE: number;
  88251. /**
  88252. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88253. */
  88254. static readonly FLIP_ROW: number;
  88255. /**
  88256. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88257. */
  88258. static readonly ROTATE_ROW: number;
  88259. /**
  88260. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88261. */
  88262. static readonly FLIP_N_ROTATE_TILE: number;
  88263. /**
  88264. * Mesh pattern setting : rotate pattern and rotate
  88265. */
  88266. static readonly FLIP_N_ROTATE_ROW: number;
  88267. /**
  88268. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88269. */
  88270. static readonly CENTER: number;
  88271. /**
  88272. * Mesh tile positioning : part tiles on left
  88273. */
  88274. static readonly LEFT: number;
  88275. /**
  88276. * Mesh tile positioning : part tiles on right
  88277. */
  88278. static readonly RIGHT: number;
  88279. /**
  88280. * Mesh tile positioning : part tiles on top
  88281. */
  88282. static readonly TOP: number;
  88283. /**
  88284. * Mesh tile positioning : part tiles on bottom
  88285. */
  88286. static readonly BOTTOM: number;
  88287. /**
  88288. * Gets the default side orientation.
  88289. * @param orientation the orientation to value to attempt to get
  88290. * @returns the default orientation
  88291. * @hidden
  88292. */
  88293. static _GetDefaultSideOrientation(orientation?: number): number;
  88294. private _internalMeshDataInfo;
  88295. /**
  88296. * An event triggered before rendering the mesh
  88297. */
  88298. readonly onBeforeRenderObservable: Observable<Mesh>;
  88299. /**
  88300. * An event triggered before binding the mesh
  88301. */
  88302. readonly onBeforeBindObservable: Observable<Mesh>;
  88303. /**
  88304. * An event triggered after rendering the mesh
  88305. */
  88306. readonly onAfterRenderObservable: Observable<Mesh>;
  88307. /**
  88308. * An event triggered before drawing the mesh
  88309. */
  88310. readonly onBeforeDrawObservable: Observable<Mesh>;
  88311. private _onBeforeDrawObserver;
  88312. /**
  88313. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88314. */
  88315. onBeforeDraw: () => void;
  88316. readonly hasInstances: boolean;
  88317. /**
  88318. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88319. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88320. */
  88321. delayLoadState: number;
  88322. /**
  88323. * Gets the list of instances created from this mesh
  88324. * it is not supposed to be modified manually.
  88325. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88326. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88327. */
  88328. instances: InstancedMesh[];
  88329. /**
  88330. * Gets the file containing delay loading data for this mesh
  88331. */
  88332. delayLoadingFile: string;
  88333. /** @hidden */
  88334. _binaryInfo: any;
  88335. /**
  88336. * User defined function used to change how LOD level selection is done
  88337. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88338. */
  88339. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88340. /**
  88341. * Gets or sets the morph target manager
  88342. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88343. */
  88344. morphTargetManager: Nullable<MorphTargetManager>;
  88345. /** @hidden */
  88346. _creationDataStorage: Nullable<_CreationDataStorage>;
  88347. /** @hidden */
  88348. _geometry: Nullable<Geometry>;
  88349. /** @hidden */
  88350. _delayInfo: Array<string>;
  88351. /** @hidden */
  88352. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88353. /** @hidden */
  88354. _instanceDataStorage: _InstanceDataStorage;
  88355. private _effectiveMaterial;
  88356. /** @hidden */
  88357. _shouldGenerateFlatShading: boolean;
  88358. /** @hidden */
  88359. _originalBuilderSideOrientation: number;
  88360. /**
  88361. * Use this property to change the original side orientation defined at construction time
  88362. */
  88363. overrideMaterialSideOrientation: Nullable<number>;
  88364. /**
  88365. * Gets the source mesh (the one used to clone this one from)
  88366. */
  88367. readonly source: Nullable<Mesh>;
  88368. /**
  88369. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88370. */
  88371. isUnIndexed: boolean;
  88372. /**
  88373. * @constructor
  88374. * @param name The value used by scene.getMeshByName() to do a lookup.
  88375. * @param scene The scene to add this mesh to.
  88376. * @param parent The parent of this mesh, if it has one
  88377. * @param source An optional Mesh from which geometry is shared, cloned.
  88378. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88379. * When false, achieved by calling a clone(), also passing False.
  88380. * This will make creation of children, recursive.
  88381. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88382. */
  88383. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88384. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88385. /**
  88386. * Gets the class name
  88387. * @returns the string "Mesh".
  88388. */
  88389. getClassName(): string;
  88390. /** @hidden */
  88391. readonly _isMesh: boolean;
  88392. /**
  88393. * Returns a description of this mesh
  88394. * @param fullDetails define if full details about this mesh must be used
  88395. * @returns a descriptive string representing this mesh
  88396. */
  88397. toString(fullDetails?: boolean): string;
  88398. /** @hidden */
  88399. _unBindEffect(): void;
  88400. /**
  88401. * Gets a boolean indicating if this mesh has LOD
  88402. */
  88403. readonly hasLODLevels: boolean;
  88404. /**
  88405. * Gets the list of MeshLODLevel associated with the current mesh
  88406. * @returns an array of MeshLODLevel
  88407. */
  88408. getLODLevels(): MeshLODLevel[];
  88409. private _sortLODLevels;
  88410. /**
  88411. * Add a mesh as LOD level triggered at the given distance.
  88412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88413. * @param distance The distance from the center of the object to show this level
  88414. * @param mesh The mesh to be added as LOD level (can be null)
  88415. * @return This mesh (for chaining)
  88416. */
  88417. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  88418. /**
  88419. * Returns the LOD level mesh at the passed distance or null if not found.
  88420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88421. * @param distance The distance from the center of the object to show this level
  88422. * @returns a Mesh or `null`
  88423. */
  88424. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88425. /**
  88426. * Remove a mesh from the LOD array
  88427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88428. * @param mesh defines the mesh to be removed
  88429. * @return This mesh (for chaining)
  88430. */
  88431. removeLODLevel(mesh: Mesh): Mesh;
  88432. /**
  88433. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88435. * @param camera defines the camera to use to compute distance
  88436. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88437. * @return This mesh (for chaining)
  88438. */
  88439. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88440. /**
  88441. * Gets the mesh internal Geometry object
  88442. */
  88443. readonly geometry: Nullable<Geometry>;
  88444. /**
  88445. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88446. * @returns the total number of vertices
  88447. */
  88448. getTotalVertices(): number;
  88449. /**
  88450. * Returns the content of an associated vertex buffer
  88451. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88452. * - VertexBuffer.PositionKind
  88453. * - VertexBuffer.UVKind
  88454. * - VertexBuffer.UV2Kind
  88455. * - VertexBuffer.UV3Kind
  88456. * - VertexBuffer.UV4Kind
  88457. * - VertexBuffer.UV5Kind
  88458. * - VertexBuffer.UV6Kind
  88459. * - VertexBuffer.ColorKind
  88460. * - VertexBuffer.MatricesIndicesKind
  88461. * - VertexBuffer.MatricesIndicesExtraKind
  88462. * - VertexBuffer.MatricesWeightsKind
  88463. * - VertexBuffer.MatricesWeightsExtraKind
  88464. * @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
  88465. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88466. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88467. */
  88468. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88469. /**
  88470. * Returns the mesh VertexBuffer object from the requested `kind`
  88471. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88472. * - VertexBuffer.PositionKind
  88473. * - VertexBuffer.NormalKind
  88474. * - VertexBuffer.UVKind
  88475. * - VertexBuffer.UV2Kind
  88476. * - VertexBuffer.UV3Kind
  88477. * - VertexBuffer.UV4Kind
  88478. * - VertexBuffer.UV5Kind
  88479. * - VertexBuffer.UV6Kind
  88480. * - VertexBuffer.ColorKind
  88481. * - VertexBuffer.MatricesIndicesKind
  88482. * - VertexBuffer.MatricesIndicesExtraKind
  88483. * - VertexBuffer.MatricesWeightsKind
  88484. * - VertexBuffer.MatricesWeightsExtraKind
  88485. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88486. */
  88487. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88488. /**
  88489. * Tests if a specific vertex buffer is associated with this mesh
  88490. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88491. * - VertexBuffer.PositionKind
  88492. * - VertexBuffer.NormalKind
  88493. * - VertexBuffer.UVKind
  88494. * - VertexBuffer.UV2Kind
  88495. * - VertexBuffer.UV3Kind
  88496. * - VertexBuffer.UV4Kind
  88497. * - VertexBuffer.UV5Kind
  88498. * - VertexBuffer.UV6Kind
  88499. * - VertexBuffer.ColorKind
  88500. * - VertexBuffer.MatricesIndicesKind
  88501. * - VertexBuffer.MatricesIndicesExtraKind
  88502. * - VertexBuffer.MatricesWeightsKind
  88503. * - VertexBuffer.MatricesWeightsExtraKind
  88504. * @returns a boolean
  88505. */
  88506. isVerticesDataPresent(kind: string): boolean;
  88507. /**
  88508. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88509. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88510. * - VertexBuffer.PositionKind
  88511. * - VertexBuffer.UVKind
  88512. * - VertexBuffer.UV2Kind
  88513. * - VertexBuffer.UV3Kind
  88514. * - VertexBuffer.UV4Kind
  88515. * - VertexBuffer.UV5Kind
  88516. * - VertexBuffer.UV6Kind
  88517. * - VertexBuffer.ColorKind
  88518. * - VertexBuffer.MatricesIndicesKind
  88519. * - VertexBuffer.MatricesIndicesExtraKind
  88520. * - VertexBuffer.MatricesWeightsKind
  88521. * - VertexBuffer.MatricesWeightsExtraKind
  88522. * @returns a boolean
  88523. */
  88524. isVertexBufferUpdatable(kind: string): boolean;
  88525. /**
  88526. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88528. * - VertexBuffer.PositionKind
  88529. * - VertexBuffer.NormalKind
  88530. * - VertexBuffer.UVKind
  88531. * - VertexBuffer.UV2Kind
  88532. * - VertexBuffer.UV3Kind
  88533. * - VertexBuffer.UV4Kind
  88534. * - VertexBuffer.UV5Kind
  88535. * - VertexBuffer.UV6Kind
  88536. * - VertexBuffer.ColorKind
  88537. * - VertexBuffer.MatricesIndicesKind
  88538. * - VertexBuffer.MatricesIndicesExtraKind
  88539. * - VertexBuffer.MatricesWeightsKind
  88540. * - VertexBuffer.MatricesWeightsExtraKind
  88541. * @returns an array of strings
  88542. */
  88543. getVerticesDataKinds(): string[];
  88544. /**
  88545. * Returns a positive integer : the total number of indices in this mesh geometry.
  88546. * @returns the numner of indices or zero if the mesh has no geometry.
  88547. */
  88548. getTotalIndices(): number;
  88549. /**
  88550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88551. * @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.
  88552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88553. * @returns the indices array or an empty array if the mesh has no geometry
  88554. */
  88555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88556. readonly isBlocked: boolean;
  88557. /**
  88558. * Determine if the current mesh is ready to be rendered
  88559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88560. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88561. * @returns true if all associated assets are ready (material, textures, shaders)
  88562. */
  88563. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88564. /**
  88565. * 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.
  88566. */
  88567. readonly areNormalsFrozen: boolean;
  88568. /**
  88569. * 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.
  88570. * @returns the current mesh
  88571. */
  88572. freezeNormals(): Mesh;
  88573. /**
  88574. * 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
  88575. * @returns the current mesh
  88576. */
  88577. unfreezeNormals(): Mesh;
  88578. /**
  88579. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88580. */
  88581. overridenInstanceCount: number;
  88582. /** @hidden */
  88583. _preActivate(): Mesh;
  88584. /** @hidden */
  88585. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88586. /** @hidden */
  88587. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88588. /**
  88589. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88590. * This means the mesh underlying bounding box and sphere are recomputed.
  88591. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88592. * @returns the current mesh
  88593. */
  88594. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88595. /** @hidden */
  88596. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88597. /**
  88598. * This function will subdivide the mesh into multiple submeshes
  88599. * @param count defines the expected number of submeshes
  88600. */
  88601. subdivide(count: number): void;
  88602. /**
  88603. * Copy a FloatArray into a specific associated vertex buffer
  88604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88605. * - VertexBuffer.PositionKind
  88606. * - VertexBuffer.UVKind
  88607. * - VertexBuffer.UV2Kind
  88608. * - VertexBuffer.UV3Kind
  88609. * - VertexBuffer.UV4Kind
  88610. * - VertexBuffer.UV5Kind
  88611. * - VertexBuffer.UV6Kind
  88612. * - VertexBuffer.ColorKind
  88613. * - VertexBuffer.MatricesIndicesKind
  88614. * - VertexBuffer.MatricesIndicesExtraKind
  88615. * - VertexBuffer.MatricesWeightsKind
  88616. * - VertexBuffer.MatricesWeightsExtraKind
  88617. * @param data defines the data source
  88618. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88619. * @param stride defines the data stride size (can be null)
  88620. * @returns the current mesh
  88621. */
  88622. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88623. /**
  88624. * Flags an associated vertex buffer as updatable
  88625. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88626. * - VertexBuffer.PositionKind
  88627. * - VertexBuffer.UVKind
  88628. * - VertexBuffer.UV2Kind
  88629. * - VertexBuffer.UV3Kind
  88630. * - VertexBuffer.UV4Kind
  88631. * - VertexBuffer.UV5Kind
  88632. * - VertexBuffer.UV6Kind
  88633. * - VertexBuffer.ColorKind
  88634. * - VertexBuffer.MatricesIndicesKind
  88635. * - VertexBuffer.MatricesIndicesExtraKind
  88636. * - VertexBuffer.MatricesWeightsKind
  88637. * - VertexBuffer.MatricesWeightsExtraKind
  88638. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88639. */
  88640. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88641. /**
  88642. * Sets the mesh global Vertex Buffer
  88643. * @param buffer defines the buffer to use
  88644. * @returns the current mesh
  88645. */
  88646. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88647. /**
  88648. * Update a specific associated vertex buffer
  88649. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88650. * - VertexBuffer.PositionKind
  88651. * - VertexBuffer.UVKind
  88652. * - VertexBuffer.UV2Kind
  88653. * - VertexBuffer.UV3Kind
  88654. * - VertexBuffer.UV4Kind
  88655. * - VertexBuffer.UV5Kind
  88656. * - VertexBuffer.UV6Kind
  88657. * - VertexBuffer.ColorKind
  88658. * - VertexBuffer.MatricesIndicesKind
  88659. * - VertexBuffer.MatricesIndicesExtraKind
  88660. * - VertexBuffer.MatricesWeightsKind
  88661. * - VertexBuffer.MatricesWeightsExtraKind
  88662. * @param data defines the data source
  88663. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88664. * @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)
  88665. * @returns the current mesh
  88666. */
  88667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  88668. /**
  88669. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88670. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88671. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88672. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88673. * @returns the current mesh
  88674. */
  88675. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88676. /**
  88677. * Creates a un-shared specific occurence of the geometry for the mesh.
  88678. * @returns the current mesh
  88679. */
  88680. makeGeometryUnique(): Mesh;
  88681. /**
  88682. * Set the index buffer of this mesh
  88683. * @param indices defines the source data
  88684. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88685. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88686. * @returns the current mesh
  88687. */
  88688. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  88689. /**
  88690. * Update the current index buffer
  88691. * @param indices defines the source data
  88692. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88693. * @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)
  88694. * @returns the current mesh
  88695. */
  88696. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88697. /**
  88698. * Invert the geometry to move from a right handed system to a left handed one.
  88699. * @returns the current mesh
  88700. */
  88701. toLeftHanded(): Mesh;
  88702. /** @hidden */
  88703. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88704. /** @hidden */
  88705. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88706. /**
  88707. * Registers for this mesh a javascript function called just before the rendering process
  88708. * @param func defines the function to call before rendering this mesh
  88709. * @returns the current mesh
  88710. */
  88711. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88712. /**
  88713. * Disposes a previously registered javascript function called before the rendering
  88714. * @param func defines the function to remove
  88715. * @returns the current mesh
  88716. */
  88717. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88718. /**
  88719. * Registers for this mesh a javascript function called just after the rendering is complete
  88720. * @param func defines the function to call after rendering this mesh
  88721. * @returns the current mesh
  88722. */
  88723. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88724. /**
  88725. * Disposes a previously registered javascript function called after the rendering.
  88726. * @param func defines the function to remove
  88727. * @returns the current mesh
  88728. */
  88729. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88730. /** @hidden */
  88731. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88732. /** @hidden */
  88733. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88734. /** @hidden */
  88735. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88736. /** @hidden */
  88737. _rebuild(): void;
  88738. /** @hidden */
  88739. _freeze(): void;
  88740. /** @hidden */
  88741. _unFreeze(): void;
  88742. /**
  88743. * 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
  88744. * @param subMesh defines the subMesh to render
  88745. * @param enableAlphaMode defines if alpha mode can be changed
  88746. * @returns the current mesh
  88747. */
  88748. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88749. private _onBeforeDraw;
  88750. /**
  88751. * Renormalize the mesh and patch it up if there are no weights
  88752. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88753. * However in the case of zero weights then we set just a single influence to 1.
  88754. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88755. */
  88756. cleanMatrixWeights(): void;
  88757. private normalizeSkinFourWeights;
  88758. private normalizeSkinWeightsAndExtra;
  88759. /**
  88760. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88761. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88762. * the user know there was an issue with importing the mesh
  88763. * @returns a validation object with skinned, valid and report string
  88764. */
  88765. validateSkinning(): {
  88766. skinned: boolean;
  88767. valid: boolean;
  88768. report: string;
  88769. };
  88770. /** @hidden */
  88771. _checkDelayState(): Mesh;
  88772. private _queueLoad;
  88773. /**
  88774. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88775. * A mesh is in the frustum if its bounding box intersects the frustum
  88776. * @param frustumPlanes defines the frustum to test
  88777. * @returns true if the mesh is in the frustum planes
  88778. */
  88779. isInFrustum(frustumPlanes: Plane[]): boolean;
  88780. /**
  88781. * Sets the mesh material by the material or multiMaterial `id` property
  88782. * @param id is a string identifying the material or the multiMaterial
  88783. * @returns the current mesh
  88784. */
  88785. setMaterialByID(id: string): Mesh;
  88786. /**
  88787. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88788. * @returns an array of IAnimatable
  88789. */
  88790. getAnimatables(): IAnimatable[];
  88791. /**
  88792. * Modifies the mesh geometry according to the passed transformation matrix.
  88793. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88794. * The mesh normals are modified using the same transformation.
  88795. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88796. * @param transform defines the transform matrix to use
  88797. * @see http://doc.babylonjs.com/resources/baking_transformations
  88798. * @returns the current mesh
  88799. */
  88800. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88801. /**
  88802. * Modifies the mesh geometry according to its own current World Matrix.
  88803. * The mesh World Matrix is then reset.
  88804. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88805. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88806. * @see http://doc.babylonjs.com/resources/baking_transformations
  88807. * @returns the current mesh
  88808. */
  88809. bakeCurrentTransformIntoVertices(): Mesh;
  88810. /** @hidden */
  88811. readonly _positions: Nullable<Vector3[]>;
  88812. /** @hidden */
  88813. _resetPointsArrayCache(): Mesh;
  88814. /** @hidden */
  88815. _generatePointsArray(): boolean;
  88816. /**
  88817. * Returns a new Mesh object generated from the current mesh properties.
  88818. * This method must not get confused with createInstance()
  88819. * @param name is a string, the name given to the new mesh
  88820. * @param newParent can be any Node object (default `null`)
  88821. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88822. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88823. * @returns a new mesh
  88824. */
  88825. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  88826. /**
  88827. * Releases resources associated with this mesh.
  88828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88830. */
  88831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88832. /**
  88833. * Modifies the mesh geometry according to a displacement map.
  88834. * 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.
  88835. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88836. * @param url is a string, the URL from the image file is to be downloaded.
  88837. * @param minHeight is the lower limit of the displacement.
  88838. * @param maxHeight is the upper limit of the displacement.
  88839. * @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.
  88840. * @param uvOffset is an optional vector2 used to offset UV.
  88841. * @param uvScale is an optional vector2 used to scale UV.
  88842. * @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.
  88843. * @returns the Mesh.
  88844. */
  88845. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88846. /**
  88847. * Modifies the mesh geometry according to a displacementMap buffer.
  88848. * 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.
  88849. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88850. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88851. * @param heightMapWidth is the width of the buffer image.
  88852. * @param heightMapHeight is the height of the buffer image.
  88853. * @param minHeight is the lower limit of the displacement.
  88854. * @param maxHeight is the upper limit of the displacement.
  88855. * @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.
  88856. * @param uvOffset is an optional vector2 used to offset UV.
  88857. * @param uvScale is an optional vector2 used to scale UV.
  88858. * @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.
  88859. * @returns the Mesh.
  88860. */
  88861. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88862. /**
  88863. * Modify the mesh to get a flat shading rendering.
  88864. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88865. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88866. * @returns current mesh
  88867. */
  88868. convertToFlatShadedMesh(): Mesh;
  88869. /**
  88870. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88871. * In other words, more vertices, no more indices and a single bigger VBO.
  88872. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88873. * @returns current mesh
  88874. */
  88875. convertToUnIndexedMesh(): Mesh;
  88876. /**
  88877. * Inverses facet orientations.
  88878. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88879. * @param flipNormals will also inverts the normals
  88880. * @returns current mesh
  88881. */
  88882. flipFaces(flipNormals?: boolean): Mesh;
  88883. /**
  88884. * Increase the number of facets and hence vertices in a mesh
  88885. * Vertex normals are interpolated from existing vertex normals
  88886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88887. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88888. */
  88889. increaseVertices(numberPerEdge: number): void;
  88890. /**
  88891. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88892. * This will undo any application of covertToFlatShadedMesh
  88893. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88894. */
  88895. forceSharedVertices(): void;
  88896. /** @hidden */
  88897. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88898. /** @hidden */
  88899. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88900. /**
  88901. * Creates a new InstancedMesh object from the mesh model.
  88902. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88903. * @param name defines the name of the new instance
  88904. * @returns a new InstancedMesh
  88905. */
  88906. createInstance(name: string): InstancedMesh;
  88907. /**
  88908. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88909. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88910. * @returns the current mesh
  88911. */
  88912. synchronizeInstances(): Mesh;
  88913. /**
  88914. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88915. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88916. * This should be used together with the simplification to avoid disappearing triangles.
  88917. * @param successCallback an optional success callback to be called after the optimization finished.
  88918. * @returns the current mesh
  88919. */
  88920. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88921. /**
  88922. * Serialize current mesh
  88923. * @param serializationObject defines the object which will receive the serialization data
  88924. */
  88925. serialize(serializationObject: any): void;
  88926. /** @hidden */
  88927. _syncGeometryWithMorphTargetManager(): void;
  88928. /** @hidden */
  88929. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88930. /**
  88931. * Returns a new Mesh object parsed from the source provided.
  88932. * @param parsedMesh is the source
  88933. * @param scene defines the hosting scene
  88934. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88935. * @returns a new Mesh
  88936. */
  88937. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88938. /**
  88939. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88940. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88941. * @param name defines the name of the mesh to create
  88942. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88943. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88944. * @param closePath creates a seam between the first and the last points of each path of the path array
  88945. * @param offset is taken in account only if the `pathArray` is containing a single path
  88946. * @param scene defines the hosting scene
  88947. * @param updatable defines if the mesh must be flagged as updatable
  88948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88949. * @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)
  88950. * @returns a new Mesh
  88951. */
  88952. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88953. /**
  88954. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88955. * @param name defines the name of the mesh to create
  88956. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88957. * @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
  88958. * @param scene defines the hosting scene
  88959. * @param updatable defines if the mesh must be flagged as updatable
  88960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88961. * @returns a new Mesh
  88962. */
  88963. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88964. /**
  88965. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88966. * @param name defines the name of the mesh to create
  88967. * @param size sets the size (float) of each box side (default 1)
  88968. * @param scene defines the hosting scene
  88969. * @param updatable defines if the mesh must be flagged as updatable
  88970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88971. * @returns a new Mesh
  88972. */
  88973. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88974. /**
  88975. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88976. * @param name defines the name of the mesh to create
  88977. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88978. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88979. * @param scene defines the hosting scene
  88980. * @param updatable defines if the mesh must be flagged as updatable
  88981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88982. * @returns a new Mesh
  88983. */
  88984. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88985. /**
  88986. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88987. * @param name defines the name of the mesh to create
  88988. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88989. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88990. * @param scene defines the hosting scene
  88991. * @returns a new Mesh
  88992. */
  88993. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88994. /**
  88995. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88996. * @param name defines the name of the mesh to create
  88997. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88998. * @param diameterTop set the top cap diameter (floats, default 1)
  88999. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89000. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89001. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89002. * @param scene defines the hosting scene
  89003. * @param updatable defines if the mesh must be flagged as updatable
  89004. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89005. * @returns a new Mesh
  89006. */
  89007. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89008. /**
  89009. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89010. * @param name defines the name of the mesh to create
  89011. * @param diameter sets the diameter size (float) of the torus (default 1)
  89012. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89013. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89014. * @param scene defines the hosting scene
  89015. * @param updatable defines if the mesh must be flagged as updatable
  89016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89017. * @returns a new Mesh
  89018. */
  89019. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89020. /**
  89021. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89022. * @param name defines the name of the mesh to create
  89023. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89024. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89025. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89026. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89027. * @param p the number of windings on X axis (positive integers, default 2)
  89028. * @param q the number of windings on Y axis (positive integers, default 3)
  89029. * @param scene defines the hosting scene
  89030. * @param updatable defines if the mesh must be flagged as updatable
  89031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89032. * @returns a new Mesh
  89033. */
  89034. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89035. /**
  89036. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89037. * @param name defines the name of the mesh to create
  89038. * @param points is an array successive Vector3
  89039. * @param scene defines the hosting scene
  89040. * @param updatable defines if the mesh must be flagged as updatable
  89041. * @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).
  89042. * @returns a new Mesh
  89043. */
  89044. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89045. /**
  89046. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89047. * @param name defines the name of the mesh to create
  89048. * @param points is an array successive Vector3
  89049. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89050. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89051. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89052. * @param scene defines the hosting scene
  89053. * @param updatable defines if the mesh must be flagged as updatable
  89054. * @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)
  89055. * @returns a new Mesh
  89056. */
  89057. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89058. /**
  89059. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89060. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89061. * 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.
  89062. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89063. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89064. * Remember you can only change the shape positions, not their number when updating a polygon.
  89065. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89066. * @param name defines the name of the mesh to create
  89067. * @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
  89068. * @param scene defines the hosting scene
  89069. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89070. * @param updatable defines if the mesh must be flagged as updatable
  89071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89072. * @param earcutInjection can be used to inject your own earcut reference
  89073. * @returns a new Mesh
  89074. */
  89075. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89076. /**
  89077. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89079. * @param name defines the name of the mesh to create
  89080. * @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
  89081. * @param depth defines the height of extrusion
  89082. * @param scene defines the hosting scene
  89083. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89084. * @param updatable defines if the mesh must be flagged as updatable
  89085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89086. * @param earcutInjection can be used to inject your own earcut reference
  89087. * @returns a new Mesh
  89088. */
  89089. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89090. /**
  89091. * Creates an extruded shape mesh.
  89092. * 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
  89093. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89094. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89095. * @param name defines the name of the mesh to create
  89096. * @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
  89097. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89098. * @param scale is the value to scale the shape
  89099. * @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
  89100. * @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
  89101. * @param scene defines the hosting scene
  89102. * @param updatable defines if the mesh must be flagged as updatable
  89103. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89104. * @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)
  89105. * @returns a new Mesh
  89106. */
  89107. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89108. /**
  89109. * Creates an custom extruded shape mesh.
  89110. * The custom extrusion is a parametric shape.
  89111. * It has no predefined shape. Its final shape will depend on the input parameters.
  89112. * Please consider using the same method from the MeshBuilder class instead
  89113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89114. * @param name defines the name of the mesh to create
  89115. * @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
  89116. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89117. * @param scaleFunction is a custom Javascript function called on each path point
  89118. * @param rotationFunction is a custom Javascript function called on each path point
  89119. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89120. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89121. * @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
  89122. * @param scene defines the hosting scene
  89123. * @param updatable defines if the mesh must be flagged as updatable
  89124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89125. * @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)
  89126. * @returns a new Mesh
  89127. */
  89128. 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;
  89129. /**
  89130. * Creates lathe mesh.
  89131. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89132. * Please consider using the same method from the MeshBuilder class instead
  89133. * @param name defines the name of the mesh to create
  89134. * @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
  89135. * @param radius is the radius value of the lathe
  89136. * @param tessellation is the side number of the lathe.
  89137. * @param scene defines the hosting scene
  89138. * @param updatable defines if the mesh must be flagged as updatable
  89139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89140. * @returns a new Mesh
  89141. */
  89142. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89143. /**
  89144. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89145. * @param name defines the name of the mesh to create
  89146. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89147. * @param scene defines the hosting scene
  89148. * @param updatable defines if the mesh must be flagged as updatable
  89149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89150. * @returns a new Mesh
  89151. */
  89152. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89153. /**
  89154. * Creates a ground mesh.
  89155. * Please consider using the same method from the MeshBuilder class instead
  89156. * @param name defines the name of the mesh to create
  89157. * @param width set the width of the ground
  89158. * @param height set the height of the ground
  89159. * @param subdivisions sets the number of subdivisions per side
  89160. * @param scene defines the hosting scene
  89161. * @param updatable defines if the mesh must be flagged as updatable
  89162. * @returns a new Mesh
  89163. */
  89164. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89165. /**
  89166. * Creates a tiled ground mesh.
  89167. * Please consider using the same method from the MeshBuilder class instead
  89168. * @param name defines the name of the mesh to create
  89169. * @param xmin set the ground minimum X coordinate
  89170. * @param zmin set the ground minimum Y coordinate
  89171. * @param xmax set the ground maximum X coordinate
  89172. * @param zmax set the ground maximum Z coordinate
  89173. * @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
  89174. * @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
  89175. * @param scene defines the hosting scene
  89176. * @param updatable defines if the mesh must be flagged as updatable
  89177. * @returns a new Mesh
  89178. */
  89179. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89180. w: number;
  89181. h: number;
  89182. }, precision: {
  89183. w: number;
  89184. h: number;
  89185. }, scene: Scene, updatable?: boolean): Mesh;
  89186. /**
  89187. * Creates a ground mesh from a height map.
  89188. * Please consider using the same method from the MeshBuilder class instead
  89189. * @see http://doc.babylonjs.com/babylon101/height_map
  89190. * @param name defines the name of the mesh to create
  89191. * @param url sets the URL of the height map image resource
  89192. * @param width set the ground width size
  89193. * @param height set the ground height size
  89194. * @param subdivisions sets the number of subdivision per side
  89195. * @param minHeight is the minimum altitude on the ground
  89196. * @param maxHeight is the maximum altitude on the ground
  89197. * @param scene defines the hosting scene
  89198. * @param updatable defines if the mesh must be flagged as updatable
  89199. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89200. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89201. * @returns a new Mesh
  89202. */
  89203. 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;
  89204. /**
  89205. * Creates a tube mesh.
  89206. * The tube is a parametric shape.
  89207. * It has no predefined shape. Its final shape will depend on the input parameters.
  89208. * Please consider using the same method from the MeshBuilder class instead
  89209. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89210. * @param name defines the name of the mesh to create
  89211. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89212. * @param radius sets the tube radius size
  89213. * @param tessellation is the number of sides on the tubular surface
  89214. * @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
  89215. * @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
  89216. * @param scene defines the hosting scene
  89217. * @param updatable defines if the mesh must be flagged as updatable
  89218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89219. * @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)
  89220. * @returns a new Mesh
  89221. */
  89222. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89223. (i: number, distance: number): number;
  89224. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89225. /**
  89226. * Creates a polyhedron mesh.
  89227. * Please consider using the same method from the MeshBuilder class instead.
  89228. * * 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
  89229. * * The parameter `size` (positive float, default 1) sets the polygon size
  89230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89231. * * 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`
  89232. * * 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
  89233. * * 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)`)
  89234. * * 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
  89235. * * 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
  89236. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89237. * * If you create a double-sided mesh, you can choose what parts of 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
  89238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89239. * @param name defines the name of the mesh to create
  89240. * @param options defines the options used to create the mesh
  89241. * @param scene defines the hosting scene
  89242. * @returns a new Mesh
  89243. */
  89244. static CreatePolyhedron(name: string, options: {
  89245. type?: number;
  89246. size?: number;
  89247. sizeX?: number;
  89248. sizeY?: number;
  89249. sizeZ?: number;
  89250. custom?: any;
  89251. faceUV?: Vector4[];
  89252. faceColors?: Color4[];
  89253. updatable?: boolean;
  89254. sideOrientation?: number;
  89255. }, scene: Scene): Mesh;
  89256. /**
  89257. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89258. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89259. * * 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`)
  89260. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89261. * * 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
  89262. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89263. * * If you create a double-sided mesh, you can choose what parts of 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
  89264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89265. * @param name defines the name of the mesh
  89266. * @param options defines the options used to create the mesh
  89267. * @param scene defines the hosting scene
  89268. * @returns a new Mesh
  89269. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89270. */
  89271. static CreateIcoSphere(name: string, options: {
  89272. radius?: number;
  89273. flat?: boolean;
  89274. subdivisions?: number;
  89275. sideOrientation?: number;
  89276. updatable?: boolean;
  89277. }, scene: Scene): Mesh;
  89278. /**
  89279. * Creates a decal mesh.
  89280. * Please consider using the same method from the MeshBuilder class instead.
  89281. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89282. * @param name defines the name of the mesh
  89283. * @param sourceMesh defines the mesh receiving the decal
  89284. * @param position sets the position of the decal in world coordinates
  89285. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89286. * @param size sets the decal scaling
  89287. * @param angle sets the angle to rotate the decal
  89288. * @returns a new Mesh
  89289. */
  89290. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89291. /**
  89292. * Prepare internal position array for software CPU skinning
  89293. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89294. */
  89295. setPositionsForCPUSkinning(): Float32Array;
  89296. /**
  89297. * Prepare internal normal array for software CPU skinning
  89298. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89299. */
  89300. setNormalsForCPUSkinning(): Float32Array;
  89301. /**
  89302. * Updates the vertex buffer by applying transformation from the bones
  89303. * @param skeleton defines the skeleton to apply to current mesh
  89304. * @returns the current mesh
  89305. */
  89306. applySkeleton(skeleton: Skeleton): Mesh;
  89307. /**
  89308. * 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
  89309. * @param meshes defines the list of meshes to scan
  89310. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89311. */
  89312. static MinMax(meshes: AbstractMesh[]): {
  89313. min: Vector3;
  89314. max: Vector3;
  89315. };
  89316. /**
  89317. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89318. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89319. * @returns a vector3
  89320. */
  89321. static Center(meshesOrMinMaxVector: {
  89322. min: Vector3;
  89323. max: Vector3;
  89324. } | AbstractMesh[]): Vector3;
  89325. /**
  89326. * Merge the array of meshes into a single mesh for performance reasons.
  89327. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89328. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89329. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89330. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89331. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89332. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89333. * @returns a new mesh
  89334. */
  89335. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89336. /** @hidden */
  89337. addInstance(instance: InstancedMesh): void;
  89338. /** @hidden */
  89339. removeInstance(instance: InstancedMesh): void;
  89340. }
  89341. }
  89342. declare module BABYLON {
  89343. /**
  89344. * This is the base class of all the camera used in the application.
  89345. * @see http://doc.babylonjs.com/features/cameras
  89346. */
  89347. export class Camera extends Node {
  89348. /** @hidden */
  89349. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89350. /**
  89351. * This is the default projection mode used by the cameras.
  89352. * It helps recreating a feeling of perspective and better appreciate depth.
  89353. * This is the best way to simulate real life cameras.
  89354. */
  89355. static readonly PERSPECTIVE_CAMERA: number;
  89356. /**
  89357. * This helps creating camera with an orthographic mode.
  89358. * 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.
  89359. */
  89360. static readonly ORTHOGRAPHIC_CAMERA: number;
  89361. /**
  89362. * This is the default FOV mode for perspective cameras.
  89363. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89364. */
  89365. static readonly FOVMODE_VERTICAL_FIXED: number;
  89366. /**
  89367. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89368. */
  89369. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89370. /**
  89371. * This specifies ther is no need for a camera rig.
  89372. * Basically only one eye is rendered corresponding to the camera.
  89373. */
  89374. static readonly RIG_MODE_NONE: number;
  89375. /**
  89376. * Simulates a camera Rig with one blue eye and one red eye.
  89377. * This can be use with 3d blue and red glasses.
  89378. */
  89379. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89380. /**
  89381. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89382. */
  89383. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89384. /**
  89385. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89386. */
  89387. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89388. /**
  89389. * Defines that both eyes of the camera will be rendered over under each other.
  89390. */
  89391. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89392. /**
  89393. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89394. */
  89395. static readonly RIG_MODE_VR: number;
  89396. /**
  89397. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89398. */
  89399. static readonly RIG_MODE_WEBVR: number;
  89400. /**
  89401. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89402. */
  89403. static readonly RIG_MODE_CUSTOM: number;
  89404. /**
  89405. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89406. */
  89407. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89408. /**
  89409. * Define the input manager associated with the camera.
  89410. */
  89411. inputs: CameraInputsManager<Camera>;
  89412. /** @hidden */
  89413. _position: Vector3;
  89414. /**
  89415. * Define the current local position of the camera in the scene
  89416. */
  89417. position: Vector3;
  89418. /**
  89419. * The vector the camera should consider as up.
  89420. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89421. */
  89422. upVector: Vector3;
  89423. /**
  89424. * Define the current limit on the left side for an orthographic camera
  89425. * In scene unit
  89426. */
  89427. orthoLeft: Nullable<number>;
  89428. /**
  89429. * Define the current limit on the right side for an orthographic camera
  89430. * In scene unit
  89431. */
  89432. orthoRight: Nullable<number>;
  89433. /**
  89434. * Define the current limit on the bottom side for an orthographic camera
  89435. * In scene unit
  89436. */
  89437. orthoBottom: Nullable<number>;
  89438. /**
  89439. * Define the current limit on the top side for an orthographic camera
  89440. * In scene unit
  89441. */
  89442. orthoTop: Nullable<number>;
  89443. /**
  89444. * Field Of View is set in Radians. (default is 0.8)
  89445. */
  89446. fov: number;
  89447. /**
  89448. * Define the minimum distance the camera can see from.
  89449. * This is important to note that the depth buffer are not infinite and the closer it starts
  89450. * the more your scene might encounter depth fighting issue.
  89451. */
  89452. minZ: number;
  89453. /**
  89454. * Define the maximum distance the camera can see to.
  89455. * This is important to note that the depth buffer are not infinite and the further it end
  89456. * the more your scene might encounter depth fighting issue.
  89457. */
  89458. maxZ: number;
  89459. /**
  89460. * Define the default inertia of the camera.
  89461. * This helps giving a smooth feeling to the camera movement.
  89462. */
  89463. inertia: number;
  89464. /**
  89465. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89466. */
  89467. mode: number;
  89468. /**
  89469. * Define wether the camera is intermediate.
  89470. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89471. */
  89472. isIntermediate: boolean;
  89473. /**
  89474. * Define the viewport of the camera.
  89475. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89476. */
  89477. viewport: Viewport;
  89478. /**
  89479. * Restricts the camera to viewing objects with the same layerMask.
  89480. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89481. */
  89482. layerMask: number;
  89483. /**
  89484. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89485. */
  89486. fovMode: number;
  89487. /**
  89488. * Rig mode of the camera.
  89489. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89490. * This is normally controlled byt the camera themselves as internal use.
  89491. */
  89492. cameraRigMode: number;
  89493. /**
  89494. * Defines the distance between both "eyes" in case of a RIG
  89495. */
  89496. interaxialDistance: number;
  89497. /**
  89498. * Defines if stereoscopic rendering is done side by side or over under.
  89499. */
  89500. isStereoscopicSideBySide: boolean;
  89501. /**
  89502. * 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
  89503. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89504. * else in the scene. (Eg. security camera)
  89505. *
  89506. * 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)
  89507. */
  89508. customRenderTargets: RenderTargetTexture[];
  89509. /**
  89510. * When set, the camera will render to this render target instead of the default canvas
  89511. *
  89512. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89513. */
  89514. outputRenderTarget: Nullable<RenderTargetTexture>;
  89515. /**
  89516. * Observable triggered when the camera view matrix has changed.
  89517. */
  89518. onViewMatrixChangedObservable: Observable<Camera>;
  89519. /**
  89520. * Observable triggered when the camera Projection matrix has changed.
  89521. */
  89522. onProjectionMatrixChangedObservable: Observable<Camera>;
  89523. /**
  89524. * Observable triggered when the inputs have been processed.
  89525. */
  89526. onAfterCheckInputsObservable: Observable<Camera>;
  89527. /**
  89528. * Observable triggered when reset has been called and applied to the camera.
  89529. */
  89530. onRestoreStateObservable: Observable<Camera>;
  89531. /** @hidden */
  89532. _cameraRigParams: any;
  89533. /** @hidden */
  89534. _rigCameras: Camera[];
  89535. /** @hidden */
  89536. _rigPostProcess: Nullable<PostProcess>;
  89537. protected _webvrViewMatrix: Matrix;
  89538. /** @hidden */
  89539. _skipRendering: boolean;
  89540. /** @hidden */
  89541. _projectionMatrix: Matrix;
  89542. /** @hidden */
  89543. _postProcesses: Nullable<PostProcess>[];
  89544. /** @hidden */
  89545. _activeMeshes: SmartArray<AbstractMesh>;
  89546. protected _globalPosition: Vector3;
  89547. /** @hidden */
  89548. _computedViewMatrix: Matrix;
  89549. private _doNotComputeProjectionMatrix;
  89550. private _transformMatrix;
  89551. private _frustumPlanes;
  89552. private _refreshFrustumPlanes;
  89553. private _storedFov;
  89554. private _stateStored;
  89555. /**
  89556. * Instantiates a new camera object.
  89557. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89558. * @see http://doc.babylonjs.com/features/cameras
  89559. * @param name Defines the name of the camera in the scene
  89560. * @param position Defines the position of the camera
  89561. * @param scene Defines the scene the camera belongs too
  89562. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89563. */
  89564. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89565. /**
  89566. * Store current camera state (fov, position, etc..)
  89567. * @returns the camera
  89568. */
  89569. storeState(): Camera;
  89570. /**
  89571. * Restores the camera state values if it has been stored. You must call storeState() first
  89572. */
  89573. protected _restoreStateValues(): boolean;
  89574. /**
  89575. * Restored camera state. You must call storeState() first.
  89576. * @returns true if restored and false otherwise
  89577. */
  89578. restoreState(): boolean;
  89579. /**
  89580. * Gets the class name of the camera.
  89581. * @returns the class name
  89582. */
  89583. getClassName(): string;
  89584. /** @hidden */
  89585. readonly _isCamera: boolean;
  89586. /**
  89587. * Gets a string representation of the camera useful for debug purpose.
  89588. * @param fullDetails Defines that a more verboe level of logging is required
  89589. * @returns the string representation
  89590. */
  89591. toString(fullDetails?: boolean): string;
  89592. /**
  89593. * Gets the current world space position of the camera.
  89594. */
  89595. readonly globalPosition: Vector3;
  89596. /**
  89597. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89598. * @returns the active meshe list
  89599. */
  89600. getActiveMeshes(): SmartArray<AbstractMesh>;
  89601. /**
  89602. * Check wether a mesh is part of the current active mesh list of the camera
  89603. * @param mesh Defines the mesh to check
  89604. * @returns true if active, false otherwise
  89605. */
  89606. isActiveMesh(mesh: Mesh): boolean;
  89607. /**
  89608. * Is this camera ready to be used/rendered
  89609. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89610. * @return true if the camera is ready
  89611. */
  89612. isReady(completeCheck?: boolean): boolean;
  89613. /** @hidden */
  89614. _initCache(): void;
  89615. /** @hidden */
  89616. _updateCache(ignoreParentClass?: boolean): void;
  89617. /** @hidden */
  89618. _isSynchronized(): boolean;
  89619. /** @hidden */
  89620. _isSynchronizedViewMatrix(): boolean;
  89621. /** @hidden */
  89622. _isSynchronizedProjectionMatrix(): boolean;
  89623. /**
  89624. * Attach the input controls to a specific dom element to get the input from.
  89625. * @param element Defines the element the controls should be listened from
  89626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89627. */
  89628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89629. /**
  89630. * Detach the current controls from the specified dom element.
  89631. * @param element Defines the element to stop listening the inputs from
  89632. */
  89633. detachControl(element: HTMLElement): void;
  89634. /**
  89635. * Update the camera state according to the different inputs gathered during the frame.
  89636. */
  89637. update(): void;
  89638. /** @hidden */
  89639. _checkInputs(): void;
  89640. /** @hidden */
  89641. readonly rigCameras: Camera[];
  89642. /**
  89643. * Gets the post process used by the rig cameras
  89644. */
  89645. readonly rigPostProcess: Nullable<PostProcess>;
  89646. /**
  89647. * Internal, gets the first post proces.
  89648. * @returns the first post process to be run on this camera.
  89649. */
  89650. _getFirstPostProcess(): Nullable<PostProcess>;
  89651. private _cascadePostProcessesToRigCams;
  89652. /**
  89653. * Attach a post process to the camera.
  89654. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89655. * @param postProcess The post process to attach to the camera
  89656. * @param insertAt The position of the post process in case several of them are in use in the scene
  89657. * @returns the position the post process has been inserted at
  89658. */
  89659. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89660. /**
  89661. * Detach a post process to the camera.
  89662. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89663. * @param postProcess The post process to detach from the camera
  89664. */
  89665. detachPostProcess(postProcess: PostProcess): void;
  89666. /**
  89667. * Gets the current world matrix of the camera
  89668. */
  89669. getWorldMatrix(): Matrix;
  89670. /** @hidden */
  89671. _getViewMatrix(): Matrix;
  89672. /**
  89673. * Gets the current view matrix of the camera.
  89674. * @param force forces the camera to recompute the matrix without looking at the cached state
  89675. * @returns the view matrix
  89676. */
  89677. getViewMatrix(force?: boolean): Matrix;
  89678. /**
  89679. * Freeze the projection matrix.
  89680. * It will prevent the cache check of the camera projection compute and can speed up perf
  89681. * if no parameter of the camera are meant to change
  89682. * @param projection Defines manually a projection if necessary
  89683. */
  89684. freezeProjectionMatrix(projection?: Matrix): void;
  89685. /**
  89686. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89687. */
  89688. unfreezeProjectionMatrix(): void;
  89689. /**
  89690. * Gets the current projection matrix of the camera.
  89691. * @param force forces the camera to recompute the matrix without looking at the cached state
  89692. * @returns the projection matrix
  89693. */
  89694. getProjectionMatrix(force?: boolean): Matrix;
  89695. /**
  89696. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89697. * @returns a Matrix
  89698. */
  89699. getTransformationMatrix(): Matrix;
  89700. private _updateFrustumPlanes;
  89701. /**
  89702. * Checks if a cullable object (mesh...) is in the camera frustum
  89703. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89704. * @param target The object to check
  89705. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89706. * @returns true if the object is in frustum otherwise false
  89707. */
  89708. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89709. /**
  89710. * Checks if a cullable object (mesh...) is in the camera frustum
  89711. * Unlike isInFrustum this cheks the full bounding box
  89712. * @param target The object to check
  89713. * @returns true if the object is in frustum otherwise false
  89714. */
  89715. isCompletelyInFrustum(target: ICullable): boolean;
  89716. /**
  89717. * Gets a ray in the forward direction from the camera.
  89718. * @param length Defines the length of the ray to create
  89719. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89720. * @param origin Defines the start point of the ray which defaults to the camera position
  89721. * @returns the forward ray
  89722. */
  89723. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89724. /**
  89725. * Releases resources associated with this node.
  89726. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89727. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89728. */
  89729. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89730. /** @hidden */
  89731. _isLeftCamera: boolean;
  89732. /**
  89733. * Gets the left camera of a rig setup in case of Rigged Camera
  89734. */
  89735. readonly isLeftCamera: boolean;
  89736. /** @hidden */
  89737. _isRightCamera: boolean;
  89738. /**
  89739. * Gets the right camera of a rig setup in case of Rigged Camera
  89740. */
  89741. readonly isRightCamera: boolean;
  89742. /**
  89743. * Gets the left camera of a rig setup in case of Rigged Camera
  89744. */
  89745. readonly leftCamera: Nullable<FreeCamera>;
  89746. /**
  89747. * Gets the right camera of a rig setup in case of Rigged Camera
  89748. */
  89749. readonly rightCamera: Nullable<FreeCamera>;
  89750. /**
  89751. * Gets the left camera target of a rig setup in case of Rigged Camera
  89752. * @returns the target position
  89753. */
  89754. getLeftTarget(): Nullable<Vector3>;
  89755. /**
  89756. * Gets the right camera target of a rig setup in case of Rigged Camera
  89757. * @returns the target position
  89758. */
  89759. getRightTarget(): Nullable<Vector3>;
  89760. /**
  89761. * @hidden
  89762. */
  89763. setCameraRigMode(mode: number, rigParams: any): void;
  89764. /** @hidden */
  89765. static _setStereoscopicRigMode(camera: Camera): void;
  89766. /** @hidden */
  89767. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89768. /** @hidden */
  89769. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89770. /** @hidden */
  89771. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89772. /** @hidden */
  89773. _getVRProjectionMatrix(): Matrix;
  89774. protected _updateCameraRotationMatrix(): void;
  89775. protected _updateWebVRCameraRotationMatrix(): void;
  89776. /**
  89777. * This function MUST be overwritten by the different WebVR cameras available.
  89778. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89779. * @hidden
  89780. */
  89781. _getWebVRProjectionMatrix(): Matrix;
  89782. /**
  89783. * This function MUST be overwritten by the different WebVR cameras available.
  89784. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89785. * @hidden
  89786. */
  89787. _getWebVRViewMatrix(): Matrix;
  89788. /** @hidden */
  89789. setCameraRigParameter(name: string, value: any): void;
  89790. /**
  89791. * needs to be overridden by children so sub has required properties to be copied
  89792. * @hidden
  89793. */
  89794. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89795. /**
  89796. * May need to be overridden by children
  89797. * @hidden
  89798. */
  89799. _updateRigCameras(): void;
  89800. /** @hidden */
  89801. _setupInputs(): void;
  89802. /**
  89803. * Serialiaze the camera setup to a json represention
  89804. * @returns the JSON representation
  89805. */
  89806. serialize(): any;
  89807. /**
  89808. * Clones the current camera.
  89809. * @param name The cloned camera name
  89810. * @returns the cloned camera
  89811. */
  89812. clone(name: string): Camera;
  89813. /**
  89814. * Gets the direction of the camera relative to a given local axis.
  89815. * @param localAxis Defines the reference axis to provide a relative direction.
  89816. * @return the direction
  89817. */
  89818. getDirection(localAxis: Vector3): Vector3;
  89819. /**
  89820. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89821. * @param localAxis Defines the reference axis to provide a relative direction.
  89822. * @param result Defines the vector to store the result in
  89823. */
  89824. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89825. /**
  89826. * Gets a camera constructor for a given camera type
  89827. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89828. * @param name The name of the camera the result will be able to instantiate
  89829. * @param scene The scene the result will construct the camera in
  89830. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89831. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89832. * @returns a factory method to construc the camera
  89833. */
  89834. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89835. /**
  89836. * Compute the world matrix of the camera.
  89837. * @returns the camera workd matrix
  89838. */
  89839. computeWorldMatrix(): Matrix;
  89840. /**
  89841. * Parse a JSON and creates the camera from the parsed information
  89842. * @param parsedCamera The JSON to parse
  89843. * @param scene The scene to instantiate the camera in
  89844. * @returns the newly constructed camera
  89845. */
  89846. static Parse(parsedCamera: any, scene: Scene): Camera;
  89847. }
  89848. }
  89849. declare module BABYLON {
  89850. /**
  89851. * Class containing static functions to help procedurally build meshes
  89852. */
  89853. export class DiscBuilder {
  89854. /**
  89855. * Creates a plane polygonal mesh. By default, this is a disc
  89856. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89857. * * 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
  89858. * * 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
  89859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89862. * @param name defines the name of the mesh
  89863. * @param options defines the options used to create the mesh
  89864. * @param scene defines the hosting scene
  89865. * @returns the plane polygonal mesh
  89866. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89867. */
  89868. static CreateDisc(name: string, options: {
  89869. radius?: number;
  89870. tessellation?: number;
  89871. arc?: number;
  89872. updatable?: boolean;
  89873. sideOrientation?: number;
  89874. frontUVs?: Vector4;
  89875. backUVs?: Vector4;
  89876. }, scene?: Nullable<Scene>): Mesh;
  89877. }
  89878. }
  89879. declare module BABYLON {
  89880. /**
  89881. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89882. *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.
  89883. * The SPS is also a particle system. It provides some methods to manage the particles.
  89884. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89885. *
  89886. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89887. */
  89888. export class SolidParticleSystem implements IDisposable {
  89889. /**
  89890. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89891. * Example : var p = SPS.particles[i];
  89892. */
  89893. particles: SolidParticle[];
  89894. /**
  89895. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89896. */
  89897. nbParticles: number;
  89898. /**
  89899. * If the particles must ever face the camera (default false). Useful for planar particles.
  89900. */
  89901. billboard: boolean;
  89902. /**
  89903. * Recompute normals when adding a shape
  89904. */
  89905. recomputeNormals: boolean;
  89906. /**
  89907. * This a counter ofr your own usage. It's not set by any SPS functions.
  89908. */
  89909. counter: number;
  89910. /**
  89911. * The SPS name. This name is also given to the underlying mesh.
  89912. */
  89913. name: string;
  89914. /**
  89915. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89916. */
  89917. mesh: Mesh;
  89918. /**
  89919. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89920. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89921. */
  89922. vars: any;
  89923. /**
  89924. * This array is populated when the SPS is set as 'pickable'.
  89925. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89926. * Each element of this array is an object `{idx: int, faceId: int}`.
  89927. * `idx` is the picked particle index in the `SPS.particles` array
  89928. * `faceId` is the picked face index counted within this particle.
  89929. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89930. */
  89931. pickedParticles: {
  89932. idx: number;
  89933. faceId: number;
  89934. }[];
  89935. /**
  89936. * This array is populated when `enableDepthSort` is set to true.
  89937. * Each element of this array is an instance of the class DepthSortedParticle.
  89938. */
  89939. depthSortedParticles: DepthSortedParticle[];
  89940. /**
  89941. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89942. * @hidden
  89943. */
  89944. _bSphereOnly: boolean;
  89945. /**
  89946. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89947. * @hidden
  89948. */
  89949. _bSphereRadiusFactor: number;
  89950. private _scene;
  89951. private _positions;
  89952. private _indices;
  89953. private _normals;
  89954. private _colors;
  89955. private _uvs;
  89956. private _indices32;
  89957. private _positions32;
  89958. private _normals32;
  89959. private _fixedNormal32;
  89960. private _colors32;
  89961. private _uvs32;
  89962. private _index;
  89963. private _updatable;
  89964. private _pickable;
  89965. private _isVisibilityBoxLocked;
  89966. private _alwaysVisible;
  89967. private _depthSort;
  89968. private _shapeCounter;
  89969. private _copy;
  89970. private _color;
  89971. private _computeParticleColor;
  89972. private _computeParticleTexture;
  89973. private _computeParticleRotation;
  89974. private _computeParticleVertex;
  89975. private _computeBoundingBox;
  89976. private _depthSortParticles;
  89977. private _camera;
  89978. private _mustUnrotateFixedNormals;
  89979. private _particlesIntersect;
  89980. private _needs32Bits;
  89981. /**
  89982. * Creates a SPS (Solid Particle System) object.
  89983. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89984. * @param scene (Scene) is the scene in which the SPS is added.
  89985. * @param options defines the options of the sps e.g.
  89986. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89987. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89988. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89989. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89990. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89991. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89992. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89993. */
  89994. constructor(name: string, scene: Scene, options?: {
  89995. updatable?: boolean;
  89996. isPickable?: boolean;
  89997. enableDepthSort?: boolean;
  89998. particleIntersection?: boolean;
  89999. boundingSphereOnly?: boolean;
  90000. bSphereRadiusFactor?: number;
  90001. });
  90002. /**
  90003. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90004. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90005. * @returns the created mesh
  90006. */
  90007. buildMesh(): Mesh;
  90008. /**
  90009. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90010. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90011. * Thus the particles generated from `digest()` have their property `position` set yet.
  90012. * @param mesh ( Mesh ) is the mesh to be digested
  90013. * @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
  90014. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90015. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90016. * @returns the current SPS
  90017. */
  90018. digest(mesh: Mesh, options?: {
  90019. facetNb?: number;
  90020. number?: number;
  90021. delta?: number;
  90022. }): SolidParticleSystem;
  90023. private _unrotateFixedNormals;
  90024. private _resetCopy;
  90025. private _meshBuilder;
  90026. private _posToShape;
  90027. private _uvsToShapeUV;
  90028. private _addParticle;
  90029. /**
  90030. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90031. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90032. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90033. * @param nb (positive integer) the number of particles to be created from this model
  90034. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90035. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90036. * @returns the number of shapes in the system
  90037. */
  90038. addShape(mesh: Mesh, nb: number, options?: {
  90039. positionFunction?: any;
  90040. vertexFunction?: any;
  90041. }): number;
  90042. private _rebuildParticle;
  90043. /**
  90044. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90045. * @returns the SPS.
  90046. */
  90047. rebuildMesh(): SolidParticleSystem;
  90048. /**
  90049. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90050. * This method calls `updateParticle()` for each particle of the SPS.
  90051. * For an animated SPS, it is usually called within the render loop.
  90052. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90053. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90054. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90055. * @returns the SPS.
  90056. */
  90057. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90058. /**
  90059. * Disposes the SPS.
  90060. */
  90061. dispose(): void;
  90062. /**
  90063. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90064. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90065. * @returns the SPS.
  90066. */
  90067. refreshVisibleSize(): SolidParticleSystem;
  90068. /**
  90069. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90070. * @param size the size (float) of the visibility box
  90071. * note : this doesn't lock the SPS mesh bounding box.
  90072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90073. */
  90074. setVisibilityBox(size: number): void;
  90075. /**
  90076. * Gets whether the SPS as always visible or not
  90077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90078. */
  90079. /**
  90080. * Sets the SPS as always visible or not
  90081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90082. */
  90083. isAlwaysVisible: boolean;
  90084. /**
  90085. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90087. */
  90088. /**
  90089. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90090. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90091. */
  90092. isVisibilityBoxLocked: boolean;
  90093. /**
  90094. * Tells to `setParticles()` to compute the particle rotations or not.
  90095. * Default value : true. The SPS is faster when it's set to false.
  90096. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90097. */
  90098. /**
  90099. * Gets if `setParticles()` computes the particle rotations or not.
  90100. * Default value : true. The SPS is faster when it's set to false.
  90101. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90102. */
  90103. computeParticleRotation: boolean;
  90104. /**
  90105. * Tells to `setParticles()` to compute the particle colors or not.
  90106. * Default value : true. The SPS is faster when it's set to false.
  90107. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90108. */
  90109. /**
  90110. * Gets if `setParticles()` computes the particle colors or not.
  90111. * Default value : true. The SPS is faster when it's set to false.
  90112. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90113. */
  90114. computeParticleColor: boolean;
  90115. /**
  90116. * Gets if `setParticles()` computes the particle textures or not.
  90117. * Default value : true. The SPS is faster when it's set to false.
  90118. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90119. */
  90120. computeParticleTexture: boolean;
  90121. /**
  90122. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90123. * Default value : false. The SPS is faster when it's set to false.
  90124. * Note : the particle custom vertex positions aren't stored values.
  90125. */
  90126. /**
  90127. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90128. * Default value : false. The SPS is faster when it's set to false.
  90129. * Note : the particle custom vertex positions aren't stored values.
  90130. */
  90131. computeParticleVertex: boolean;
  90132. /**
  90133. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90134. */
  90135. /**
  90136. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90137. */
  90138. computeBoundingBox: boolean;
  90139. /**
  90140. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90141. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90142. * Default : `true`
  90143. */
  90144. /**
  90145. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90146. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90147. * Default : `true`
  90148. */
  90149. depthSortParticles: boolean;
  90150. /**
  90151. * This function does nothing. It may be overwritten to set all the particle first values.
  90152. * The SPS doesn't call this function, you may have to call it by your own.
  90153. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90154. */
  90155. initParticles(): void;
  90156. /**
  90157. * This function does nothing. It may be overwritten to recycle a particle.
  90158. * The SPS doesn't call this function, you may have to call it by your own.
  90159. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90160. * @param particle The particle to recycle
  90161. * @returns the recycled particle
  90162. */
  90163. recycleParticle(particle: SolidParticle): SolidParticle;
  90164. /**
  90165. * Updates a particle : this function should be overwritten by the user.
  90166. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90167. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90168. * @example : just set a particle position or velocity and recycle conditions
  90169. * @param particle The particle to update
  90170. * @returns the updated particle
  90171. */
  90172. updateParticle(particle: SolidParticle): SolidParticle;
  90173. /**
  90174. * Updates a vertex of a particle : it can be overwritten by the user.
  90175. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90176. * @param particle the current particle
  90177. * @param vertex the current index of the current particle
  90178. * @param pt the index of the current vertex in the particle shape
  90179. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90180. * @example : just set a vertex particle position
  90181. * @returns the updated vertex
  90182. */
  90183. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90184. /**
  90185. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90186. * This does nothing and may be overwritten by the user.
  90187. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90188. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90189. * @param update the boolean update value actually passed to setParticles()
  90190. */
  90191. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90192. /**
  90193. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90194. * This will be passed three parameters.
  90195. * This does nothing and may be overwritten by the user.
  90196. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90197. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90198. * @param update the boolean update value actually passed to setParticles()
  90199. */
  90200. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90201. }
  90202. }
  90203. declare module BABYLON {
  90204. /**
  90205. * Represents one particle of a solid particle system.
  90206. */
  90207. export class SolidParticle {
  90208. /**
  90209. * particle global index
  90210. */
  90211. idx: number;
  90212. /**
  90213. * The color of the particle
  90214. */
  90215. color: Nullable<Color4>;
  90216. /**
  90217. * The world space position of the particle.
  90218. */
  90219. position: Vector3;
  90220. /**
  90221. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90222. */
  90223. rotation: Vector3;
  90224. /**
  90225. * The world space rotation quaternion of the particle.
  90226. */
  90227. rotationQuaternion: Nullable<Quaternion>;
  90228. /**
  90229. * The scaling of the particle.
  90230. */
  90231. scaling: Vector3;
  90232. /**
  90233. * The uvs of the particle.
  90234. */
  90235. uvs: Vector4;
  90236. /**
  90237. * The current speed of the particle.
  90238. */
  90239. velocity: Vector3;
  90240. /**
  90241. * The pivot point in the particle local space.
  90242. */
  90243. pivot: Vector3;
  90244. /**
  90245. * Must the particle be translated from its pivot point in its local space ?
  90246. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90247. * Default : false
  90248. */
  90249. translateFromPivot: boolean;
  90250. /**
  90251. * Is the particle active or not ?
  90252. */
  90253. alive: boolean;
  90254. /**
  90255. * Is the particle visible or not ?
  90256. */
  90257. isVisible: boolean;
  90258. /**
  90259. * Index of this particle in the global "positions" array (Internal use)
  90260. * @hidden
  90261. */
  90262. _pos: number;
  90263. /**
  90264. * @hidden Index of this particle in the global "indices" array (Internal use)
  90265. */
  90266. _ind: number;
  90267. /**
  90268. * @hidden ModelShape of this particle (Internal use)
  90269. */
  90270. _model: ModelShape;
  90271. /**
  90272. * ModelShape id of this particle
  90273. */
  90274. shapeId: number;
  90275. /**
  90276. * Index of the particle in its shape id
  90277. */
  90278. idxInShape: number;
  90279. /**
  90280. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90281. */
  90282. _modelBoundingInfo: BoundingInfo;
  90283. /**
  90284. * @hidden Particle BoundingInfo object (Internal use)
  90285. */
  90286. _boundingInfo: BoundingInfo;
  90287. /**
  90288. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90289. */
  90290. _sps: SolidParticleSystem;
  90291. /**
  90292. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90293. */
  90294. _stillInvisible: boolean;
  90295. /**
  90296. * @hidden Last computed particle rotation matrix
  90297. */
  90298. _rotationMatrix: number[];
  90299. /**
  90300. * Parent particle Id, if any.
  90301. * Default null.
  90302. */
  90303. parentId: Nullable<number>;
  90304. /**
  90305. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90306. * The possible values are :
  90307. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90308. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90311. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90312. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90313. * */
  90314. cullingStrategy: number;
  90315. /**
  90316. * @hidden Internal global position in the SPS.
  90317. */
  90318. _globalPosition: Vector3;
  90319. /**
  90320. * Creates a Solid Particle object.
  90321. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90322. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90323. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90324. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90325. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90326. * @param shapeId (integer) is the model shape identifier in the SPS.
  90327. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90328. * @param sps defines the sps it is associated to
  90329. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90330. */
  90331. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90332. /**
  90333. * Legacy support, changed scale to scaling
  90334. */
  90335. /**
  90336. * Legacy support, changed scale to scaling
  90337. */
  90338. scale: Vector3;
  90339. /**
  90340. * Legacy support, changed quaternion to rotationQuaternion
  90341. */
  90342. /**
  90343. * Legacy support, changed quaternion to rotationQuaternion
  90344. */
  90345. quaternion: Nullable<Quaternion>;
  90346. /**
  90347. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90348. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90349. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90350. * @returns true if it intersects
  90351. */
  90352. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90353. /**
  90354. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90355. * A particle is in the frustum if its bounding box intersects the frustum
  90356. * @param frustumPlanes defines the frustum to test
  90357. * @returns true if the particle is in the frustum planes
  90358. */
  90359. isInFrustum(frustumPlanes: Plane[]): boolean;
  90360. /**
  90361. * get the rotation matrix of the particle
  90362. * @hidden
  90363. */
  90364. getRotationMatrix(m: Matrix): void;
  90365. }
  90366. /**
  90367. * Represents the shape of the model used by one particle of a solid particle system.
  90368. * SPS internal tool, don't use it manually.
  90369. */
  90370. export class ModelShape {
  90371. /**
  90372. * The shape id
  90373. * @hidden
  90374. */
  90375. shapeID: number;
  90376. /**
  90377. * flat array of model positions (internal use)
  90378. * @hidden
  90379. */
  90380. _shape: Vector3[];
  90381. /**
  90382. * flat array of model UVs (internal use)
  90383. * @hidden
  90384. */
  90385. _shapeUV: number[];
  90386. /**
  90387. * length of the shape in the model indices array (internal use)
  90388. * @hidden
  90389. */
  90390. _indicesLength: number;
  90391. /**
  90392. * Custom position function (internal use)
  90393. * @hidden
  90394. */
  90395. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90396. /**
  90397. * Custom vertex function (internal use)
  90398. * @hidden
  90399. */
  90400. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90401. /**
  90402. * 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.
  90403. * SPS internal tool, don't use it manually.
  90404. * @hidden
  90405. */
  90406. 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>);
  90407. }
  90408. /**
  90409. * Represents a Depth Sorted Particle in the solid particle system.
  90410. */
  90411. export class DepthSortedParticle {
  90412. /**
  90413. * Index of the particle in the "indices" array
  90414. */
  90415. ind: number;
  90416. /**
  90417. * Length of the particle shape in the "indices" array
  90418. */
  90419. indicesLength: number;
  90420. /**
  90421. * Squared distance from the particle to the camera
  90422. */
  90423. sqDistance: number;
  90424. }
  90425. }
  90426. declare module BABYLON {
  90427. /**
  90428. * @hidden
  90429. */
  90430. export class _MeshCollisionData {
  90431. _checkCollisions: boolean;
  90432. _collisionMask: number;
  90433. _collisionGroup: number;
  90434. _collider: Nullable<Collider>;
  90435. _oldPositionForCollisions: Vector3;
  90436. _diffPositionForCollisions: Vector3;
  90437. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90438. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90439. }
  90440. }
  90441. declare module BABYLON {
  90442. /** @hidden */
  90443. class _FacetDataStorage {
  90444. facetPositions: Vector3[];
  90445. facetNormals: Vector3[];
  90446. facetPartitioning: number[][];
  90447. facetNb: number;
  90448. partitioningSubdivisions: number;
  90449. partitioningBBoxRatio: number;
  90450. facetDataEnabled: boolean;
  90451. facetParameters: any;
  90452. bbSize: Vector3;
  90453. subDiv: {
  90454. max: number;
  90455. X: number;
  90456. Y: number;
  90457. Z: number;
  90458. };
  90459. facetDepthSort: boolean;
  90460. facetDepthSortEnabled: boolean;
  90461. depthSortedIndices: IndicesArray;
  90462. depthSortedFacets: {
  90463. ind: number;
  90464. sqDistance: number;
  90465. }[];
  90466. facetDepthSortFunction: (f1: {
  90467. ind: number;
  90468. sqDistance: number;
  90469. }, f2: {
  90470. ind: number;
  90471. sqDistance: number;
  90472. }) => number;
  90473. facetDepthSortFrom: Vector3;
  90474. facetDepthSortOrigin: Vector3;
  90475. invertedMatrix: Matrix;
  90476. }
  90477. /**
  90478. * @hidden
  90479. **/
  90480. class _InternalAbstractMeshDataInfo {
  90481. _hasVertexAlpha: boolean;
  90482. _useVertexColors: boolean;
  90483. _numBoneInfluencers: number;
  90484. _applyFog: boolean;
  90485. _receiveShadows: boolean;
  90486. _facetData: _FacetDataStorage;
  90487. _visibility: number;
  90488. _skeleton: Nullable<Skeleton>;
  90489. _layerMask: number;
  90490. _computeBonesUsingShaders: boolean;
  90491. _isActive: boolean;
  90492. _onlyForInstances: boolean;
  90493. _isActiveIntermediate: boolean;
  90494. _onlyForInstancesIntermediate: boolean;
  90495. }
  90496. /**
  90497. * Class used to store all common mesh properties
  90498. */
  90499. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90500. /** No occlusion */
  90501. static OCCLUSION_TYPE_NONE: number;
  90502. /** Occlusion set to optimisitic */
  90503. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90504. /** Occlusion set to strict */
  90505. static OCCLUSION_TYPE_STRICT: number;
  90506. /** Use an accurante occlusion algorithm */
  90507. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90508. /** Use a conservative occlusion algorithm */
  90509. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90510. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90511. * Test order :
  90512. * Is the bounding sphere outside the frustum ?
  90513. * If not, are the bounding box vertices outside the frustum ?
  90514. * It not, then the cullable object is in the frustum.
  90515. */
  90516. static readonly CULLINGSTRATEGY_STANDARD: number;
  90517. /** Culling strategy : Bounding Sphere Only.
  90518. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90519. * It's also less accurate than the standard because some not visible objects can still be selected.
  90520. * Test : is the bounding sphere outside the frustum ?
  90521. * If not, then the cullable object is in the frustum.
  90522. */
  90523. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90524. /** Culling strategy : Optimistic Inclusion.
  90525. * This in an inclusion test first, then the standard exclusion test.
  90526. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90527. * 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.
  90528. * Anyway, it's as accurate as the standard strategy.
  90529. * Test :
  90530. * Is the cullable object bounding sphere center in the frustum ?
  90531. * If not, apply the default culling strategy.
  90532. */
  90533. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90534. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90535. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90536. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90537. * 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.
  90538. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90539. * Test :
  90540. * Is the cullable object bounding sphere center in the frustum ?
  90541. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90542. */
  90543. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90544. /**
  90545. * No billboard
  90546. */
  90547. static readonly BILLBOARDMODE_NONE: number;
  90548. /** Billboard on X axis */
  90549. static readonly BILLBOARDMODE_X: number;
  90550. /** Billboard on Y axis */
  90551. static readonly BILLBOARDMODE_Y: number;
  90552. /** Billboard on Z axis */
  90553. static readonly BILLBOARDMODE_Z: number;
  90554. /** Billboard on all axes */
  90555. static readonly BILLBOARDMODE_ALL: number;
  90556. /** Billboard on using position instead of orientation */
  90557. static readonly BILLBOARDMODE_USE_POSITION: number;
  90558. /** @hidden */
  90559. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90560. /**
  90561. * The culling strategy to use to check whether the mesh must be rendered or not.
  90562. * This value can be changed at any time and will be used on the next render mesh selection.
  90563. * The possible values are :
  90564. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90565. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90566. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90567. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90568. * Please read each static variable documentation to get details about the culling process.
  90569. * */
  90570. cullingStrategy: number;
  90571. /**
  90572. * Gets the number of facets in the mesh
  90573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90574. */
  90575. readonly facetNb: number;
  90576. /**
  90577. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90579. */
  90580. partitioningSubdivisions: number;
  90581. /**
  90582. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90583. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90585. */
  90586. partitioningBBoxRatio: number;
  90587. /**
  90588. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90589. * Works only for updatable meshes.
  90590. * Doesn't work with multi-materials
  90591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90592. */
  90593. mustDepthSortFacets: boolean;
  90594. /**
  90595. * The location (Vector3) where the facet depth sort must be computed from.
  90596. * By default, the active camera position.
  90597. * Used only when facet depth sort is enabled
  90598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90599. */
  90600. facetDepthSortFrom: Vector3;
  90601. /**
  90602. * gets a boolean indicating if facetData is enabled
  90603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90604. */
  90605. readonly isFacetDataEnabled: boolean;
  90606. /** @hidden */
  90607. _updateNonUniformScalingState(value: boolean): boolean;
  90608. /**
  90609. * An event triggered when this mesh collides with another one
  90610. */
  90611. onCollideObservable: Observable<AbstractMesh>;
  90612. /** Set a function to call when this mesh collides with another one */
  90613. onCollide: () => void;
  90614. /**
  90615. * An event triggered when the collision's position changes
  90616. */
  90617. onCollisionPositionChangeObservable: Observable<Vector3>;
  90618. /** Set a function to call when the collision's position changes */
  90619. onCollisionPositionChange: () => void;
  90620. /**
  90621. * An event triggered when material is changed
  90622. */
  90623. onMaterialChangedObservable: Observable<AbstractMesh>;
  90624. /**
  90625. * Gets or sets the orientation for POV movement & rotation
  90626. */
  90627. definedFacingForward: boolean;
  90628. /** @hidden */
  90629. _occlusionQuery: Nullable<WebGLQuery>;
  90630. /** @hidden */
  90631. _renderingGroup: Nullable<RenderingGroup>;
  90632. /**
  90633. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90634. */
  90635. /**
  90636. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90637. */
  90638. visibility: number;
  90639. /** Gets or sets the alpha index used to sort transparent meshes
  90640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90641. */
  90642. alphaIndex: number;
  90643. /**
  90644. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90645. */
  90646. isVisible: boolean;
  90647. /**
  90648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90649. */
  90650. isPickable: boolean;
  90651. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90652. showSubMeshesBoundingBox: boolean;
  90653. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90655. */
  90656. isBlocker: boolean;
  90657. /**
  90658. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90659. */
  90660. enablePointerMoveEvents: boolean;
  90661. /**
  90662. * Specifies the rendering group id for this mesh (0 by default)
  90663. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90664. */
  90665. renderingGroupId: number;
  90666. private _material;
  90667. /** Gets or sets current material */
  90668. material: Nullable<Material>;
  90669. /**
  90670. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90671. * @see http://doc.babylonjs.com/babylon101/shadows
  90672. */
  90673. receiveShadows: boolean;
  90674. /** Defines color to use when rendering outline */
  90675. outlineColor: Color3;
  90676. /** Define width to use when rendering outline */
  90677. outlineWidth: number;
  90678. /** Defines color to use when rendering overlay */
  90679. overlayColor: Color3;
  90680. /** Defines alpha to use when rendering overlay */
  90681. overlayAlpha: number;
  90682. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90683. hasVertexAlpha: boolean;
  90684. /** 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) */
  90685. useVertexColors: boolean;
  90686. /**
  90687. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90688. */
  90689. computeBonesUsingShaders: boolean;
  90690. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90691. numBoneInfluencers: number;
  90692. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90693. applyFog: boolean;
  90694. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90695. useOctreeForRenderingSelection: boolean;
  90696. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90697. useOctreeForPicking: boolean;
  90698. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90699. useOctreeForCollisions: boolean;
  90700. /**
  90701. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90702. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90703. */
  90704. layerMask: number;
  90705. /**
  90706. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90707. */
  90708. alwaysSelectAsActiveMesh: boolean;
  90709. /**
  90710. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90711. */
  90712. doNotSyncBoundingInfo: boolean;
  90713. /**
  90714. * Gets or sets the current action manager
  90715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90716. */
  90717. actionManager: Nullable<AbstractActionManager>;
  90718. private _meshCollisionData;
  90719. /**
  90720. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90722. */
  90723. ellipsoid: Vector3;
  90724. /**
  90725. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90727. */
  90728. ellipsoidOffset: Vector3;
  90729. /**
  90730. * Gets or sets a collision mask used to mask collisions (default is -1).
  90731. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90732. */
  90733. collisionMask: number;
  90734. /**
  90735. * Gets or sets the current collision group mask (-1 by default).
  90736. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90737. */
  90738. collisionGroup: number;
  90739. /**
  90740. * Defines edge width used when edgesRenderer is enabled
  90741. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90742. */
  90743. edgesWidth: number;
  90744. /**
  90745. * Defines edge color used when edgesRenderer is enabled
  90746. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90747. */
  90748. edgesColor: Color4;
  90749. /** @hidden */
  90750. _edgesRenderer: Nullable<IEdgesRenderer>;
  90751. /** @hidden */
  90752. _masterMesh: Nullable<AbstractMesh>;
  90753. /** @hidden */
  90754. _boundingInfo: Nullable<BoundingInfo>;
  90755. /** @hidden */
  90756. _renderId: number;
  90757. /**
  90758. * Gets or sets the list of subMeshes
  90759. * @see http://doc.babylonjs.com/how_to/multi_materials
  90760. */
  90761. subMeshes: SubMesh[];
  90762. /** @hidden */
  90763. _intersectionsInProgress: AbstractMesh[];
  90764. /** @hidden */
  90765. _unIndexed: boolean;
  90766. /** @hidden */
  90767. _lightSources: Light[];
  90768. /** Gets the list of lights affecting that mesh */
  90769. readonly lightSources: Light[];
  90770. /** @hidden */
  90771. readonly _positions: Nullable<Vector3[]>;
  90772. /** @hidden */
  90773. _waitingData: {
  90774. lods: Nullable<any>;
  90775. actions: Nullable<any>;
  90776. freezeWorldMatrix: Nullable<boolean>;
  90777. };
  90778. /** @hidden */
  90779. _bonesTransformMatrices: Nullable<Float32Array>;
  90780. /** @hidden */
  90781. _transformMatrixTexture: Nullable<RawTexture>;
  90782. /**
  90783. * Gets or sets a skeleton to apply skining transformations
  90784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90785. */
  90786. skeleton: Nullable<Skeleton>;
  90787. /**
  90788. * An event triggered when the mesh is rebuilt.
  90789. */
  90790. onRebuildObservable: Observable<AbstractMesh>;
  90791. /**
  90792. * Creates a new AbstractMesh
  90793. * @param name defines the name of the mesh
  90794. * @param scene defines the hosting scene
  90795. */
  90796. constructor(name: string, scene?: Nullable<Scene>);
  90797. /**
  90798. * Returns the string "AbstractMesh"
  90799. * @returns "AbstractMesh"
  90800. */
  90801. getClassName(): string;
  90802. /**
  90803. * Gets a string representation of the current mesh
  90804. * @param fullDetails defines a boolean indicating if full details must be included
  90805. * @returns a string representation of the current mesh
  90806. */
  90807. toString(fullDetails?: boolean): string;
  90808. /**
  90809. * @hidden
  90810. */
  90811. protected _getEffectiveParent(): Nullable<Node>;
  90812. /** @hidden */
  90813. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90814. /** @hidden */
  90815. _rebuild(): void;
  90816. /** @hidden */
  90817. _resyncLightSources(): void;
  90818. /** @hidden */
  90819. _resyncLighSource(light: Light): void;
  90820. /** @hidden */
  90821. _unBindEffect(): void;
  90822. /** @hidden */
  90823. _removeLightSource(light: Light): void;
  90824. private _markSubMeshesAsDirty;
  90825. /** @hidden */
  90826. _markSubMeshesAsLightDirty(): void;
  90827. /** @hidden */
  90828. _markSubMeshesAsAttributesDirty(): void;
  90829. /** @hidden */
  90830. _markSubMeshesAsMiscDirty(): void;
  90831. /**
  90832. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90833. */
  90834. scaling: Vector3;
  90835. /**
  90836. * Returns true if the mesh is blocked. Implemented by child classes
  90837. */
  90838. readonly isBlocked: boolean;
  90839. /**
  90840. * Returns the mesh itself by default. Implemented by child classes
  90841. * @param camera defines the camera to use to pick the right LOD level
  90842. * @returns the currentAbstractMesh
  90843. */
  90844. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90845. /**
  90846. * Returns 0 by default. Implemented by child classes
  90847. * @returns an integer
  90848. */
  90849. getTotalVertices(): number;
  90850. /**
  90851. * Returns a positive integer : the total number of indices in this mesh geometry.
  90852. * @returns the numner of indices or zero if the mesh has no geometry.
  90853. */
  90854. getTotalIndices(): number;
  90855. /**
  90856. * Returns null by default. Implemented by child classes
  90857. * @returns null
  90858. */
  90859. getIndices(): Nullable<IndicesArray>;
  90860. /**
  90861. * Returns the array of the requested vertex data kind. Implemented by child classes
  90862. * @param kind defines the vertex data kind to use
  90863. * @returns null
  90864. */
  90865. getVerticesData(kind: string): Nullable<FloatArray>;
  90866. /**
  90867. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90868. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90869. * Note that a new underlying VertexBuffer object is created each call.
  90870. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90871. * @param kind defines vertex data kind:
  90872. * * VertexBuffer.PositionKind
  90873. * * VertexBuffer.UVKind
  90874. * * VertexBuffer.UV2Kind
  90875. * * VertexBuffer.UV3Kind
  90876. * * VertexBuffer.UV4Kind
  90877. * * VertexBuffer.UV5Kind
  90878. * * VertexBuffer.UV6Kind
  90879. * * VertexBuffer.ColorKind
  90880. * * VertexBuffer.MatricesIndicesKind
  90881. * * VertexBuffer.MatricesIndicesExtraKind
  90882. * * VertexBuffer.MatricesWeightsKind
  90883. * * VertexBuffer.MatricesWeightsExtraKind
  90884. * @param data defines the data source
  90885. * @param updatable defines if the data must be flagged as updatable (or static)
  90886. * @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
  90887. * @returns the current mesh
  90888. */
  90889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90890. /**
  90891. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90892. * If the mesh has no geometry, it is simply returned as it is.
  90893. * @param kind defines vertex data kind:
  90894. * * VertexBuffer.PositionKind
  90895. * * VertexBuffer.UVKind
  90896. * * VertexBuffer.UV2Kind
  90897. * * VertexBuffer.UV3Kind
  90898. * * VertexBuffer.UV4Kind
  90899. * * VertexBuffer.UV5Kind
  90900. * * VertexBuffer.UV6Kind
  90901. * * VertexBuffer.ColorKind
  90902. * * VertexBuffer.MatricesIndicesKind
  90903. * * VertexBuffer.MatricesIndicesExtraKind
  90904. * * VertexBuffer.MatricesWeightsKind
  90905. * * VertexBuffer.MatricesWeightsExtraKind
  90906. * @param data defines the data source
  90907. * @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
  90908. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90909. * @returns the current mesh
  90910. */
  90911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90912. /**
  90913. * Sets the mesh indices,
  90914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90915. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90916. * @param totalVertices Defines the total number of vertices
  90917. * @returns the current mesh
  90918. */
  90919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90920. /**
  90921. * Gets a boolean indicating if specific vertex data is present
  90922. * @param kind defines the vertex data kind to use
  90923. * @returns true is data kind is present
  90924. */
  90925. isVerticesDataPresent(kind: string): boolean;
  90926. /**
  90927. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90928. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90929. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90930. * @returns a BoundingInfo
  90931. */
  90932. getBoundingInfo(): BoundingInfo;
  90933. /**
  90934. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90935. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90936. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90937. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90938. * @returns the current mesh
  90939. */
  90940. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90941. /**
  90942. * Overwrite the current bounding info
  90943. * @param boundingInfo defines the new bounding info
  90944. * @returns the current mesh
  90945. */
  90946. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90947. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90948. readonly useBones: boolean;
  90949. /** @hidden */
  90950. _preActivate(): void;
  90951. /** @hidden */
  90952. _preActivateForIntermediateRendering(renderId: number): void;
  90953. /** @hidden */
  90954. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90955. /** @hidden */
  90956. _postActivate(): void;
  90957. /** @hidden */
  90958. _freeze(): void;
  90959. /** @hidden */
  90960. _unFreeze(): void;
  90961. /**
  90962. * Gets the current world matrix
  90963. * @returns a Matrix
  90964. */
  90965. getWorldMatrix(): Matrix;
  90966. /** @hidden */
  90967. _getWorldMatrixDeterminant(): number;
  90968. /**
  90969. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90970. */
  90971. readonly isAnInstance: boolean;
  90972. /**
  90973. * Gets a boolean indicating if this mesh has instances
  90974. */
  90975. readonly hasInstances: boolean;
  90976. /**
  90977. * Perform relative position change from the point of view of behind the front of the mesh.
  90978. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90979. * Supports definition of mesh facing forward or backward
  90980. * @param amountRight defines the distance on the right axis
  90981. * @param amountUp defines the distance on the up axis
  90982. * @param amountForward defines the distance on the forward axis
  90983. * @returns the current mesh
  90984. */
  90985. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90986. /**
  90987. * Calculate relative position change from the point of view of behind the front of the mesh.
  90988. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90989. * Supports definition of mesh facing forward or backward
  90990. * @param amountRight defines the distance on the right axis
  90991. * @param amountUp defines the distance on the up axis
  90992. * @param amountForward defines the distance on the forward axis
  90993. * @returns the new displacement vector
  90994. */
  90995. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90996. /**
  90997. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90998. * Supports definition of mesh facing forward or backward
  90999. * @param flipBack defines the flip
  91000. * @param twirlClockwise defines the twirl
  91001. * @param tiltRight defines the tilt
  91002. * @returns the current mesh
  91003. */
  91004. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91005. /**
  91006. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91007. * Supports definition of mesh facing forward or backward.
  91008. * @param flipBack defines the flip
  91009. * @param twirlClockwise defines the twirl
  91010. * @param tiltRight defines the tilt
  91011. * @returns the new rotation vector
  91012. */
  91013. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91014. /**
  91015. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91016. * This means the mesh underlying bounding box and sphere are recomputed.
  91017. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91018. * @returns the current mesh
  91019. */
  91020. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91021. /** @hidden */
  91022. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91023. /** @hidden */
  91024. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91025. /** @hidden */
  91026. _updateBoundingInfo(): AbstractMesh;
  91027. /** @hidden */
  91028. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91029. /** @hidden */
  91030. protected _afterComputeWorldMatrix(): void;
  91031. /** @hidden */
  91032. readonly _effectiveMesh: AbstractMesh;
  91033. /**
  91034. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91035. * A mesh is in the frustum if its bounding box intersects the frustum
  91036. * @param frustumPlanes defines the frustum to test
  91037. * @returns true if the mesh is in the frustum planes
  91038. */
  91039. isInFrustum(frustumPlanes: Plane[]): boolean;
  91040. /**
  91041. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91042. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91043. * @param frustumPlanes defines the frustum to test
  91044. * @returns true if the mesh is completely in the frustum planes
  91045. */
  91046. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91047. /**
  91048. * True if the mesh intersects another mesh or a SolidParticle object
  91049. * @param mesh defines a target mesh or SolidParticle to test
  91050. * @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)
  91051. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91052. * @returns true if there is an intersection
  91053. */
  91054. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91055. /**
  91056. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91057. * @param point defines the point to test
  91058. * @returns true if there is an intersection
  91059. */
  91060. intersectsPoint(point: Vector3): boolean;
  91061. /**
  91062. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91064. */
  91065. checkCollisions: boolean;
  91066. /**
  91067. * Gets Collider object used to compute collisions (not physics)
  91068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91069. */
  91070. readonly collider: Nullable<Collider>;
  91071. /**
  91072. * Move the mesh using collision engine
  91073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91074. * @param displacement defines the requested displacement vector
  91075. * @returns the current mesh
  91076. */
  91077. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91078. private _onCollisionPositionChange;
  91079. /** @hidden */
  91080. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91081. /** @hidden */
  91082. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91083. /** @hidden */
  91084. _checkCollision(collider: Collider): AbstractMesh;
  91085. /** @hidden */
  91086. _generatePointsArray(): boolean;
  91087. /**
  91088. * Checks if the passed Ray intersects with the mesh
  91089. * @param ray defines the ray to use
  91090. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91091. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91092. * @returns the picking info
  91093. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91094. */
  91095. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91096. /**
  91097. * Clones the current mesh
  91098. * @param name defines the mesh name
  91099. * @param newParent defines the new mesh parent
  91100. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91101. * @returns the new mesh
  91102. */
  91103. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91104. /**
  91105. * Disposes all the submeshes of the current meshnp
  91106. * @returns the current mesh
  91107. */
  91108. releaseSubMeshes(): AbstractMesh;
  91109. /**
  91110. * Releases resources associated with this abstract mesh.
  91111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91113. */
  91114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91115. /**
  91116. * Adds the passed mesh as a child to the current mesh
  91117. * @param mesh defines the child mesh
  91118. * @returns the current mesh
  91119. */
  91120. addChild(mesh: AbstractMesh): AbstractMesh;
  91121. /**
  91122. * Removes the passed mesh from the current mesh children list
  91123. * @param mesh defines the child mesh
  91124. * @returns the current mesh
  91125. */
  91126. removeChild(mesh: AbstractMesh): AbstractMesh;
  91127. /** @hidden */
  91128. private _initFacetData;
  91129. /**
  91130. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91131. * This method can be called within the render loop.
  91132. * 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
  91133. * @returns the current mesh
  91134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91135. */
  91136. updateFacetData(): AbstractMesh;
  91137. /**
  91138. * Returns the facetLocalNormals array.
  91139. * The normals are expressed in the mesh local spac
  91140. * @returns an array of Vector3
  91141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91142. */
  91143. getFacetLocalNormals(): Vector3[];
  91144. /**
  91145. * Returns the facetLocalPositions array.
  91146. * The facet positions are expressed in the mesh local space
  91147. * @returns an array of Vector3
  91148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91149. */
  91150. getFacetLocalPositions(): Vector3[];
  91151. /**
  91152. * Returns the facetLocalPartioning array
  91153. * @returns an array of array of numbers
  91154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91155. */
  91156. getFacetLocalPartitioning(): number[][];
  91157. /**
  91158. * Returns the i-th facet position in the world system.
  91159. * This method allocates a new Vector3 per call
  91160. * @param i defines the facet index
  91161. * @returns a new Vector3
  91162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91163. */
  91164. getFacetPosition(i: number): Vector3;
  91165. /**
  91166. * Sets the reference Vector3 with the i-th facet position in the world system
  91167. * @param i defines the facet index
  91168. * @param ref defines the target vector
  91169. * @returns the current mesh
  91170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91171. */
  91172. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91173. /**
  91174. * Returns the i-th facet normal in the world system.
  91175. * This method allocates a new Vector3 per call
  91176. * @param i defines the facet index
  91177. * @returns a new Vector3
  91178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91179. */
  91180. getFacetNormal(i: number): Vector3;
  91181. /**
  91182. * Sets the reference Vector3 with the i-th facet normal in the world system
  91183. * @param i defines the facet index
  91184. * @param ref defines the target vector
  91185. * @returns the current mesh
  91186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91187. */
  91188. getFacetNormalToRef(i: number, ref: Vector3): this;
  91189. /**
  91190. * 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)
  91191. * @param x defines x coordinate
  91192. * @param y defines y coordinate
  91193. * @param z defines z coordinate
  91194. * @returns the array of facet indexes
  91195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91196. */
  91197. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91198. /**
  91199. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91200. * @param projected sets as the (x,y,z) world projection on the facet
  91201. * @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
  91202. * @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
  91203. * @param x defines x coordinate
  91204. * @param y defines y coordinate
  91205. * @param z defines z coordinate
  91206. * @returns the face index if found (or null instead)
  91207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91208. */
  91209. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91210. /**
  91211. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91212. * @param projected sets as the (x,y,z) local projection on the facet
  91213. * @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
  91214. * @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
  91215. * @param x defines x coordinate
  91216. * @param y defines y coordinate
  91217. * @param z defines z coordinate
  91218. * @returns the face index if found (or null instead)
  91219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91220. */
  91221. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91222. /**
  91223. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91224. * @returns the parameters
  91225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91226. */
  91227. getFacetDataParameters(): any;
  91228. /**
  91229. * Disables the feature FacetData and frees the related memory
  91230. * @returns the current mesh
  91231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91232. */
  91233. disableFacetData(): AbstractMesh;
  91234. /**
  91235. * Updates the AbstractMesh indices array
  91236. * @param indices defines the data source
  91237. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91238. * @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)
  91239. * @returns the current mesh
  91240. */
  91241. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91242. /**
  91243. * Creates new normals data for the mesh
  91244. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91245. * @returns the current mesh
  91246. */
  91247. createNormals(updatable: boolean): AbstractMesh;
  91248. /**
  91249. * Align the mesh with a normal
  91250. * @param normal defines the normal to use
  91251. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91252. * @returns the current mesh
  91253. */
  91254. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91255. /** @hidden */
  91256. _checkOcclusionQuery(): boolean;
  91257. /**
  91258. * Disables the mesh edge rendering mode
  91259. * @returns the currentAbstractMesh
  91260. */
  91261. disableEdgesRendering(): AbstractMesh;
  91262. /**
  91263. * Enables the edge rendering mode on the mesh.
  91264. * This mode makes the mesh edges visible
  91265. * @param epsilon defines the maximal distance between two angles to detect a face
  91266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91267. * @returns the currentAbstractMesh
  91268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91269. */
  91270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91271. }
  91272. }
  91273. declare module BABYLON {
  91274. /**
  91275. * Interface used to define ActionEvent
  91276. */
  91277. export interface IActionEvent {
  91278. /** The mesh or sprite that triggered the action */
  91279. source: any;
  91280. /** The X mouse cursor position at the time of the event */
  91281. pointerX: number;
  91282. /** The Y mouse cursor position at the time of the event */
  91283. pointerY: number;
  91284. /** The mesh that is currently pointed at (can be null) */
  91285. meshUnderPointer: Nullable<AbstractMesh>;
  91286. /** the original (browser) event that triggered the ActionEvent */
  91287. sourceEvent?: any;
  91288. /** additional data for the event */
  91289. additionalData?: any;
  91290. }
  91291. /**
  91292. * ActionEvent is the event being sent when an action is triggered.
  91293. */
  91294. export class ActionEvent implements IActionEvent {
  91295. /** The mesh or sprite that triggered the action */
  91296. source: any;
  91297. /** The X mouse cursor position at the time of the event */
  91298. pointerX: number;
  91299. /** The Y mouse cursor position at the time of the event */
  91300. pointerY: number;
  91301. /** The mesh that is currently pointed at (can be null) */
  91302. meshUnderPointer: Nullable<AbstractMesh>;
  91303. /** the original (browser) event that triggered the ActionEvent */
  91304. sourceEvent?: any;
  91305. /** additional data for the event */
  91306. additionalData?: any;
  91307. /**
  91308. * Creates a new ActionEvent
  91309. * @param source The mesh or sprite that triggered the action
  91310. * @param pointerX The X mouse cursor position at the time of the event
  91311. * @param pointerY The Y mouse cursor position at the time of the event
  91312. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91313. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91314. * @param additionalData additional data for the event
  91315. */
  91316. constructor(
  91317. /** The mesh or sprite that triggered the action */
  91318. source: any,
  91319. /** The X mouse cursor position at the time of the event */
  91320. pointerX: number,
  91321. /** The Y mouse cursor position at the time of the event */
  91322. pointerY: number,
  91323. /** The mesh that is currently pointed at (can be null) */
  91324. meshUnderPointer: Nullable<AbstractMesh>,
  91325. /** the original (browser) event that triggered the ActionEvent */
  91326. sourceEvent?: any,
  91327. /** additional data for the event */
  91328. additionalData?: any);
  91329. /**
  91330. * Helper function to auto-create an ActionEvent from a source mesh.
  91331. * @param source The source mesh that triggered the event
  91332. * @param evt The original (browser) event
  91333. * @param additionalData additional data for the event
  91334. * @returns the new ActionEvent
  91335. */
  91336. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91337. /**
  91338. * Helper function to auto-create an ActionEvent from a source sprite
  91339. * @param source The source sprite that triggered the event
  91340. * @param scene Scene associated with the sprite
  91341. * @param evt The original (browser) event
  91342. * @param additionalData additional data for the event
  91343. * @returns the new ActionEvent
  91344. */
  91345. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91346. /**
  91347. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91348. * @param scene the scene where the event occurred
  91349. * @param evt The original (browser) event
  91350. * @returns the new ActionEvent
  91351. */
  91352. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91353. /**
  91354. * Helper function to auto-create an ActionEvent from a primitive
  91355. * @param prim defines the target primitive
  91356. * @param pointerPos defines the pointer position
  91357. * @param evt The original (browser) event
  91358. * @param additionalData additional data for the event
  91359. * @returns the new ActionEvent
  91360. */
  91361. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91362. }
  91363. }
  91364. declare module BABYLON {
  91365. /**
  91366. * Abstract class used to decouple action Manager from scene and meshes.
  91367. * Do not instantiate.
  91368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91369. */
  91370. export abstract class AbstractActionManager implements IDisposable {
  91371. /** Gets the list of active triggers */
  91372. static Triggers: {
  91373. [key: string]: number;
  91374. };
  91375. /** Gets the cursor to use when hovering items */
  91376. hoverCursor: string;
  91377. /** Gets the list of actions */
  91378. actions: IAction[];
  91379. /**
  91380. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91381. */
  91382. isRecursive: boolean;
  91383. /**
  91384. * Releases all associated resources
  91385. */
  91386. abstract dispose(): void;
  91387. /**
  91388. * Does this action manager has pointer triggers
  91389. */
  91390. abstract readonly hasPointerTriggers: boolean;
  91391. /**
  91392. * Does this action manager has pick triggers
  91393. */
  91394. abstract readonly hasPickTriggers: boolean;
  91395. /**
  91396. * Process a specific trigger
  91397. * @param trigger defines the trigger to process
  91398. * @param evt defines the event details to be processed
  91399. */
  91400. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91401. /**
  91402. * Does this action manager handles actions of any of the given triggers
  91403. * @param triggers defines the triggers to be tested
  91404. * @return a boolean indicating whether one (or more) of the triggers is handled
  91405. */
  91406. abstract hasSpecificTriggers(triggers: number[]): boolean;
  91407. /**
  91408. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91409. * speed.
  91410. * @param triggerA defines the trigger to be tested
  91411. * @param triggerB defines the trigger to be tested
  91412. * @return a boolean indicating whether one (or more) of the triggers is handled
  91413. */
  91414. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91415. /**
  91416. * Does this action manager handles actions of a given trigger
  91417. * @param trigger defines the trigger to be tested
  91418. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91419. * @return whether the trigger is handled
  91420. */
  91421. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91422. /**
  91423. * Serialize this manager to a JSON object
  91424. * @param name defines the property name to store this manager
  91425. * @returns a JSON representation of this manager
  91426. */
  91427. abstract serialize(name: string): any;
  91428. /**
  91429. * Registers an action to this action manager
  91430. * @param action defines the action to be registered
  91431. * @return the action amended (prepared) after registration
  91432. */
  91433. abstract registerAction(action: IAction): Nullable<IAction>;
  91434. /**
  91435. * Unregisters an action to this action manager
  91436. * @param action defines the action to be unregistered
  91437. * @return a boolean indicating whether the action has been unregistered
  91438. */
  91439. abstract unregisterAction(action: IAction): Boolean;
  91440. /**
  91441. * Does exist one action manager with at least one trigger
  91442. **/
  91443. static readonly HasTriggers: boolean;
  91444. /**
  91445. * Does exist one action manager with at least one pick trigger
  91446. **/
  91447. static readonly HasPickTriggers: boolean;
  91448. /**
  91449. * Does exist one action manager that handles actions of a given trigger
  91450. * @param trigger defines the trigger to be tested
  91451. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91452. **/
  91453. static HasSpecificTrigger(trigger: number): boolean;
  91454. }
  91455. }
  91456. declare module BABYLON {
  91457. /**
  91458. * Defines how a node can be built from a string name.
  91459. */
  91460. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91461. /**
  91462. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91463. */
  91464. export class Node implements IBehaviorAware<Node> {
  91465. /** @hidden */
  91466. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91467. private static _NodeConstructors;
  91468. /**
  91469. * Add a new node constructor
  91470. * @param type defines the type name of the node to construct
  91471. * @param constructorFunc defines the constructor function
  91472. */
  91473. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91474. /**
  91475. * Returns a node constructor based on type name
  91476. * @param type defines the type name
  91477. * @param name defines the new node name
  91478. * @param scene defines the hosting scene
  91479. * @param options defines optional options to transmit to constructors
  91480. * @returns the new constructor or null
  91481. */
  91482. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91483. /**
  91484. * Gets or sets the name of the node
  91485. */
  91486. name: string;
  91487. /**
  91488. * Gets or sets the id of the node
  91489. */
  91490. id: string;
  91491. /**
  91492. * Gets or sets the unique id of the node
  91493. */
  91494. uniqueId: number;
  91495. /**
  91496. * Gets or sets a string used to store user defined state for the node
  91497. */
  91498. state: string;
  91499. /**
  91500. * Gets or sets an object used to store user defined information for the node
  91501. */
  91502. metadata: any;
  91503. /**
  91504. * For internal use only. Please do not use.
  91505. */
  91506. reservedDataStore: any;
  91507. /**
  91508. * List of inspectable custom properties (used by the Inspector)
  91509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91510. */
  91511. inspectableCustomProperties: IInspectable[];
  91512. /**
  91513. * Gets or sets a boolean used to define if the node must be serialized
  91514. */
  91515. doNotSerialize: boolean;
  91516. /** @hidden */
  91517. _isDisposed: boolean;
  91518. /**
  91519. * Gets a list of Animations associated with the node
  91520. */
  91521. animations: Animation[];
  91522. protected _ranges: {
  91523. [name: string]: Nullable<AnimationRange>;
  91524. };
  91525. /**
  91526. * Callback raised when the node is ready to be used
  91527. */
  91528. onReady: Nullable<(node: Node) => void>;
  91529. private _isEnabled;
  91530. private _isParentEnabled;
  91531. private _isReady;
  91532. /** @hidden */
  91533. _currentRenderId: number;
  91534. private _parentUpdateId;
  91535. /** @hidden */
  91536. _childUpdateId: number;
  91537. /** @hidden */
  91538. _waitingParentId: Nullable<string>;
  91539. /** @hidden */
  91540. _scene: Scene;
  91541. /** @hidden */
  91542. _cache: any;
  91543. private _parentNode;
  91544. private _children;
  91545. /** @hidden */
  91546. _worldMatrix: Matrix;
  91547. /** @hidden */
  91548. _worldMatrixDeterminant: number;
  91549. /** @hidden */
  91550. _worldMatrixDeterminantIsDirty: boolean;
  91551. /** @hidden */
  91552. private _sceneRootNodesIndex;
  91553. /**
  91554. * Gets a boolean indicating if the node has been disposed
  91555. * @returns true if the node was disposed
  91556. */
  91557. isDisposed(): boolean;
  91558. /**
  91559. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91560. * @see https://doc.babylonjs.com/how_to/parenting
  91561. */
  91562. parent: Nullable<Node>;
  91563. private addToSceneRootNodes;
  91564. private removeFromSceneRootNodes;
  91565. private _animationPropertiesOverride;
  91566. /**
  91567. * Gets or sets the animation properties override
  91568. */
  91569. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91570. /**
  91571. * Gets a string idenfifying the name of the class
  91572. * @returns "Node" string
  91573. */
  91574. getClassName(): string;
  91575. /** @hidden */
  91576. readonly _isNode: boolean;
  91577. /**
  91578. * An event triggered when the mesh is disposed
  91579. */
  91580. onDisposeObservable: Observable<Node>;
  91581. private _onDisposeObserver;
  91582. /**
  91583. * Sets a callback that will be raised when the node will be disposed
  91584. */
  91585. onDispose: () => void;
  91586. /**
  91587. * Creates a new Node
  91588. * @param name the name and id to be given to this node
  91589. * @param scene the scene this node will be added to
  91590. * @param addToRootNodes the node will be added to scene.rootNodes
  91591. */
  91592. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91593. /**
  91594. * Gets the scene of the node
  91595. * @returns a scene
  91596. */
  91597. getScene(): Scene;
  91598. /**
  91599. * Gets the engine of the node
  91600. * @returns a Engine
  91601. */
  91602. getEngine(): Engine;
  91603. private _behaviors;
  91604. /**
  91605. * Attach a behavior to the node
  91606. * @see http://doc.babylonjs.com/features/behaviour
  91607. * @param behavior defines the behavior to attach
  91608. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91609. * @returns the current Node
  91610. */
  91611. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91612. /**
  91613. * Remove an attached behavior
  91614. * @see http://doc.babylonjs.com/features/behaviour
  91615. * @param behavior defines the behavior to attach
  91616. * @returns the current Node
  91617. */
  91618. removeBehavior(behavior: Behavior<Node>): Node;
  91619. /**
  91620. * Gets the list of attached behaviors
  91621. * @see http://doc.babylonjs.com/features/behaviour
  91622. */
  91623. readonly behaviors: Behavior<Node>[];
  91624. /**
  91625. * Gets an attached behavior by name
  91626. * @param name defines the name of the behavior to look for
  91627. * @see http://doc.babylonjs.com/features/behaviour
  91628. * @returns null if behavior was not found else the requested behavior
  91629. */
  91630. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91631. /**
  91632. * Returns the latest update of the World matrix
  91633. * @returns a Matrix
  91634. */
  91635. getWorldMatrix(): Matrix;
  91636. /** @hidden */
  91637. _getWorldMatrixDeterminant(): number;
  91638. /**
  91639. * Returns directly the latest state of the mesh World matrix.
  91640. * A Matrix is returned.
  91641. */
  91642. readonly worldMatrixFromCache: Matrix;
  91643. /** @hidden */
  91644. _initCache(): void;
  91645. /** @hidden */
  91646. updateCache(force?: boolean): void;
  91647. /** @hidden */
  91648. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91649. /** @hidden */
  91650. _updateCache(ignoreParentClass?: boolean): void;
  91651. /** @hidden */
  91652. _isSynchronized(): boolean;
  91653. /** @hidden */
  91654. _markSyncedWithParent(): void;
  91655. /** @hidden */
  91656. isSynchronizedWithParent(): boolean;
  91657. /** @hidden */
  91658. isSynchronized(): boolean;
  91659. /**
  91660. * Is this node ready to be used/rendered
  91661. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91662. * @return true if the node is ready
  91663. */
  91664. isReady(completeCheck?: boolean): boolean;
  91665. /**
  91666. * Is this node enabled?
  91667. * 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
  91668. * @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
  91669. * @return whether this node (and its parent) is enabled
  91670. */
  91671. isEnabled(checkAncestors?: boolean): boolean;
  91672. /** @hidden */
  91673. protected _syncParentEnabledState(): void;
  91674. /**
  91675. * Set the enabled state of this node
  91676. * @param value defines the new enabled state
  91677. */
  91678. setEnabled(value: boolean): void;
  91679. /**
  91680. * Is this node a descendant of the given node?
  91681. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91682. * @param ancestor defines the parent node to inspect
  91683. * @returns a boolean indicating if this node is a descendant of the given node
  91684. */
  91685. isDescendantOf(ancestor: Node): boolean;
  91686. /** @hidden */
  91687. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91688. /**
  91689. * Will return all nodes that have this node as ascendant
  91690. * @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
  91691. * @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
  91692. * @return all children nodes of all types
  91693. */
  91694. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91695. /**
  91696. * Get all child-meshes of this node
  91697. * @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)
  91698. * @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
  91699. * @returns an array of AbstractMesh
  91700. */
  91701. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91702. /**
  91703. * Get all direct children of this node
  91704. * @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
  91705. * @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)
  91706. * @returns an array of Node
  91707. */
  91708. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91709. /** @hidden */
  91710. _setReady(state: boolean): void;
  91711. /**
  91712. * Get an animation by name
  91713. * @param name defines the name of the animation to look for
  91714. * @returns null if not found else the requested animation
  91715. */
  91716. getAnimationByName(name: string): Nullable<Animation>;
  91717. /**
  91718. * Creates an animation range for this node
  91719. * @param name defines the name of the range
  91720. * @param from defines the starting key
  91721. * @param to defines the end key
  91722. */
  91723. createAnimationRange(name: string, from: number, to: number): void;
  91724. /**
  91725. * Delete a specific animation range
  91726. * @param name defines the name of the range to delete
  91727. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91728. */
  91729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91730. /**
  91731. * Get an animation range by name
  91732. * @param name defines the name of the animation range to look for
  91733. * @returns null if not found else the requested animation range
  91734. */
  91735. getAnimationRange(name: string): Nullable<AnimationRange>;
  91736. /**
  91737. * Gets the list of all animation ranges defined on this node
  91738. * @returns an array
  91739. */
  91740. getAnimationRanges(): Nullable<AnimationRange>[];
  91741. /**
  91742. * Will start the animation sequence
  91743. * @param name defines the range frames for animation sequence
  91744. * @param loop defines if the animation should loop (false by default)
  91745. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91746. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91747. * @returns the object created for this animation. If range does not exist, it will return null
  91748. */
  91749. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91750. /**
  91751. * Serialize animation ranges into a JSON compatible object
  91752. * @returns serialization object
  91753. */
  91754. serializeAnimationRanges(): any;
  91755. /**
  91756. * Computes the world matrix of the node
  91757. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91758. * @returns the world matrix
  91759. */
  91760. computeWorldMatrix(force?: boolean): Matrix;
  91761. /**
  91762. * Releases resources associated with this node.
  91763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91765. */
  91766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91767. /**
  91768. * Parse animation range data from a serialization object and store them into a given node
  91769. * @param node defines where to store the animation ranges
  91770. * @param parsedNode defines the serialization object to read data from
  91771. * @param scene defines the hosting scene
  91772. */
  91773. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91774. /**
  91775. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91776. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91777. * @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
  91778. * @returns the new bounding vectors
  91779. */
  91780. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91781. min: Vector3;
  91782. max: Vector3;
  91783. };
  91784. }
  91785. }
  91786. declare module BABYLON {
  91787. /**
  91788. * @hidden
  91789. */
  91790. export class _IAnimationState {
  91791. key: number;
  91792. repeatCount: number;
  91793. workValue?: any;
  91794. loopMode?: number;
  91795. offsetValue?: any;
  91796. highLimitValue?: any;
  91797. }
  91798. /**
  91799. * Class used to store any kind of animation
  91800. */
  91801. export class Animation {
  91802. /**Name of the animation */
  91803. name: string;
  91804. /**Property to animate */
  91805. targetProperty: string;
  91806. /**The frames per second of the animation */
  91807. framePerSecond: number;
  91808. /**The data type of the animation */
  91809. dataType: number;
  91810. /**The loop mode of the animation */
  91811. loopMode?: number | undefined;
  91812. /**Specifies if blending should be enabled */
  91813. enableBlending?: boolean | undefined;
  91814. /**
  91815. * Use matrix interpolation instead of using direct key value when animating matrices
  91816. */
  91817. static AllowMatricesInterpolation: boolean;
  91818. /**
  91819. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91820. */
  91821. static AllowMatrixDecomposeForInterpolation: boolean;
  91822. /**
  91823. * Stores the key frames of the animation
  91824. */
  91825. private _keys;
  91826. /**
  91827. * Stores the easing function of the animation
  91828. */
  91829. private _easingFunction;
  91830. /**
  91831. * @hidden Internal use only
  91832. */
  91833. _runtimeAnimations: RuntimeAnimation[];
  91834. /**
  91835. * The set of event that will be linked to this animation
  91836. */
  91837. private _events;
  91838. /**
  91839. * Stores an array of target property paths
  91840. */
  91841. targetPropertyPath: string[];
  91842. /**
  91843. * Stores the blending speed of the animation
  91844. */
  91845. blendingSpeed: number;
  91846. /**
  91847. * Stores the animation ranges for the animation
  91848. */
  91849. private _ranges;
  91850. /**
  91851. * @hidden Internal use
  91852. */
  91853. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91854. /**
  91855. * Sets up an animation
  91856. * @param property The property to animate
  91857. * @param animationType The animation type to apply
  91858. * @param framePerSecond The frames per second of the animation
  91859. * @param easingFunction The easing function used in the animation
  91860. * @returns The created animation
  91861. */
  91862. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91863. /**
  91864. * Create and start an animation on a node
  91865. * @param name defines the name of the global animation that will be run on all nodes
  91866. * @param node defines the root node where the animation will take place
  91867. * @param targetProperty defines property to animate
  91868. * @param framePerSecond defines the number of frame per second yo use
  91869. * @param totalFrame defines the number of frames in total
  91870. * @param from defines the initial value
  91871. * @param to defines the final value
  91872. * @param loopMode defines which loop mode you want to use (off by default)
  91873. * @param easingFunction defines the easing function to use (linear by default)
  91874. * @param onAnimationEnd defines the callback to call when animation end
  91875. * @returns the animatable created for this animation
  91876. */
  91877. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91878. /**
  91879. * Create and start an animation on a node and its descendants
  91880. * @param name defines the name of the global animation that will be run on all nodes
  91881. * @param node defines the root node where the animation will take place
  91882. * @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
  91883. * @param targetProperty defines property to animate
  91884. * @param framePerSecond defines the number of frame per second to use
  91885. * @param totalFrame defines the number of frames in total
  91886. * @param from defines the initial value
  91887. * @param to defines the final value
  91888. * @param loopMode defines which loop mode you want to use (off by default)
  91889. * @param easingFunction defines the easing function to use (linear by default)
  91890. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91891. * @returns the list of animatables created for all nodes
  91892. * @example https://www.babylonjs-playground.com/#MH0VLI
  91893. */
  91894. 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[]>;
  91895. /**
  91896. * Creates a new animation, merges it with the existing animations and starts it
  91897. * @param name Name of the animation
  91898. * @param node Node which contains the scene that begins the animations
  91899. * @param targetProperty Specifies which property to animate
  91900. * @param framePerSecond The frames per second of the animation
  91901. * @param totalFrame The total number of frames
  91902. * @param from The frame at the beginning of the animation
  91903. * @param to The frame at the end of the animation
  91904. * @param loopMode Specifies the loop mode of the animation
  91905. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91906. * @param onAnimationEnd Callback to run once the animation is complete
  91907. * @returns Nullable animation
  91908. */
  91909. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91910. /**
  91911. * Transition property of an host to the target Value
  91912. * @param property The property to transition
  91913. * @param targetValue The target Value of the property
  91914. * @param host The object where the property to animate belongs
  91915. * @param scene Scene used to run the animation
  91916. * @param frameRate Framerate (in frame/s) to use
  91917. * @param transition The transition type we want to use
  91918. * @param duration The duration of the animation, in milliseconds
  91919. * @param onAnimationEnd Callback trigger at the end of the animation
  91920. * @returns Nullable animation
  91921. */
  91922. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91923. /**
  91924. * Return the array of runtime animations currently using this animation
  91925. */
  91926. readonly runtimeAnimations: RuntimeAnimation[];
  91927. /**
  91928. * Specifies if any of the runtime animations are currently running
  91929. */
  91930. readonly hasRunningRuntimeAnimations: boolean;
  91931. /**
  91932. * Initializes the animation
  91933. * @param name Name of the animation
  91934. * @param targetProperty Property to animate
  91935. * @param framePerSecond The frames per second of the animation
  91936. * @param dataType The data type of the animation
  91937. * @param loopMode The loop mode of the animation
  91938. * @param enableBlending Specifies if blending should be enabled
  91939. */
  91940. constructor(
  91941. /**Name of the animation */
  91942. name: string,
  91943. /**Property to animate */
  91944. targetProperty: string,
  91945. /**The frames per second of the animation */
  91946. framePerSecond: number,
  91947. /**The data type of the animation */
  91948. dataType: number,
  91949. /**The loop mode of the animation */
  91950. loopMode?: number | undefined,
  91951. /**Specifies if blending should be enabled */
  91952. enableBlending?: boolean | undefined);
  91953. /**
  91954. * Converts the animation to a string
  91955. * @param fullDetails support for multiple levels of logging within scene loading
  91956. * @returns String form of the animation
  91957. */
  91958. toString(fullDetails?: boolean): string;
  91959. /**
  91960. * Add an event to this animation
  91961. * @param event Event to add
  91962. */
  91963. addEvent(event: AnimationEvent): void;
  91964. /**
  91965. * Remove all events found at the given frame
  91966. * @param frame The frame to remove events from
  91967. */
  91968. removeEvents(frame: number): void;
  91969. /**
  91970. * Retrieves all the events from the animation
  91971. * @returns Events from the animation
  91972. */
  91973. getEvents(): AnimationEvent[];
  91974. /**
  91975. * Creates an animation range
  91976. * @param name Name of the animation range
  91977. * @param from Starting frame of the animation range
  91978. * @param to Ending frame of the animation
  91979. */
  91980. createRange(name: string, from: number, to: number): void;
  91981. /**
  91982. * Deletes an animation range by name
  91983. * @param name Name of the animation range to delete
  91984. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91985. */
  91986. deleteRange(name: string, deleteFrames?: boolean): void;
  91987. /**
  91988. * Gets the animation range by name, or null if not defined
  91989. * @param name Name of the animation range
  91990. * @returns Nullable animation range
  91991. */
  91992. getRange(name: string): Nullable<AnimationRange>;
  91993. /**
  91994. * Gets the key frames from the animation
  91995. * @returns The key frames of the animation
  91996. */
  91997. getKeys(): Array<IAnimationKey>;
  91998. /**
  91999. * Gets the highest frame rate of the animation
  92000. * @returns Highest frame rate of the animation
  92001. */
  92002. getHighestFrame(): number;
  92003. /**
  92004. * Gets the easing function of the animation
  92005. * @returns Easing function of the animation
  92006. */
  92007. getEasingFunction(): IEasingFunction;
  92008. /**
  92009. * Sets the easing function of the animation
  92010. * @param easingFunction A custom mathematical formula for animation
  92011. */
  92012. setEasingFunction(easingFunction: EasingFunction): void;
  92013. /**
  92014. * Interpolates a scalar linearly
  92015. * @param startValue Start value of the animation curve
  92016. * @param endValue End value of the animation curve
  92017. * @param gradient Scalar amount to interpolate
  92018. * @returns Interpolated scalar value
  92019. */
  92020. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92021. /**
  92022. * Interpolates a scalar cubically
  92023. * @param startValue Start value of the animation curve
  92024. * @param outTangent End tangent of the animation
  92025. * @param endValue End value of the animation curve
  92026. * @param inTangent Start tangent of the animation curve
  92027. * @param gradient Scalar amount to interpolate
  92028. * @returns Interpolated scalar value
  92029. */
  92030. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92031. /**
  92032. * Interpolates a quaternion using a spherical linear interpolation
  92033. * @param startValue Start value of the animation curve
  92034. * @param endValue End value of the animation curve
  92035. * @param gradient Scalar amount to interpolate
  92036. * @returns Interpolated quaternion value
  92037. */
  92038. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92039. /**
  92040. * Interpolates a quaternion cubically
  92041. * @param startValue Start value of the animation curve
  92042. * @param outTangent End tangent of the animation curve
  92043. * @param endValue End value of the animation curve
  92044. * @param inTangent Start tangent of the animation curve
  92045. * @param gradient Scalar amount to interpolate
  92046. * @returns Interpolated quaternion value
  92047. */
  92048. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92049. /**
  92050. * Interpolates a Vector3 linearl
  92051. * @param startValue Start value of the animation curve
  92052. * @param endValue End value of the animation curve
  92053. * @param gradient Scalar amount to interpolate
  92054. * @returns Interpolated scalar value
  92055. */
  92056. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92057. /**
  92058. * Interpolates a Vector3 cubically
  92059. * @param startValue Start value of the animation curve
  92060. * @param outTangent End tangent of the animation
  92061. * @param endValue End value of the animation curve
  92062. * @param inTangent Start tangent of the animation curve
  92063. * @param gradient Scalar amount to interpolate
  92064. * @returns InterpolatedVector3 value
  92065. */
  92066. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92067. /**
  92068. * Interpolates a Vector2 linearly
  92069. * @param startValue Start value of the animation curve
  92070. * @param endValue End value of the animation curve
  92071. * @param gradient Scalar amount to interpolate
  92072. * @returns Interpolated Vector2 value
  92073. */
  92074. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92075. /**
  92076. * Interpolates a Vector2 cubically
  92077. * @param startValue Start value of the animation curve
  92078. * @param outTangent End tangent of the animation
  92079. * @param endValue End value of the animation curve
  92080. * @param inTangent Start tangent of the animation curve
  92081. * @param gradient Scalar amount to interpolate
  92082. * @returns Interpolated Vector2 value
  92083. */
  92084. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92085. /**
  92086. * Interpolates a size linearly
  92087. * @param startValue Start value of the animation curve
  92088. * @param endValue End value of the animation curve
  92089. * @param gradient Scalar amount to interpolate
  92090. * @returns Interpolated Size value
  92091. */
  92092. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92093. /**
  92094. * Interpolates a Color3 linearly
  92095. * @param startValue Start value of the animation curve
  92096. * @param endValue End value of the animation curve
  92097. * @param gradient Scalar amount to interpolate
  92098. * @returns Interpolated Color3 value
  92099. */
  92100. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92101. /**
  92102. * @hidden Internal use only
  92103. */
  92104. _getKeyValue(value: any): any;
  92105. /**
  92106. * @hidden Internal use only
  92107. */
  92108. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92109. /**
  92110. * Defines the function to use to interpolate matrices
  92111. * @param startValue defines the start matrix
  92112. * @param endValue defines the end matrix
  92113. * @param gradient defines the gradient between both matrices
  92114. * @param result defines an optional target matrix where to store the interpolation
  92115. * @returns the interpolated matrix
  92116. */
  92117. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92118. /**
  92119. * Makes a copy of the animation
  92120. * @returns Cloned animation
  92121. */
  92122. clone(): Animation;
  92123. /**
  92124. * Sets the key frames of the animation
  92125. * @param values The animation key frames to set
  92126. */
  92127. setKeys(values: Array<IAnimationKey>): void;
  92128. /**
  92129. * Serializes the animation to an object
  92130. * @returns Serialized object
  92131. */
  92132. serialize(): any;
  92133. /**
  92134. * Float animation type
  92135. */
  92136. private static _ANIMATIONTYPE_FLOAT;
  92137. /**
  92138. * Vector3 animation type
  92139. */
  92140. private static _ANIMATIONTYPE_VECTOR3;
  92141. /**
  92142. * Quaternion animation type
  92143. */
  92144. private static _ANIMATIONTYPE_QUATERNION;
  92145. /**
  92146. * Matrix animation type
  92147. */
  92148. private static _ANIMATIONTYPE_MATRIX;
  92149. /**
  92150. * Color3 animation type
  92151. */
  92152. private static _ANIMATIONTYPE_COLOR3;
  92153. /**
  92154. * Vector2 animation type
  92155. */
  92156. private static _ANIMATIONTYPE_VECTOR2;
  92157. /**
  92158. * Size animation type
  92159. */
  92160. private static _ANIMATIONTYPE_SIZE;
  92161. /**
  92162. * Relative Loop Mode
  92163. */
  92164. private static _ANIMATIONLOOPMODE_RELATIVE;
  92165. /**
  92166. * Cycle Loop Mode
  92167. */
  92168. private static _ANIMATIONLOOPMODE_CYCLE;
  92169. /**
  92170. * Constant Loop Mode
  92171. */
  92172. private static _ANIMATIONLOOPMODE_CONSTANT;
  92173. /**
  92174. * Get the float animation type
  92175. */
  92176. static readonly ANIMATIONTYPE_FLOAT: number;
  92177. /**
  92178. * Get the Vector3 animation type
  92179. */
  92180. static readonly ANIMATIONTYPE_VECTOR3: number;
  92181. /**
  92182. * Get the Vector2 animation type
  92183. */
  92184. static readonly ANIMATIONTYPE_VECTOR2: number;
  92185. /**
  92186. * Get the Size animation type
  92187. */
  92188. static readonly ANIMATIONTYPE_SIZE: number;
  92189. /**
  92190. * Get the Quaternion animation type
  92191. */
  92192. static readonly ANIMATIONTYPE_QUATERNION: number;
  92193. /**
  92194. * Get the Matrix animation type
  92195. */
  92196. static readonly ANIMATIONTYPE_MATRIX: number;
  92197. /**
  92198. * Get the Color3 animation type
  92199. */
  92200. static readonly ANIMATIONTYPE_COLOR3: number;
  92201. /**
  92202. * Get the Relative Loop Mode
  92203. */
  92204. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92205. /**
  92206. * Get the Cycle Loop Mode
  92207. */
  92208. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92209. /**
  92210. * Get the Constant Loop Mode
  92211. */
  92212. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92213. /** @hidden */
  92214. static _UniversalLerp(left: any, right: any, amount: number): any;
  92215. /**
  92216. * Parses an animation object and creates an animation
  92217. * @param parsedAnimation Parsed animation object
  92218. * @returns Animation object
  92219. */
  92220. static Parse(parsedAnimation: any): Animation;
  92221. /**
  92222. * Appends the serialized animations from the source animations
  92223. * @param source Source containing the animations
  92224. * @param destination Target to store the animations
  92225. */
  92226. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92227. }
  92228. }
  92229. declare module BABYLON {
  92230. /**
  92231. * Interface containing an array of animations
  92232. */
  92233. export interface IAnimatable {
  92234. /**
  92235. * Array of animations
  92236. */
  92237. animations: Nullable<Array<Animation>>;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /**
  92242. * This represents all the required information to add a fresnel effect on a material:
  92243. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92244. */
  92245. export class FresnelParameters {
  92246. private _isEnabled;
  92247. /**
  92248. * Define if the fresnel effect is enable or not.
  92249. */
  92250. isEnabled: boolean;
  92251. /**
  92252. * Define the color used on edges (grazing angle)
  92253. */
  92254. leftColor: Color3;
  92255. /**
  92256. * Define the color used on center
  92257. */
  92258. rightColor: Color3;
  92259. /**
  92260. * Define bias applied to computed fresnel term
  92261. */
  92262. bias: number;
  92263. /**
  92264. * Defined the power exponent applied to fresnel term
  92265. */
  92266. power: number;
  92267. /**
  92268. * Clones the current fresnel and its valuues
  92269. * @returns a clone fresnel configuration
  92270. */
  92271. clone(): FresnelParameters;
  92272. /**
  92273. * Serializes the current fresnel parameters to a JSON representation.
  92274. * @return the JSON serialization
  92275. */
  92276. serialize(): any;
  92277. /**
  92278. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92279. * @param parsedFresnelParameters Define the JSON representation
  92280. * @returns the parsed parameters
  92281. */
  92282. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92283. }
  92284. }
  92285. declare module BABYLON {
  92286. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92287. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92288. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92289. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92290. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92291. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92292. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92293. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92294. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92295. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92296. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92297. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92298. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92299. /**
  92300. * Decorator used to define property that can be serialized as reference to a camera
  92301. * @param sourceName defines the name of the property to decorate
  92302. */
  92303. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92304. /**
  92305. * Class used to help serialization objects
  92306. */
  92307. export class SerializationHelper {
  92308. /** @hidden */
  92309. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92310. /** @hidden */
  92311. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92312. /** @hidden */
  92313. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92314. /** @hidden */
  92315. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92316. /**
  92317. * Appends the serialized animations from the source animations
  92318. * @param source Source containing the animations
  92319. * @param destination Target to store the animations
  92320. */
  92321. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92322. /**
  92323. * Static function used to serialized a specific entity
  92324. * @param entity defines the entity to serialize
  92325. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92326. * @returns a JSON compatible object representing the serialization of the entity
  92327. */
  92328. static Serialize<T>(entity: T, serializationObject?: any): any;
  92329. /**
  92330. * Creates a new entity from a serialization data object
  92331. * @param creationFunction defines a function used to instanciated the new entity
  92332. * @param source defines the source serialization data
  92333. * @param scene defines the hosting scene
  92334. * @param rootUrl defines the root url for resources
  92335. * @returns a new entity
  92336. */
  92337. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92338. /**
  92339. * Clones an object
  92340. * @param creationFunction defines the function used to instanciate the new object
  92341. * @param source defines the source object
  92342. * @returns the cloned object
  92343. */
  92344. static Clone<T>(creationFunction: () => T, source: T): T;
  92345. /**
  92346. * Instanciates a new object based on a source one (some data will be shared between both object)
  92347. * @param creationFunction defines the function used to instanciate the new object
  92348. * @param source defines the source object
  92349. * @returns the new object
  92350. */
  92351. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92352. }
  92353. }
  92354. declare module BABYLON {
  92355. /**
  92356. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92357. */
  92358. export interface CubeMapInfo {
  92359. /**
  92360. * The pixel array for the front face.
  92361. * This is stored in format, left to right, up to down format.
  92362. */
  92363. front: Nullable<ArrayBufferView>;
  92364. /**
  92365. * The pixel array for the back face.
  92366. * This is stored in format, left to right, up to down format.
  92367. */
  92368. back: Nullable<ArrayBufferView>;
  92369. /**
  92370. * The pixel array for the left face.
  92371. * This is stored in format, left to right, up to down format.
  92372. */
  92373. left: Nullable<ArrayBufferView>;
  92374. /**
  92375. * The pixel array for the right face.
  92376. * This is stored in format, left to right, up to down format.
  92377. */
  92378. right: Nullable<ArrayBufferView>;
  92379. /**
  92380. * The pixel array for the up face.
  92381. * This is stored in format, left to right, up to down format.
  92382. */
  92383. up: Nullable<ArrayBufferView>;
  92384. /**
  92385. * The pixel array for the down face.
  92386. * This is stored in format, left to right, up to down format.
  92387. */
  92388. down: Nullable<ArrayBufferView>;
  92389. /**
  92390. * The size of the cubemap stored.
  92391. *
  92392. * Each faces will be size * size pixels.
  92393. */
  92394. size: number;
  92395. /**
  92396. * The format of the texture.
  92397. *
  92398. * RGBA, RGB.
  92399. */
  92400. format: number;
  92401. /**
  92402. * The type of the texture data.
  92403. *
  92404. * UNSIGNED_INT, FLOAT.
  92405. */
  92406. type: number;
  92407. /**
  92408. * Specifies whether the texture is in gamma space.
  92409. */
  92410. gammaSpace: boolean;
  92411. }
  92412. /**
  92413. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  92414. */
  92415. export class PanoramaToCubeMapTools {
  92416. private static FACE_FRONT;
  92417. private static FACE_BACK;
  92418. private static FACE_RIGHT;
  92419. private static FACE_LEFT;
  92420. private static FACE_DOWN;
  92421. private static FACE_UP;
  92422. /**
  92423. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92424. *
  92425. * @param float32Array The source data.
  92426. * @param inputWidth The width of the input panorama.
  92427. * @param inputHeight The height of the input panorama.
  92428. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92429. * @return The cubemap data
  92430. */
  92431. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92432. private static CreateCubemapTexture;
  92433. private static CalcProjectionSpherical;
  92434. }
  92435. }
  92436. declare module BABYLON {
  92437. /**
  92438. * Helper class dealing with the extraction of spherical polynomial dataArray
  92439. * from a cube map.
  92440. */
  92441. export class CubeMapToSphericalPolynomialTools {
  92442. private static FileFaces;
  92443. /**
  92444. * Converts a texture to the according Spherical Polynomial data.
  92445. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92446. *
  92447. * @param texture The texture to extract the information from.
  92448. * @return The Spherical Polynomial data.
  92449. */
  92450. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92451. /**
  92452. * Converts a cubemap to the according Spherical Polynomial data.
  92453. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92454. *
  92455. * @param cubeInfo The Cube map to extract the information from.
  92456. * @return The Spherical Polynomial data.
  92457. */
  92458. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92459. }
  92460. }
  92461. declare module BABYLON {
  92462. /**
  92463. * Class used to manipulate GUIDs
  92464. */
  92465. export class GUID {
  92466. /**
  92467. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92468. * Be aware Math.random() could cause collisions, but:
  92469. * "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"
  92470. * @returns a pseudo random id
  92471. */
  92472. static RandomId(): string;
  92473. }
  92474. }
  92475. declare module BABYLON {
  92476. /**
  92477. * Base class of all the textures in babylon.
  92478. * It groups all the common properties the materials, post process, lights... might need
  92479. * in order to make a correct use of the texture.
  92480. */
  92481. export class BaseTexture implements IAnimatable {
  92482. /**
  92483. * Default anisotropic filtering level for the application.
  92484. * It is set to 4 as a good tradeoff between perf and quality.
  92485. */
  92486. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92487. /**
  92488. * Gets or sets the unique id of the texture
  92489. */
  92490. uniqueId: number;
  92491. /**
  92492. * Define the name of the texture.
  92493. */
  92494. name: string;
  92495. /**
  92496. * Gets or sets an object used to store user defined information.
  92497. */
  92498. metadata: any;
  92499. /**
  92500. * For internal use only. Please do not use.
  92501. */
  92502. reservedDataStore: any;
  92503. private _hasAlpha;
  92504. /**
  92505. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92506. */
  92507. hasAlpha: boolean;
  92508. /**
  92509. * Defines if the alpha value should be determined via the rgb values.
  92510. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92511. */
  92512. getAlphaFromRGB: boolean;
  92513. /**
  92514. * Intensity or strength of the texture.
  92515. * It is commonly used by materials to fine tune the intensity of the texture
  92516. */
  92517. level: number;
  92518. /**
  92519. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92520. * This is part of the texture as textures usually maps to one uv set.
  92521. */
  92522. coordinatesIndex: number;
  92523. private _coordinatesMode;
  92524. /**
  92525. * How a texture is mapped.
  92526. *
  92527. * | Value | Type | Description |
  92528. * | ----- | ----------------------------------- | ----------- |
  92529. * | 0 | EXPLICIT_MODE | |
  92530. * | 1 | SPHERICAL_MODE | |
  92531. * | 2 | PLANAR_MODE | |
  92532. * | 3 | CUBIC_MODE | |
  92533. * | 4 | PROJECTION_MODE | |
  92534. * | 5 | SKYBOX_MODE | |
  92535. * | 6 | INVCUBIC_MODE | |
  92536. * | 7 | EQUIRECTANGULAR_MODE | |
  92537. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92538. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92539. */
  92540. coordinatesMode: number;
  92541. /**
  92542. * | Value | Type | Description |
  92543. * | ----- | ------------------ | ----------- |
  92544. * | 0 | CLAMP_ADDRESSMODE | |
  92545. * | 1 | WRAP_ADDRESSMODE | |
  92546. * | 2 | MIRROR_ADDRESSMODE | |
  92547. */
  92548. wrapU: number;
  92549. /**
  92550. * | Value | Type | Description |
  92551. * | ----- | ------------------ | ----------- |
  92552. * | 0 | CLAMP_ADDRESSMODE | |
  92553. * | 1 | WRAP_ADDRESSMODE | |
  92554. * | 2 | MIRROR_ADDRESSMODE | |
  92555. */
  92556. wrapV: number;
  92557. /**
  92558. * | Value | Type | Description |
  92559. * | ----- | ------------------ | ----------- |
  92560. * | 0 | CLAMP_ADDRESSMODE | |
  92561. * | 1 | WRAP_ADDRESSMODE | |
  92562. * | 2 | MIRROR_ADDRESSMODE | |
  92563. */
  92564. wrapR: number;
  92565. /**
  92566. * With compliant hardware and browser (supporting anisotropic filtering)
  92567. * this defines the level of anisotropic filtering in the texture.
  92568. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92569. */
  92570. anisotropicFilteringLevel: number;
  92571. /**
  92572. * Define if the texture is a cube texture or if false a 2d texture.
  92573. */
  92574. isCube: boolean;
  92575. /**
  92576. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92577. */
  92578. is3D: boolean;
  92579. /**
  92580. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92581. * HDR texture are usually stored in linear space.
  92582. * This only impacts the PBR and Background materials
  92583. */
  92584. gammaSpace: boolean;
  92585. /**
  92586. * Gets whether or not the texture contains RGBD data.
  92587. */
  92588. readonly isRGBD: boolean;
  92589. /**
  92590. * Is Z inverted in the texture (useful in a cube texture).
  92591. */
  92592. invertZ: boolean;
  92593. /**
  92594. * Are mip maps generated for this texture or not.
  92595. */
  92596. readonly noMipmap: boolean;
  92597. /**
  92598. * @hidden
  92599. */
  92600. lodLevelInAlpha: boolean;
  92601. /**
  92602. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92603. */
  92604. lodGenerationOffset: number;
  92605. /**
  92606. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92607. */
  92608. lodGenerationScale: number;
  92609. /**
  92610. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92611. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92612. * average roughness values.
  92613. */
  92614. linearSpecularLOD: boolean;
  92615. /**
  92616. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92617. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92618. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92619. */
  92620. irradianceTexture: Nullable<BaseTexture>;
  92621. /**
  92622. * Define if the texture is a render target.
  92623. */
  92624. isRenderTarget: boolean;
  92625. /**
  92626. * Define the unique id of the texture in the scene.
  92627. */
  92628. readonly uid: string;
  92629. /**
  92630. * Return a string representation of the texture.
  92631. * @returns the texture as a string
  92632. */
  92633. toString(): string;
  92634. /**
  92635. * Get the class name of the texture.
  92636. * @returns "BaseTexture"
  92637. */
  92638. getClassName(): string;
  92639. /**
  92640. * Define the list of animation attached to the texture.
  92641. */
  92642. animations: Animation[];
  92643. /**
  92644. * An event triggered when the texture is disposed.
  92645. */
  92646. onDisposeObservable: Observable<BaseTexture>;
  92647. private _onDisposeObserver;
  92648. /**
  92649. * Callback triggered when the texture has been disposed.
  92650. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92651. */
  92652. onDispose: () => void;
  92653. /**
  92654. * Define the current state of the loading sequence when in delayed load mode.
  92655. */
  92656. delayLoadState: number;
  92657. private _scene;
  92658. /** @hidden */
  92659. _texture: Nullable<InternalTexture>;
  92660. private _uid;
  92661. /**
  92662. * Define if the texture is preventinga material to render or not.
  92663. * If not and the texture is not ready, the engine will use a default black texture instead.
  92664. */
  92665. readonly isBlocking: boolean;
  92666. /**
  92667. * Instantiates a new BaseTexture.
  92668. * Base class of all the textures in babylon.
  92669. * It groups all the common properties the materials, post process, lights... might need
  92670. * in order to make a correct use of the texture.
  92671. * @param scene Define the scene the texture blongs to
  92672. */
  92673. constructor(scene: Nullable<Scene>);
  92674. /**
  92675. * Get the scene the texture belongs to.
  92676. * @returns the scene or null if undefined
  92677. */
  92678. getScene(): Nullable<Scene>;
  92679. /**
  92680. * Get the texture transform matrix used to offset tile the texture for istance.
  92681. * @returns the transformation matrix
  92682. */
  92683. getTextureMatrix(): Matrix;
  92684. /**
  92685. * Get the texture reflection matrix used to rotate/transform the reflection.
  92686. * @returns the reflection matrix
  92687. */
  92688. getReflectionTextureMatrix(): Matrix;
  92689. /**
  92690. * Get the underlying lower level texture from Babylon.
  92691. * @returns the insternal texture
  92692. */
  92693. getInternalTexture(): Nullable<InternalTexture>;
  92694. /**
  92695. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92696. * @returns true if ready or not blocking
  92697. */
  92698. isReadyOrNotBlocking(): boolean;
  92699. /**
  92700. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92701. * @returns true if fully ready
  92702. */
  92703. isReady(): boolean;
  92704. private _cachedSize;
  92705. /**
  92706. * Get the size of the texture.
  92707. * @returns the texture size.
  92708. */
  92709. getSize(): ISize;
  92710. /**
  92711. * Get the base size of the texture.
  92712. * It can be different from the size if the texture has been resized for POT for instance
  92713. * @returns the base size
  92714. */
  92715. getBaseSize(): ISize;
  92716. /**
  92717. * Update the sampling mode of the texture.
  92718. * Default is Trilinear mode.
  92719. *
  92720. * | Value | Type | Description |
  92721. * | ----- | ------------------ | ----------- |
  92722. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92723. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92724. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92725. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92726. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92727. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92728. * | 7 | NEAREST_LINEAR | |
  92729. * | 8 | NEAREST_NEAREST | |
  92730. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92731. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92732. * | 11 | LINEAR_LINEAR | |
  92733. * | 12 | LINEAR_NEAREST | |
  92734. *
  92735. * > _mag_: magnification filter (close to the viewer)
  92736. * > _min_: minification filter (far from the viewer)
  92737. * > _mip_: filter used between mip map levels
  92738. *@param samplingMode Define the new sampling mode of the texture
  92739. */
  92740. updateSamplingMode(samplingMode: number): void;
  92741. /**
  92742. * Scales the texture if is `canRescale()`
  92743. * @param ratio the resize factor we want to use to rescale
  92744. */
  92745. scale(ratio: number): void;
  92746. /**
  92747. * Get if the texture can rescale.
  92748. */
  92749. readonly canRescale: boolean;
  92750. /** @hidden */
  92751. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92752. /** @hidden */
  92753. _rebuild(): void;
  92754. /**
  92755. * Triggers the load sequence in delayed load mode.
  92756. */
  92757. delayLoad(): void;
  92758. /**
  92759. * Clones the texture.
  92760. * @returns the cloned texture
  92761. */
  92762. clone(): Nullable<BaseTexture>;
  92763. /**
  92764. * Get the texture underlying type (INT, FLOAT...)
  92765. */
  92766. readonly textureType: number;
  92767. /**
  92768. * Get the texture underlying format (RGB, RGBA...)
  92769. */
  92770. readonly textureFormat: number;
  92771. /**
  92772. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92773. * This will returns an RGBA array buffer containing either in values (0-255) or
  92774. * float values (0-1) depending of the underlying buffer type.
  92775. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92776. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92777. * @param buffer defines a user defined buffer to fill with data (can be null)
  92778. * @returns The Array buffer containing the pixels data.
  92779. */
  92780. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92781. /**
  92782. * Release and destroy the underlying lower level texture aka internalTexture.
  92783. */
  92784. releaseInternalTexture(): void;
  92785. /**
  92786. * Get the polynomial representation of the texture data.
  92787. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92788. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92789. */
  92790. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92791. /** @hidden */
  92792. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92793. /** @hidden */
  92794. readonly _lodTextureMid: Nullable<BaseTexture>;
  92795. /** @hidden */
  92796. readonly _lodTextureLow: Nullable<BaseTexture>;
  92797. /**
  92798. * Dispose the texture and release its associated resources.
  92799. */
  92800. dispose(): void;
  92801. /**
  92802. * Serialize the texture into a JSON representation that can be parsed later on.
  92803. * @returns the JSON representation of the texture
  92804. */
  92805. serialize(): any;
  92806. /**
  92807. * Helper function to be called back once a list of texture contains only ready textures.
  92808. * @param textures Define the list of textures to wait for
  92809. * @param callback Define the callback triggered once the entire list will be ready
  92810. */
  92811. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92812. }
  92813. }
  92814. declare module BABYLON {
  92815. /**
  92816. * Class used to store data associated with WebGL texture data for the engine
  92817. * This class should not be used directly
  92818. */
  92819. export class InternalTexture {
  92820. /** @hidden */
  92821. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92822. /**
  92823. * The source of the texture data is unknown
  92824. */
  92825. static DATASOURCE_UNKNOWN: number;
  92826. /**
  92827. * Texture data comes from an URL
  92828. */
  92829. static DATASOURCE_URL: number;
  92830. /**
  92831. * Texture data is only used for temporary storage
  92832. */
  92833. static DATASOURCE_TEMP: number;
  92834. /**
  92835. * Texture data comes from raw data (ArrayBuffer)
  92836. */
  92837. static DATASOURCE_RAW: number;
  92838. /**
  92839. * Texture content is dynamic (video or dynamic texture)
  92840. */
  92841. static DATASOURCE_DYNAMIC: number;
  92842. /**
  92843. * Texture content is generated by rendering to it
  92844. */
  92845. static DATASOURCE_RENDERTARGET: number;
  92846. /**
  92847. * Texture content is part of a multi render target process
  92848. */
  92849. static DATASOURCE_MULTIRENDERTARGET: number;
  92850. /**
  92851. * Texture data comes from a cube data file
  92852. */
  92853. static DATASOURCE_CUBE: number;
  92854. /**
  92855. * Texture data comes from a raw cube data
  92856. */
  92857. static DATASOURCE_CUBERAW: number;
  92858. /**
  92859. * Texture data come from a prefiltered cube data file
  92860. */
  92861. static DATASOURCE_CUBEPREFILTERED: number;
  92862. /**
  92863. * Texture content is raw 3D data
  92864. */
  92865. static DATASOURCE_RAW3D: number;
  92866. /**
  92867. * Texture content is a depth texture
  92868. */
  92869. static DATASOURCE_DEPTHTEXTURE: number;
  92870. /**
  92871. * Texture data comes from a raw cube data encoded with RGBD
  92872. */
  92873. static DATASOURCE_CUBERAW_RGBD: number;
  92874. /**
  92875. * Defines if the texture is ready
  92876. */
  92877. isReady: boolean;
  92878. /**
  92879. * Defines if the texture is a cube texture
  92880. */
  92881. isCube: boolean;
  92882. /**
  92883. * Defines if the texture contains 3D data
  92884. */
  92885. is3D: boolean;
  92886. /**
  92887. * Defines if the texture contains multiview data
  92888. */
  92889. isMultiview: boolean;
  92890. /**
  92891. * Gets the URL used to load this texture
  92892. */
  92893. url: string;
  92894. /**
  92895. * Gets the sampling mode of the texture
  92896. */
  92897. samplingMode: number;
  92898. /**
  92899. * Gets a boolean indicating if the texture needs mipmaps generation
  92900. */
  92901. generateMipMaps: boolean;
  92902. /**
  92903. * Gets the number of samples used by the texture (WebGL2+ only)
  92904. */
  92905. samples: number;
  92906. /**
  92907. * Gets the type of the texture (int, float...)
  92908. */
  92909. type: number;
  92910. /**
  92911. * Gets the format of the texture (RGB, RGBA...)
  92912. */
  92913. format: number;
  92914. /**
  92915. * Observable called when the texture is loaded
  92916. */
  92917. onLoadedObservable: Observable<InternalTexture>;
  92918. /**
  92919. * Gets the width of the texture
  92920. */
  92921. width: number;
  92922. /**
  92923. * Gets the height of the texture
  92924. */
  92925. height: number;
  92926. /**
  92927. * Gets the depth of the texture
  92928. */
  92929. depth: number;
  92930. /**
  92931. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92932. */
  92933. baseWidth: number;
  92934. /**
  92935. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92936. */
  92937. baseHeight: number;
  92938. /**
  92939. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92940. */
  92941. baseDepth: number;
  92942. /**
  92943. * Gets a boolean indicating if the texture is inverted on Y axis
  92944. */
  92945. invertY: boolean;
  92946. /** @hidden */
  92947. _invertVScale: boolean;
  92948. /** @hidden */
  92949. _associatedChannel: number;
  92950. /** @hidden */
  92951. _dataSource: number;
  92952. /** @hidden */
  92953. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92954. /** @hidden */
  92955. _bufferView: Nullable<ArrayBufferView>;
  92956. /** @hidden */
  92957. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92958. /** @hidden */
  92959. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92960. /** @hidden */
  92961. _size: number;
  92962. /** @hidden */
  92963. _extension: string;
  92964. /** @hidden */
  92965. _files: Nullable<string[]>;
  92966. /** @hidden */
  92967. _workingCanvas: Nullable<HTMLCanvasElement>;
  92968. /** @hidden */
  92969. _workingContext: Nullable<CanvasRenderingContext2D>;
  92970. /** @hidden */
  92971. _framebuffer: Nullable<WebGLFramebuffer>;
  92972. /** @hidden */
  92973. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92974. /** @hidden */
  92975. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92976. /** @hidden */
  92977. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92978. /** @hidden */
  92979. _attachments: Nullable<number[]>;
  92980. /** @hidden */
  92981. _cachedCoordinatesMode: Nullable<number>;
  92982. /** @hidden */
  92983. _cachedWrapU: Nullable<number>;
  92984. /** @hidden */
  92985. _cachedWrapV: Nullable<number>;
  92986. /** @hidden */
  92987. _cachedWrapR: Nullable<number>;
  92988. /** @hidden */
  92989. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92990. /** @hidden */
  92991. _isDisabled: boolean;
  92992. /** @hidden */
  92993. _compression: Nullable<string>;
  92994. /** @hidden */
  92995. _generateStencilBuffer: boolean;
  92996. /** @hidden */
  92997. _generateDepthBuffer: boolean;
  92998. /** @hidden */
  92999. _comparisonFunction: number;
  93000. /** @hidden */
  93001. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93002. /** @hidden */
  93003. _lodGenerationScale: number;
  93004. /** @hidden */
  93005. _lodGenerationOffset: number;
  93006. /** @hidden */
  93007. _colorTextureArray: Nullable<WebGLTexture>;
  93008. /** @hidden */
  93009. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93010. /** @hidden */
  93011. _lodTextureHigh: Nullable<BaseTexture>;
  93012. /** @hidden */
  93013. _lodTextureMid: Nullable<BaseTexture>;
  93014. /** @hidden */
  93015. _lodTextureLow: Nullable<BaseTexture>;
  93016. /** @hidden */
  93017. _isRGBD: boolean;
  93018. /** @hidden */
  93019. _linearSpecularLOD: boolean;
  93020. /** @hidden */
  93021. _irradianceTexture: Nullable<BaseTexture>;
  93022. /** @hidden */
  93023. _webGLTexture: Nullable<WebGLTexture>;
  93024. /** @hidden */
  93025. _references: number;
  93026. private _engine;
  93027. /**
  93028. * Gets the Engine the texture belongs to.
  93029. * @returns The babylon engine
  93030. */
  93031. getEngine(): Engine;
  93032. /**
  93033. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93034. */
  93035. readonly dataSource: number;
  93036. /**
  93037. * Creates a new InternalTexture
  93038. * @param engine defines the engine to use
  93039. * @param dataSource defines the type of data that will be used
  93040. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93041. */
  93042. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93043. /**
  93044. * Increments the number of references (ie. the number of Texture that point to it)
  93045. */
  93046. incrementReferences(): void;
  93047. /**
  93048. * Change the size of the texture (not the size of the content)
  93049. * @param width defines the new width
  93050. * @param height defines the new height
  93051. * @param depth defines the new depth (1 by default)
  93052. */
  93053. updateSize(width: int, height: int, depth?: int): void;
  93054. /** @hidden */
  93055. _rebuild(): void;
  93056. /** @hidden */
  93057. _swapAndDie(target: InternalTexture): void;
  93058. /**
  93059. * Dispose the current allocated resources
  93060. */
  93061. dispose(): void;
  93062. }
  93063. }
  93064. declare module BABYLON {
  93065. /**
  93066. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93067. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93068. */
  93069. export class EffectFallbacks {
  93070. private _defines;
  93071. private _currentRank;
  93072. private _maxRank;
  93073. private _mesh;
  93074. /**
  93075. * Removes the fallback from the bound mesh.
  93076. */
  93077. unBindMesh(): void;
  93078. /**
  93079. * Adds a fallback on the specified property.
  93080. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93081. * @param define The name of the define in the shader
  93082. */
  93083. addFallback(rank: number, define: string): void;
  93084. /**
  93085. * Sets the mesh to use CPU skinning when needing to fallback.
  93086. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93087. * @param mesh The mesh to use the fallbacks.
  93088. */
  93089. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93090. /**
  93091. * Checks to see if more fallbacks are still availible.
  93092. */
  93093. readonly hasMoreFallbacks: boolean;
  93094. /**
  93095. * Removes the defines that should be removed when falling back.
  93096. * @param currentDefines defines the current define statements for the shader.
  93097. * @param effect defines the current effect we try to compile
  93098. * @returns The resulting defines with defines of the current rank removed.
  93099. */
  93100. reduce(currentDefines: string, effect: Effect): string;
  93101. }
  93102. /**
  93103. * Options to be used when creating an effect.
  93104. */
  93105. export class EffectCreationOptions {
  93106. /**
  93107. * Atrributes that will be used in the shader.
  93108. */
  93109. attributes: string[];
  93110. /**
  93111. * Uniform varible names that will be set in the shader.
  93112. */
  93113. uniformsNames: string[];
  93114. /**
  93115. * Uniform buffer varible names that will be set in the shader.
  93116. */
  93117. uniformBuffersNames: string[];
  93118. /**
  93119. * Sampler texture variable names that will be set in the shader.
  93120. */
  93121. samplers: string[];
  93122. /**
  93123. * Define statements that will be set in the shader.
  93124. */
  93125. defines: any;
  93126. /**
  93127. * Possible fallbacks for this effect to improve performance when needed.
  93128. */
  93129. fallbacks: Nullable<EffectFallbacks>;
  93130. /**
  93131. * Callback that will be called when the shader is compiled.
  93132. */
  93133. onCompiled: Nullable<(effect: Effect) => void>;
  93134. /**
  93135. * Callback that will be called if an error occurs during shader compilation.
  93136. */
  93137. onError: Nullable<(effect: Effect, errors: string) => void>;
  93138. /**
  93139. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93140. */
  93141. indexParameters: any;
  93142. /**
  93143. * Max number of lights that can be used in the shader.
  93144. */
  93145. maxSimultaneousLights: number;
  93146. /**
  93147. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93148. */
  93149. transformFeedbackVaryings: Nullable<string[]>;
  93150. }
  93151. /**
  93152. * Effect containing vertex and fragment shader that can be executed on an object.
  93153. */
  93154. export class Effect implements IDisposable {
  93155. /**
  93156. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93157. */
  93158. static ShadersRepository: string;
  93159. /**
  93160. * Name of the effect.
  93161. */
  93162. name: any;
  93163. /**
  93164. * String container all the define statements that should be set on the shader.
  93165. */
  93166. defines: string;
  93167. /**
  93168. * Callback that will be called when the shader is compiled.
  93169. */
  93170. onCompiled: Nullable<(effect: Effect) => void>;
  93171. /**
  93172. * Callback that will be called if an error occurs during shader compilation.
  93173. */
  93174. onError: Nullable<(effect: Effect, errors: string) => void>;
  93175. /**
  93176. * Callback that will be called when effect is bound.
  93177. */
  93178. onBind: Nullable<(effect: Effect) => void>;
  93179. /**
  93180. * Unique ID of the effect.
  93181. */
  93182. uniqueId: number;
  93183. /**
  93184. * Observable that will be called when the shader is compiled.
  93185. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93186. */
  93187. onCompileObservable: Observable<Effect>;
  93188. /**
  93189. * Observable that will be called if an error occurs during shader compilation.
  93190. */
  93191. onErrorObservable: Observable<Effect>;
  93192. /** @hidden */
  93193. _onBindObservable: Nullable<Observable<Effect>>;
  93194. /**
  93195. * Observable that will be called when effect is bound.
  93196. */
  93197. readonly onBindObservable: Observable<Effect>;
  93198. /** @hidden */
  93199. _bonesComputationForcedToCPU: boolean;
  93200. private static _uniqueIdSeed;
  93201. private _engine;
  93202. private _uniformBuffersNames;
  93203. private _uniformsNames;
  93204. private _samplerList;
  93205. private _samplers;
  93206. private _isReady;
  93207. private _compilationError;
  93208. private _attributesNames;
  93209. private _attributes;
  93210. private _uniforms;
  93211. /**
  93212. * Key for the effect.
  93213. * @hidden
  93214. */
  93215. _key: string;
  93216. private _indexParameters;
  93217. private _fallbacks;
  93218. private _vertexSourceCode;
  93219. private _fragmentSourceCode;
  93220. private _vertexSourceCodeOverride;
  93221. private _fragmentSourceCodeOverride;
  93222. private _transformFeedbackVaryings;
  93223. /**
  93224. * Compiled shader to webGL program.
  93225. * @hidden
  93226. */
  93227. _pipelineContext: Nullable<IPipelineContext>;
  93228. private _valueCache;
  93229. private static _baseCache;
  93230. /**
  93231. * Instantiates an effect.
  93232. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93233. * @param baseName Name of the effect.
  93234. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93235. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93236. * @param samplers List of sampler variables that will be passed to the shader.
  93237. * @param engine Engine to be used to render the effect
  93238. * @param defines Define statements to be added to the shader.
  93239. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93240. * @param onCompiled Callback that will be called when the shader is compiled.
  93241. * @param onError Callback that will be called if an error occurs during shader compilation.
  93242. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93243. */
  93244. 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);
  93245. private _useFinalCode;
  93246. /**
  93247. * Unique key for this effect
  93248. */
  93249. readonly key: string;
  93250. /**
  93251. * If the effect has been compiled and prepared.
  93252. * @returns if the effect is compiled and prepared.
  93253. */
  93254. isReady(): boolean;
  93255. private _isReadyInternal;
  93256. /**
  93257. * The engine the effect was initialized with.
  93258. * @returns the engine.
  93259. */
  93260. getEngine(): Engine;
  93261. /**
  93262. * The pipeline context for this effect
  93263. * @returns the associated pipeline context
  93264. */
  93265. getPipelineContext(): Nullable<IPipelineContext>;
  93266. /**
  93267. * The set of names of attribute variables for the shader.
  93268. * @returns An array of attribute names.
  93269. */
  93270. getAttributesNames(): string[];
  93271. /**
  93272. * Returns the attribute at the given index.
  93273. * @param index The index of the attribute.
  93274. * @returns The location of the attribute.
  93275. */
  93276. getAttributeLocation(index: number): number;
  93277. /**
  93278. * Returns the attribute based on the name of the variable.
  93279. * @param name of the attribute to look up.
  93280. * @returns the attribute location.
  93281. */
  93282. getAttributeLocationByName(name: string): number;
  93283. /**
  93284. * The number of attributes.
  93285. * @returns the numnber of attributes.
  93286. */
  93287. getAttributesCount(): number;
  93288. /**
  93289. * Gets the index of a uniform variable.
  93290. * @param uniformName of the uniform to look up.
  93291. * @returns the index.
  93292. */
  93293. getUniformIndex(uniformName: string): number;
  93294. /**
  93295. * Returns the attribute based on the name of the variable.
  93296. * @param uniformName of the uniform to look up.
  93297. * @returns the location of the uniform.
  93298. */
  93299. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93300. /**
  93301. * Returns an array of sampler variable names
  93302. * @returns The array of sampler variable neames.
  93303. */
  93304. getSamplers(): string[];
  93305. /**
  93306. * The error from the last compilation.
  93307. * @returns the error string.
  93308. */
  93309. getCompilationError(): string;
  93310. /**
  93311. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93312. * @param func The callback to be used.
  93313. */
  93314. executeWhenCompiled(func: (effect: Effect) => void): void;
  93315. private _checkIsReady;
  93316. /** @hidden */
  93317. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93318. /** @hidden */
  93319. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93320. /** @hidden */
  93321. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93322. /**
  93323. * Recompiles the webGL program
  93324. * @param vertexSourceCode The source code for the vertex shader.
  93325. * @param fragmentSourceCode The source code for the fragment shader.
  93326. * @param onCompiled Callback called when completed.
  93327. * @param onError Callback called on error.
  93328. * @hidden
  93329. */
  93330. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93331. /**
  93332. * Prepares the effect
  93333. * @hidden
  93334. */
  93335. _prepareEffect(): void;
  93336. private _processCompilationErrors;
  93337. /**
  93338. * Checks if the effect is supported. (Must be called after compilation)
  93339. */
  93340. readonly isSupported: boolean;
  93341. /**
  93342. * Binds a texture to the engine to be used as output of the shader.
  93343. * @param channel Name of the output variable.
  93344. * @param texture Texture to bind.
  93345. * @hidden
  93346. */
  93347. _bindTexture(channel: string, texture: InternalTexture): void;
  93348. /**
  93349. * Sets a texture on the engine to be used in the shader.
  93350. * @param channel Name of the sampler variable.
  93351. * @param texture Texture to set.
  93352. */
  93353. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93354. /**
  93355. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93356. * @param channel Name of the sampler variable.
  93357. * @param texture Texture to set.
  93358. */
  93359. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93360. /**
  93361. * Sets an array of textures on the engine to be used in the shader.
  93362. * @param channel Name of the variable.
  93363. * @param textures Textures to set.
  93364. */
  93365. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93366. /**
  93367. * 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)
  93368. * @param channel Name of the sampler variable.
  93369. * @param postProcess Post process to get the input texture from.
  93370. */
  93371. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93372. /**
  93373. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93374. * 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)
  93375. * @param channel Name of the sampler variable.
  93376. * @param postProcess Post process to get the output texture from.
  93377. */
  93378. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93379. /** @hidden */
  93380. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93381. /** @hidden */
  93382. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93383. /** @hidden */
  93384. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93385. /** @hidden */
  93386. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93387. /**
  93388. * Binds a buffer to a uniform.
  93389. * @param buffer Buffer to bind.
  93390. * @param name Name of the uniform variable to bind to.
  93391. */
  93392. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93393. /**
  93394. * Binds block to a uniform.
  93395. * @param blockName Name of the block to bind.
  93396. * @param index Index to bind.
  93397. */
  93398. bindUniformBlock(blockName: string, index: number): void;
  93399. /**
  93400. * Sets an interger value on a uniform variable.
  93401. * @param uniformName Name of the variable.
  93402. * @param value Value to be set.
  93403. * @returns this effect.
  93404. */
  93405. setInt(uniformName: string, value: number): Effect;
  93406. /**
  93407. * Sets an int array on a uniform variable.
  93408. * @param uniformName Name of the variable.
  93409. * @param array array to be set.
  93410. * @returns this effect.
  93411. */
  93412. setIntArray(uniformName: string, array: Int32Array): Effect;
  93413. /**
  93414. * 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)
  93415. * @param uniformName Name of the variable.
  93416. * @param array array to be set.
  93417. * @returns this effect.
  93418. */
  93419. setIntArray2(uniformName: string, array: Int32Array): Effect;
  93420. /**
  93421. * 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)
  93422. * @param uniformName Name of the variable.
  93423. * @param array array to be set.
  93424. * @returns this effect.
  93425. */
  93426. setIntArray3(uniformName: string, array: Int32Array): Effect;
  93427. /**
  93428. * 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)
  93429. * @param uniformName Name of the variable.
  93430. * @param array array to be set.
  93431. * @returns this effect.
  93432. */
  93433. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93434. /**
  93435. * Sets an float array on a uniform variable.
  93436. * @param uniformName Name of the variable.
  93437. * @param array array to be set.
  93438. * @returns this effect.
  93439. */
  93440. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93441. /**
  93442. * 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)
  93443. * @param uniformName Name of the variable.
  93444. * @param array array to be set.
  93445. * @returns this effect.
  93446. */
  93447. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93448. /**
  93449. * 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)
  93450. * @param uniformName Name of the variable.
  93451. * @param array array to be set.
  93452. * @returns this effect.
  93453. */
  93454. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93455. /**
  93456. * 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)
  93457. * @param uniformName Name of the variable.
  93458. * @param array array to be set.
  93459. * @returns this effect.
  93460. */
  93461. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93462. /**
  93463. * Sets an array on a uniform variable.
  93464. * @param uniformName Name of the variable.
  93465. * @param array array to be set.
  93466. * @returns this effect.
  93467. */
  93468. setArray(uniformName: string, array: number[]): Effect;
  93469. /**
  93470. * 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)
  93471. * @param uniformName Name of the variable.
  93472. * @param array array to be set.
  93473. * @returns this effect.
  93474. */
  93475. setArray2(uniformName: string, array: number[]): Effect;
  93476. /**
  93477. * 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)
  93478. * @param uniformName Name of the variable.
  93479. * @param array array to be set.
  93480. * @returns this effect.
  93481. */
  93482. setArray3(uniformName: string, array: number[]): Effect;
  93483. /**
  93484. * 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)
  93485. * @param uniformName Name of the variable.
  93486. * @param array array to be set.
  93487. * @returns this effect.
  93488. */
  93489. setArray4(uniformName: string, array: number[]): Effect;
  93490. /**
  93491. * Sets matrices on a uniform variable.
  93492. * @param uniformName Name of the variable.
  93493. * @param matrices matrices to be set.
  93494. * @returns this effect.
  93495. */
  93496. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93497. /**
  93498. * Sets matrix on a uniform variable.
  93499. * @param uniformName Name of the variable.
  93500. * @param matrix matrix to be set.
  93501. * @returns this effect.
  93502. */
  93503. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93504. /**
  93505. * 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)
  93506. * @param uniformName Name of the variable.
  93507. * @param matrix matrix to be set.
  93508. * @returns this effect.
  93509. */
  93510. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93511. /**
  93512. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93513. * @param uniformName Name of the variable.
  93514. * @param matrix matrix to be set.
  93515. * @returns this effect.
  93516. */
  93517. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93518. /**
  93519. * Sets a float on a uniform variable.
  93520. * @param uniformName Name of the variable.
  93521. * @param value value to be set.
  93522. * @returns this effect.
  93523. */
  93524. setFloat(uniformName: string, value: number): Effect;
  93525. /**
  93526. * Sets a boolean on a uniform variable.
  93527. * @param uniformName Name of the variable.
  93528. * @param bool value to be set.
  93529. * @returns this effect.
  93530. */
  93531. setBool(uniformName: string, bool: boolean): Effect;
  93532. /**
  93533. * Sets a Vector2 on a uniform variable.
  93534. * @param uniformName Name of the variable.
  93535. * @param vector2 vector2 to be set.
  93536. * @returns this effect.
  93537. */
  93538. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93539. /**
  93540. * Sets a float2 on a uniform variable.
  93541. * @param uniformName Name of the variable.
  93542. * @param x First float in float2.
  93543. * @param y Second float in float2.
  93544. * @returns this effect.
  93545. */
  93546. setFloat2(uniformName: string, x: number, y: number): Effect;
  93547. /**
  93548. * Sets a Vector3 on a uniform variable.
  93549. * @param uniformName Name of the variable.
  93550. * @param vector3 Value to be set.
  93551. * @returns this effect.
  93552. */
  93553. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93554. /**
  93555. * Sets a float3 on a uniform variable.
  93556. * @param uniformName Name of the variable.
  93557. * @param x First float in float3.
  93558. * @param y Second float in float3.
  93559. * @param z Third float in float3.
  93560. * @returns this effect.
  93561. */
  93562. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93563. /**
  93564. * Sets a Vector4 on a uniform variable.
  93565. * @param uniformName Name of the variable.
  93566. * @param vector4 Value to be set.
  93567. * @returns this effect.
  93568. */
  93569. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93570. /**
  93571. * Sets a float4 on a uniform variable.
  93572. * @param uniformName Name of the variable.
  93573. * @param x First float in float4.
  93574. * @param y Second float in float4.
  93575. * @param z Third float in float4.
  93576. * @param w Fourth float in float4.
  93577. * @returns this effect.
  93578. */
  93579. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93580. /**
  93581. * Sets a Color3 on a uniform variable.
  93582. * @param uniformName Name of the variable.
  93583. * @param color3 Value to be set.
  93584. * @returns this effect.
  93585. */
  93586. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93587. /**
  93588. * Sets a Color4 on a uniform variable.
  93589. * @param uniformName Name of the variable.
  93590. * @param color3 Value to be set.
  93591. * @param alpha Alpha value to be set.
  93592. * @returns this effect.
  93593. */
  93594. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93595. /**
  93596. * Sets a Color4 on a uniform variable
  93597. * @param uniformName defines the name of the variable
  93598. * @param color4 defines the value to be set
  93599. * @returns this effect.
  93600. */
  93601. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93602. /** Release all associated resources */
  93603. dispose(): void;
  93604. /**
  93605. * This function will add a new shader to the shader store
  93606. * @param name the name of the shader
  93607. * @param pixelShader optional pixel shader content
  93608. * @param vertexShader optional vertex shader content
  93609. */
  93610. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93611. /**
  93612. * Store of each shader (The can be looked up using effect.key)
  93613. */
  93614. static ShadersStore: {
  93615. [key: string]: string;
  93616. };
  93617. /**
  93618. * Store of each included file for a shader (The can be looked up using effect.key)
  93619. */
  93620. static IncludesShadersStore: {
  93621. [key: string]: string;
  93622. };
  93623. /**
  93624. * Resets the cache of effects.
  93625. */
  93626. static ResetCache(): void;
  93627. }
  93628. }
  93629. declare module BABYLON {
  93630. /**
  93631. * Uniform buffer objects.
  93632. *
  93633. * Handles blocks of uniform on the GPU.
  93634. *
  93635. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93636. *
  93637. * For more information, please refer to :
  93638. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93639. */
  93640. export class UniformBuffer {
  93641. private _engine;
  93642. private _buffer;
  93643. private _data;
  93644. private _bufferData;
  93645. private _dynamic?;
  93646. private _uniformLocations;
  93647. private _uniformSizes;
  93648. private _uniformLocationPointer;
  93649. private _needSync;
  93650. private _noUBO;
  93651. private _currentEffect;
  93652. private static _MAX_UNIFORM_SIZE;
  93653. private static _tempBuffer;
  93654. /**
  93655. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93656. * This is dynamic to allow compat with webgl 1 and 2.
  93657. * You will need to pass the name of the uniform as well as the value.
  93658. */
  93659. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93660. /**
  93661. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93662. * This is dynamic to allow compat with webgl 1 and 2.
  93663. * You will need to pass the name of the uniform as well as the value.
  93664. */
  93665. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93666. /**
  93667. * Lambda to Update a single float in a uniform buffer.
  93668. * This is dynamic to allow compat with webgl 1 and 2.
  93669. * You will need to pass the name of the uniform as well as the value.
  93670. */
  93671. updateFloat: (name: string, x: number) => void;
  93672. /**
  93673. * Lambda to Update a vec2 of float in a uniform buffer.
  93674. * This is dynamic to allow compat with webgl 1 and 2.
  93675. * You will need to pass the name of the uniform as well as the value.
  93676. */
  93677. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93678. /**
  93679. * Lambda to Update a vec3 of float in a uniform buffer.
  93680. * This is dynamic to allow compat with webgl 1 and 2.
  93681. * You will need to pass the name of the uniform as well as the value.
  93682. */
  93683. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93684. /**
  93685. * Lambda to Update a vec4 of float in a uniform buffer.
  93686. * This is dynamic to allow compat with webgl 1 and 2.
  93687. * You will need to pass the name of the uniform as well as the value.
  93688. */
  93689. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93690. /**
  93691. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93692. * This is dynamic to allow compat with webgl 1 and 2.
  93693. * You will need to pass the name of the uniform as well as the value.
  93694. */
  93695. updateMatrix: (name: string, mat: Matrix) => void;
  93696. /**
  93697. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93698. * This is dynamic to allow compat with webgl 1 and 2.
  93699. * You will need to pass the name of the uniform as well as the value.
  93700. */
  93701. updateVector3: (name: string, vector: Vector3) => void;
  93702. /**
  93703. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93704. * This is dynamic to allow compat with webgl 1 and 2.
  93705. * You will need to pass the name of the uniform as well as the value.
  93706. */
  93707. updateVector4: (name: string, vector: Vector4) => void;
  93708. /**
  93709. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93710. * This is dynamic to allow compat with webgl 1 and 2.
  93711. * You will need to pass the name of the uniform as well as the value.
  93712. */
  93713. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93714. /**
  93715. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93716. * This is dynamic to allow compat with webgl 1 and 2.
  93717. * You will need to pass the name of the uniform as well as the value.
  93718. */
  93719. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93720. /**
  93721. * Instantiates a new Uniform buffer objects.
  93722. *
  93723. * Handles blocks of uniform on the GPU.
  93724. *
  93725. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93726. *
  93727. * For more information, please refer to :
  93728. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93729. * @param engine Define the engine the buffer is associated with
  93730. * @param data Define the data contained in the buffer
  93731. * @param dynamic Define if the buffer is updatable
  93732. */
  93733. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93734. /**
  93735. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93736. * or just falling back on setUniformXXX calls.
  93737. */
  93738. readonly useUbo: boolean;
  93739. /**
  93740. * Indicates if the WebGL underlying uniform buffer is in sync
  93741. * with the javascript cache data.
  93742. */
  93743. readonly isSync: boolean;
  93744. /**
  93745. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93746. * Also, a dynamic UniformBuffer will disable cache verification and always
  93747. * update the underlying WebGL uniform buffer to the GPU.
  93748. * @returns if Dynamic, otherwise false
  93749. */
  93750. isDynamic(): boolean;
  93751. /**
  93752. * The data cache on JS side.
  93753. * @returns the underlying data as a float array
  93754. */
  93755. getData(): Float32Array;
  93756. /**
  93757. * The underlying WebGL Uniform buffer.
  93758. * @returns the webgl buffer
  93759. */
  93760. getBuffer(): Nullable<DataBuffer>;
  93761. /**
  93762. * std140 layout specifies how to align data within an UBO structure.
  93763. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93764. * for specs.
  93765. */
  93766. private _fillAlignment;
  93767. /**
  93768. * Adds an uniform in the buffer.
  93769. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93770. * for the layout to be correct !
  93771. * @param name Name of the uniform, as used in the uniform block in the shader.
  93772. * @param size Data size, or data directly.
  93773. */
  93774. addUniform(name: string, size: number | number[]): void;
  93775. /**
  93776. * Adds a Matrix 4x4 to the uniform buffer.
  93777. * @param name Name of the uniform, as used in the uniform block in the shader.
  93778. * @param mat A 4x4 matrix.
  93779. */
  93780. addMatrix(name: string, mat: Matrix): void;
  93781. /**
  93782. * Adds a vec2 to the uniform buffer.
  93783. * @param name Name of the uniform, as used in the uniform block in the shader.
  93784. * @param x Define the x component value of the vec2
  93785. * @param y Define the y component value of the vec2
  93786. */
  93787. addFloat2(name: string, x: number, y: number): void;
  93788. /**
  93789. * Adds a vec3 to the uniform buffer.
  93790. * @param name Name of the uniform, as used in the uniform block in the shader.
  93791. * @param x Define the x component value of the vec3
  93792. * @param y Define the y component value of the vec3
  93793. * @param z Define the z component value of the vec3
  93794. */
  93795. addFloat3(name: string, x: number, y: number, z: number): void;
  93796. /**
  93797. * Adds a vec3 to the uniform buffer.
  93798. * @param name Name of the uniform, as used in the uniform block in the shader.
  93799. * @param color Define the vec3 from a Color
  93800. */
  93801. addColor3(name: string, color: Color3): void;
  93802. /**
  93803. * Adds a vec4 to the uniform buffer.
  93804. * @param name Name of the uniform, as used in the uniform block in the shader.
  93805. * @param color Define the rgb components from a Color
  93806. * @param alpha Define the a component of the vec4
  93807. */
  93808. addColor4(name: string, color: Color3, alpha: number): void;
  93809. /**
  93810. * Adds a vec3 to the uniform buffer.
  93811. * @param name Name of the uniform, as used in the uniform block in the shader.
  93812. * @param vector Define the vec3 components from a Vector
  93813. */
  93814. addVector3(name: string, vector: Vector3): void;
  93815. /**
  93816. * Adds a Matrix 3x3 to the uniform buffer.
  93817. * @param name Name of the uniform, as used in the uniform block in the shader.
  93818. */
  93819. addMatrix3x3(name: string): void;
  93820. /**
  93821. * Adds a Matrix 2x2 to the uniform buffer.
  93822. * @param name Name of the uniform, as used in the uniform block in the shader.
  93823. */
  93824. addMatrix2x2(name: string): void;
  93825. /**
  93826. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93827. */
  93828. create(): void;
  93829. /** @hidden */
  93830. _rebuild(): void;
  93831. /**
  93832. * Updates the WebGL Uniform Buffer on the GPU.
  93833. * If the `dynamic` flag is set to true, no cache comparison is done.
  93834. * Otherwise, the buffer will be updated only if the cache differs.
  93835. */
  93836. update(): void;
  93837. /**
  93838. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93839. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93840. * @param data Define the flattened data
  93841. * @param size Define the size of the data.
  93842. */
  93843. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93844. private _valueCache;
  93845. private _cacheMatrix;
  93846. private _updateMatrix3x3ForUniform;
  93847. private _updateMatrix3x3ForEffect;
  93848. private _updateMatrix2x2ForEffect;
  93849. private _updateMatrix2x2ForUniform;
  93850. private _updateFloatForEffect;
  93851. private _updateFloatForUniform;
  93852. private _updateFloat2ForEffect;
  93853. private _updateFloat2ForUniform;
  93854. private _updateFloat3ForEffect;
  93855. private _updateFloat3ForUniform;
  93856. private _updateFloat4ForEffect;
  93857. private _updateFloat4ForUniform;
  93858. private _updateMatrixForEffect;
  93859. private _updateMatrixForUniform;
  93860. private _updateVector3ForEffect;
  93861. private _updateVector3ForUniform;
  93862. private _updateVector4ForEffect;
  93863. private _updateVector4ForUniform;
  93864. private _updateColor3ForEffect;
  93865. private _updateColor3ForUniform;
  93866. private _updateColor4ForEffect;
  93867. private _updateColor4ForUniform;
  93868. /**
  93869. * Sets a sampler uniform on the effect.
  93870. * @param name Define the name of the sampler.
  93871. * @param texture Define the texture to set in the sampler
  93872. */
  93873. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93874. /**
  93875. * Directly updates the value of the uniform in the cache AND on the GPU.
  93876. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93877. * @param data Define the flattened data
  93878. */
  93879. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93880. /**
  93881. * Binds this uniform buffer to an effect.
  93882. * @param effect Define the effect to bind the buffer to
  93883. * @param name Name of the uniform block in the shader.
  93884. */
  93885. bindToEffect(effect: Effect, name: string): void;
  93886. /**
  93887. * Disposes the uniform buffer.
  93888. */
  93889. dispose(): void;
  93890. }
  93891. }
  93892. declare module BABYLON {
  93893. /**
  93894. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93896. */
  93897. export class Analyser {
  93898. /**
  93899. * Gets or sets the smoothing
  93900. * @ignorenaming
  93901. */
  93902. SMOOTHING: number;
  93903. /**
  93904. * Gets or sets the FFT table size
  93905. * @ignorenaming
  93906. */
  93907. FFT_SIZE: number;
  93908. /**
  93909. * Gets or sets the bar graph amplitude
  93910. * @ignorenaming
  93911. */
  93912. BARGRAPHAMPLITUDE: number;
  93913. /**
  93914. * Gets or sets the position of the debug canvas
  93915. * @ignorenaming
  93916. */
  93917. DEBUGCANVASPOS: {
  93918. x: number;
  93919. y: number;
  93920. };
  93921. /**
  93922. * Gets or sets the debug canvas size
  93923. * @ignorenaming
  93924. */
  93925. DEBUGCANVASSIZE: {
  93926. width: number;
  93927. height: number;
  93928. };
  93929. private _byteFreqs;
  93930. private _byteTime;
  93931. private _floatFreqs;
  93932. private _webAudioAnalyser;
  93933. private _debugCanvas;
  93934. private _debugCanvasContext;
  93935. private _scene;
  93936. private _registerFunc;
  93937. private _audioEngine;
  93938. /**
  93939. * Creates a new analyser
  93940. * @param scene defines hosting scene
  93941. */
  93942. constructor(scene: Scene);
  93943. /**
  93944. * Get the number of data values you will have to play with for the visualization
  93945. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93946. * @returns a number
  93947. */
  93948. getFrequencyBinCount(): number;
  93949. /**
  93950. * Gets the current frequency data as a byte array
  93951. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93952. * @returns a Uint8Array
  93953. */
  93954. getByteFrequencyData(): Uint8Array;
  93955. /**
  93956. * Gets the current waveform as a byte array
  93957. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93958. * @returns a Uint8Array
  93959. */
  93960. getByteTimeDomainData(): Uint8Array;
  93961. /**
  93962. * Gets the current frequency data as a float array
  93963. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93964. * @returns a Float32Array
  93965. */
  93966. getFloatFrequencyData(): Float32Array;
  93967. /**
  93968. * Renders the debug canvas
  93969. */
  93970. drawDebugCanvas(): void;
  93971. /**
  93972. * Stops rendering the debug canvas and removes it
  93973. */
  93974. stopDebugCanvas(): void;
  93975. /**
  93976. * Connects two audio nodes
  93977. * @param inputAudioNode defines first node to connect
  93978. * @param outputAudioNode defines second node to connect
  93979. */
  93980. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93981. /**
  93982. * Releases all associated resources
  93983. */
  93984. dispose(): void;
  93985. }
  93986. }
  93987. declare module BABYLON {
  93988. /**
  93989. * This represents an audio engine and it is responsible
  93990. * to play, synchronize and analyse sounds throughout the application.
  93991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93992. */
  93993. export interface IAudioEngine extends IDisposable {
  93994. /**
  93995. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93996. */
  93997. readonly canUseWebAudio: boolean;
  93998. /**
  93999. * Gets the current AudioContext if available.
  94000. */
  94001. readonly audioContext: Nullable<AudioContext>;
  94002. /**
  94003. * The master gain node defines the global audio volume of your audio engine.
  94004. */
  94005. readonly masterGain: GainNode;
  94006. /**
  94007. * Gets whether or not mp3 are supported by your browser.
  94008. */
  94009. readonly isMP3supported: boolean;
  94010. /**
  94011. * Gets whether or not ogg are supported by your browser.
  94012. */
  94013. readonly isOGGsupported: boolean;
  94014. /**
  94015. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94016. * @ignoreNaming
  94017. */
  94018. WarnedWebAudioUnsupported: boolean;
  94019. /**
  94020. * Defines if the audio engine relies on a custom unlocked button.
  94021. * In this case, the embedded button will not be displayed.
  94022. */
  94023. useCustomUnlockedButton: boolean;
  94024. /**
  94025. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94026. */
  94027. readonly unlocked: boolean;
  94028. /**
  94029. * Event raised when audio has been unlocked on the browser.
  94030. */
  94031. onAudioUnlockedObservable: Observable<AudioEngine>;
  94032. /**
  94033. * Event raised when audio has been locked on the browser.
  94034. */
  94035. onAudioLockedObservable: Observable<AudioEngine>;
  94036. /**
  94037. * Flags the audio engine in Locked state.
  94038. * This happens due to new browser policies preventing audio to autoplay.
  94039. */
  94040. lock(): void;
  94041. /**
  94042. * Unlocks the audio engine once a user action has been done on the dom.
  94043. * This is helpful to resume play once browser policies have been satisfied.
  94044. */
  94045. unlock(): void;
  94046. }
  94047. /**
  94048. * This represents the default audio engine used in babylon.
  94049. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94051. */
  94052. export class AudioEngine implements IAudioEngine {
  94053. private _audioContext;
  94054. private _audioContextInitialized;
  94055. private _muteButton;
  94056. private _hostElement;
  94057. /**
  94058. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94059. */
  94060. canUseWebAudio: boolean;
  94061. /**
  94062. * The master gain node defines the global audio volume of your audio engine.
  94063. */
  94064. masterGain: GainNode;
  94065. /**
  94066. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94067. * @ignoreNaming
  94068. */
  94069. WarnedWebAudioUnsupported: boolean;
  94070. /**
  94071. * Gets whether or not mp3 are supported by your browser.
  94072. */
  94073. isMP3supported: boolean;
  94074. /**
  94075. * Gets whether or not ogg are supported by your browser.
  94076. */
  94077. isOGGsupported: boolean;
  94078. /**
  94079. * Gets whether audio has been unlocked on the device.
  94080. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94081. * a user interaction has happened.
  94082. */
  94083. unlocked: boolean;
  94084. /**
  94085. * Defines if the audio engine relies on a custom unlocked button.
  94086. * In this case, the embedded button will not be displayed.
  94087. */
  94088. useCustomUnlockedButton: boolean;
  94089. /**
  94090. * Event raised when audio has been unlocked on the browser.
  94091. */
  94092. onAudioUnlockedObservable: Observable<AudioEngine>;
  94093. /**
  94094. * Event raised when audio has been locked on the browser.
  94095. */
  94096. onAudioLockedObservable: Observable<AudioEngine>;
  94097. /**
  94098. * Gets the current AudioContext if available.
  94099. */
  94100. readonly audioContext: Nullable<AudioContext>;
  94101. private _connectedAnalyser;
  94102. /**
  94103. * Instantiates a new audio engine.
  94104. *
  94105. * There should be only one per page as some browsers restrict the number
  94106. * of audio contexts you can create.
  94107. * @param hostElement defines the host element where to display the mute icon if necessary
  94108. */
  94109. constructor(hostElement?: Nullable<HTMLElement>);
  94110. /**
  94111. * Flags the audio engine in Locked state.
  94112. * This happens due to new browser policies preventing audio to autoplay.
  94113. */
  94114. lock(): void;
  94115. /**
  94116. * Unlocks the audio engine once a user action has been done on the dom.
  94117. * This is helpful to resume play once browser policies have been satisfied.
  94118. */
  94119. unlock(): void;
  94120. private _resumeAudioContext;
  94121. private _initializeAudioContext;
  94122. private _tryToRun;
  94123. private _triggerRunningState;
  94124. private _triggerSuspendedState;
  94125. private _displayMuteButton;
  94126. private _moveButtonToTopLeft;
  94127. private _onResize;
  94128. private _hideMuteButton;
  94129. /**
  94130. * Destroy and release the resources associated with the audio ccontext.
  94131. */
  94132. dispose(): void;
  94133. /**
  94134. * Gets the global volume sets on the master gain.
  94135. * @returns the global volume if set or -1 otherwise
  94136. */
  94137. getGlobalVolume(): number;
  94138. /**
  94139. * Sets the global volume of your experience (sets on the master gain).
  94140. * @param newVolume Defines the new global volume of the application
  94141. */
  94142. setGlobalVolume(newVolume: number): void;
  94143. /**
  94144. * Connect the audio engine to an audio analyser allowing some amazing
  94145. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94147. * @param analyser The analyser to connect to the engine
  94148. */
  94149. connectToAnalyser(analyser: Analyser): void;
  94150. }
  94151. }
  94152. declare module BABYLON {
  94153. /**
  94154. * Interface used to present a loading screen while loading a scene
  94155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94156. */
  94157. export interface ILoadingScreen {
  94158. /**
  94159. * Function called to display the loading screen
  94160. */
  94161. displayLoadingUI: () => void;
  94162. /**
  94163. * Function called to hide the loading screen
  94164. */
  94165. hideLoadingUI: () => void;
  94166. /**
  94167. * Gets or sets the color to use for the background
  94168. */
  94169. loadingUIBackgroundColor: string;
  94170. /**
  94171. * Gets or sets the text to display while loading
  94172. */
  94173. loadingUIText: string;
  94174. }
  94175. /**
  94176. * Class used for the default loading screen
  94177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94178. */
  94179. export class DefaultLoadingScreen implements ILoadingScreen {
  94180. private _renderingCanvas;
  94181. private _loadingText;
  94182. private _loadingDivBackgroundColor;
  94183. private _loadingDiv;
  94184. private _loadingTextDiv;
  94185. /** Gets or sets the logo url to use for the default loading screen */
  94186. static DefaultLogoUrl: string;
  94187. /** Gets or sets the spinner url to use for the default loading screen */
  94188. static DefaultSpinnerUrl: string;
  94189. /**
  94190. * Creates a new default loading screen
  94191. * @param _renderingCanvas defines the canvas used to render the scene
  94192. * @param _loadingText defines the default text to display
  94193. * @param _loadingDivBackgroundColor defines the default background color
  94194. */
  94195. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94196. /**
  94197. * Function called to display the loading screen
  94198. */
  94199. displayLoadingUI(): void;
  94200. /**
  94201. * Function called to hide the loading screen
  94202. */
  94203. hideLoadingUI(): void;
  94204. /**
  94205. * Gets or sets the text to display while loading
  94206. */
  94207. loadingUIText: string;
  94208. /**
  94209. * Gets or sets the color to use for the background
  94210. */
  94211. loadingUIBackgroundColor: string;
  94212. private _resizeLoadingUI;
  94213. }
  94214. }
  94215. declare module BABYLON {
  94216. /** @hidden */
  94217. export class WebGLPipelineContext implements IPipelineContext {
  94218. engine: Engine;
  94219. program: Nullable<WebGLProgram>;
  94220. context?: WebGLRenderingContext;
  94221. vertexShader?: WebGLShader;
  94222. fragmentShader?: WebGLShader;
  94223. isParallelCompiled: boolean;
  94224. onCompiled?: () => void;
  94225. transformFeedback?: WebGLTransformFeedback | null;
  94226. readonly isAsync: boolean;
  94227. readonly isReady: boolean;
  94228. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94229. }
  94230. }
  94231. declare module BABYLON {
  94232. /** @hidden */
  94233. export class WebGLDataBuffer extends DataBuffer {
  94234. private _buffer;
  94235. constructor(resource: WebGLBuffer);
  94236. readonly underlyingResource: any;
  94237. }
  94238. }
  94239. declare module BABYLON {
  94240. /** @hidden */
  94241. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94242. attributeProcessor(attribute: string): string;
  94243. varyingProcessor(varying: string, isFragment: boolean): string;
  94244. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94245. }
  94246. }
  94247. declare module BABYLON {
  94248. /**
  94249. * This class is used to track a performance counter which is number based.
  94250. * The user has access to many properties which give statistics of different nature.
  94251. *
  94252. * The implementer can track two kinds of Performance Counter: time and count.
  94253. * 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.
  94254. * 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.
  94255. */
  94256. export class PerfCounter {
  94257. /**
  94258. * Gets or sets a global boolean to turn on and off all the counters
  94259. */
  94260. static Enabled: boolean;
  94261. /**
  94262. * Returns the smallest value ever
  94263. */
  94264. readonly min: number;
  94265. /**
  94266. * Returns the biggest value ever
  94267. */
  94268. readonly max: number;
  94269. /**
  94270. * Returns the average value since the performance counter is running
  94271. */
  94272. readonly average: number;
  94273. /**
  94274. * Returns the average value of the last second the counter was monitored
  94275. */
  94276. readonly lastSecAverage: number;
  94277. /**
  94278. * Returns the current value
  94279. */
  94280. readonly current: number;
  94281. /**
  94282. * Gets the accumulated total
  94283. */
  94284. readonly total: number;
  94285. /**
  94286. * Gets the total value count
  94287. */
  94288. readonly count: number;
  94289. /**
  94290. * Creates a new counter
  94291. */
  94292. constructor();
  94293. /**
  94294. * Call this method to start monitoring a new frame.
  94295. * 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.
  94296. */
  94297. fetchNewFrame(): void;
  94298. /**
  94299. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94300. * @param newCount the count value to add to the monitored count
  94301. * @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.
  94302. */
  94303. addCount(newCount: number, fetchResult: boolean): void;
  94304. /**
  94305. * Start monitoring this performance counter
  94306. */
  94307. beginMonitoring(): void;
  94308. /**
  94309. * Compute the time lapsed since the previous beginMonitoring() call.
  94310. * @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
  94311. */
  94312. endMonitoring(newFrame?: boolean): void;
  94313. private _fetchResult;
  94314. private _startMonitoringTime;
  94315. private _min;
  94316. private _max;
  94317. private _average;
  94318. private _current;
  94319. private _totalValueCount;
  94320. private _totalAccumulated;
  94321. private _lastSecAverage;
  94322. private _lastSecAccumulated;
  94323. private _lastSecTime;
  94324. private _lastSecValueCount;
  94325. }
  94326. }
  94327. declare module BABYLON {
  94328. /**
  94329. * Interface for any object that can request an animation frame
  94330. */
  94331. export interface ICustomAnimationFrameRequester {
  94332. /**
  94333. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94334. */
  94335. renderFunction?: Function;
  94336. /**
  94337. * Called to request the next frame to render to
  94338. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94339. */
  94340. requestAnimationFrame: Function;
  94341. /**
  94342. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94343. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94344. */
  94345. requestID?: number;
  94346. }
  94347. }
  94348. declare module BABYLON {
  94349. /**
  94350. * Settings for finer control over video usage
  94351. */
  94352. export interface VideoTextureSettings {
  94353. /**
  94354. * Applies `autoplay` to video, if specified
  94355. */
  94356. autoPlay?: boolean;
  94357. /**
  94358. * Applies `loop` to video, if specified
  94359. */
  94360. loop?: boolean;
  94361. /**
  94362. * Automatically updates internal texture from video at every frame in the render loop
  94363. */
  94364. autoUpdateTexture: boolean;
  94365. /**
  94366. * Image src displayed during the video loading or until the user interacts with the video.
  94367. */
  94368. poster?: string;
  94369. }
  94370. /**
  94371. * If you want to display a video in your scene, this is the special texture for that.
  94372. * This special texture works similar to other textures, with the exception of a few parameters.
  94373. * @see https://doc.babylonjs.com/how_to/video_texture
  94374. */
  94375. export class VideoTexture extends Texture {
  94376. /**
  94377. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94378. */
  94379. readonly autoUpdateTexture: boolean;
  94380. /**
  94381. * The video instance used by the texture internally
  94382. */
  94383. readonly video: HTMLVideoElement;
  94384. private _onUserActionRequestedObservable;
  94385. /**
  94386. * Event triggerd when a dom action is required by the user to play the video.
  94387. * This happens due to recent changes in browser policies preventing video to auto start.
  94388. */
  94389. readonly onUserActionRequestedObservable: Observable<Texture>;
  94390. private _generateMipMaps;
  94391. private _engine;
  94392. private _stillImageCaptured;
  94393. private _displayingPosterTexture;
  94394. private _settings;
  94395. private _createInternalTextureOnEvent;
  94396. /**
  94397. * Creates a video texture.
  94398. * If you want to display a video in your scene, this is the special texture for that.
  94399. * This special texture works similar to other textures, with the exception of a few parameters.
  94400. * @see https://doc.babylonjs.com/how_to/video_texture
  94401. * @param name optional name, will detect from video source, if not defined
  94402. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94403. * @param scene is obviously the current scene.
  94404. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94405. * @param invertY is false by default but can be used to invert video on Y axis
  94406. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  94407. * @param settings allows finer control over video usage
  94408. */
  94409. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  94410. private _getName;
  94411. private _getVideo;
  94412. private _createInternalTexture;
  94413. private reset;
  94414. /**
  94415. * @hidden Internal method to initiate `update`.
  94416. */
  94417. _rebuild(): void;
  94418. /**
  94419. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  94420. */
  94421. update(): void;
  94422. /**
  94423. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  94424. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  94425. */
  94426. updateTexture(isVisible: boolean): void;
  94427. protected _updateInternalTexture: () => void;
  94428. /**
  94429. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  94430. * @param url New url.
  94431. */
  94432. updateURL(url: string): void;
  94433. /**
  94434. * Dispose the texture and release its associated resources.
  94435. */
  94436. dispose(): void;
  94437. /**
  94438. * Creates a video texture straight from a stream.
  94439. * @param scene Define the scene the texture should be created in
  94440. * @param stream Define the stream the texture should be created from
  94441. * @returns The created video texture as a promise
  94442. */
  94443. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94444. /**
  94445. * Creates a video texture straight from your WebCam video feed.
  94446. * @param scene Define the scene the texture should be created in
  94447. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94448. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94449. * @returns The created video texture as a promise
  94450. */
  94451. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94452. minWidth: number;
  94453. maxWidth: number;
  94454. minHeight: number;
  94455. maxHeight: number;
  94456. deviceId: string;
  94457. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94458. /**
  94459. * Creates a video texture straight from your WebCam video feed.
  94460. * @param scene Define the scene the texture should be created in
  94461. * @param onReady Define a callback to triggered once the texture will be ready
  94462. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94463. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94464. */
  94465. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94466. minWidth: number;
  94467. maxWidth: number;
  94468. minHeight: number;
  94469. maxHeight: number;
  94470. deviceId: string;
  94471. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94472. }
  94473. }
  94474. declare module BABYLON {
  94475. /**
  94476. * Defines the interface used by objects containing a viewport (like a camera)
  94477. */
  94478. interface IViewportOwnerLike {
  94479. /**
  94480. * Gets or sets the viewport
  94481. */
  94482. viewport: IViewportLike;
  94483. }
  94484. /**
  94485. * Interface for attribute information associated with buffer instanciation
  94486. */
  94487. export class InstancingAttributeInfo {
  94488. /**
  94489. * Index/offset of the attribute in the vertex shader
  94490. */
  94491. index: number;
  94492. /**
  94493. * size of the attribute, 1, 2, 3 or 4
  94494. */
  94495. attributeSize: number;
  94496. /**
  94497. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94498. * default is FLOAT
  94499. */
  94500. attribyteType: number;
  94501. /**
  94502. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94503. */
  94504. normalized: boolean;
  94505. /**
  94506. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94507. */
  94508. offset: number;
  94509. /**
  94510. * Name of the GLSL attribute, for debugging purpose only
  94511. */
  94512. attributeName: string;
  94513. }
  94514. /**
  94515. * Define options used to create a depth texture
  94516. */
  94517. export class DepthTextureCreationOptions {
  94518. /** Specifies whether or not a stencil should be allocated in the texture */
  94519. generateStencil?: boolean;
  94520. /** Specifies whether or not bilinear filtering is enable on the texture */
  94521. bilinearFiltering?: boolean;
  94522. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94523. comparisonFunction?: number;
  94524. /** Specifies if the created texture is a cube texture */
  94525. isCube?: boolean;
  94526. }
  94527. /**
  94528. * Class used to describe the capabilities of the engine relatively to the current browser
  94529. */
  94530. export class EngineCapabilities {
  94531. /** Maximum textures units per fragment shader */
  94532. maxTexturesImageUnits: number;
  94533. /** Maximum texture units per vertex shader */
  94534. maxVertexTextureImageUnits: number;
  94535. /** Maximum textures units in the entire pipeline */
  94536. maxCombinedTexturesImageUnits: number;
  94537. /** Maximum texture size */
  94538. maxTextureSize: number;
  94539. /** Maximum cube texture size */
  94540. maxCubemapTextureSize: number;
  94541. /** Maximum render texture size */
  94542. maxRenderTextureSize: number;
  94543. /** Maximum number of vertex attributes */
  94544. maxVertexAttribs: number;
  94545. /** Maximum number of varyings */
  94546. maxVaryingVectors: number;
  94547. /** Maximum number of uniforms per vertex shader */
  94548. maxVertexUniformVectors: number;
  94549. /** Maximum number of uniforms per fragment shader */
  94550. maxFragmentUniformVectors: number;
  94551. /** Defines if standard derivates (dx/dy) are supported */
  94552. standardDerivatives: boolean;
  94553. /** Defines if s3tc texture compression is supported */
  94554. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94555. /** Defines if pvrtc texture compression is supported */
  94556. pvrtc: any;
  94557. /** Defines if etc1 texture compression is supported */
  94558. etc1: any;
  94559. /** Defines if etc2 texture compression is supported */
  94560. etc2: any;
  94561. /** Defines if astc texture compression is supported */
  94562. astc: any;
  94563. /** Defines if float textures are supported */
  94564. textureFloat: boolean;
  94565. /** Defines if vertex array objects are supported */
  94566. vertexArrayObject: boolean;
  94567. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94568. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94569. /** Gets the maximum level of anisotropy supported */
  94570. maxAnisotropy: number;
  94571. /** Defines if instancing is supported */
  94572. instancedArrays: boolean;
  94573. /** Defines if 32 bits indices are supported */
  94574. uintIndices: boolean;
  94575. /** Defines if high precision shaders are supported */
  94576. highPrecisionShaderSupported: boolean;
  94577. /** Defines if depth reading in the fragment shader is supported */
  94578. fragmentDepthSupported: boolean;
  94579. /** Defines if float texture linear filtering is supported*/
  94580. textureFloatLinearFiltering: boolean;
  94581. /** Defines if rendering to float textures is supported */
  94582. textureFloatRender: boolean;
  94583. /** Defines if half float textures are supported*/
  94584. textureHalfFloat: boolean;
  94585. /** Defines if half float texture linear filtering is supported*/
  94586. textureHalfFloatLinearFiltering: boolean;
  94587. /** Defines if rendering to half float textures is supported */
  94588. textureHalfFloatRender: boolean;
  94589. /** Defines if textureLOD shader command is supported */
  94590. textureLOD: boolean;
  94591. /** Defines if draw buffers extension is supported */
  94592. drawBuffersExtension: boolean;
  94593. /** Defines if depth textures are supported */
  94594. depthTextureExtension: boolean;
  94595. /** Defines if float color buffer are supported */
  94596. colorBufferFloat: boolean;
  94597. /** Gets disjoint timer query extension (null if not supported) */
  94598. timerQuery: EXT_disjoint_timer_query;
  94599. /** Defines if timestamp can be used with timer query */
  94600. canUseTimestampForTimerQuery: boolean;
  94601. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94602. multiview: any;
  94603. /** Function used to let the system compiles shaders in background */
  94604. parallelShaderCompile: {
  94605. COMPLETION_STATUS_KHR: number;
  94606. };
  94607. /** Max number of texture samples for MSAA */
  94608. maxMSAASamples: number;
  94609. }
  94610. /** Interface defining initialization parameters for Engine class */
  94611. export interface EngineOptions extends WebGLContextAttributes {
  94612. /**
  94613. * Defines if the engine should no exceed a specified device ratio
  94614. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94615. */
  94616. limitDeviceRatio?: number;
  94617. /**
  94618. * Defines if webvr should be enabled automatically
  94619. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94620. */
  94621. autoEnableWebVR?: boolean;
  94622. /**
  94623. * Defines if webgl2 should be turned off even if supported
  94624. * @see http://doc.babylonjs.com/features/webgl2
  94625. */
  94626. disableWebGL2Support?: boolean;
  94627. /**
  94628. * Defines if webaudio should be initialized as well
  94629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94630. */
  94631. audioEngine?: boolean;
  94632. /**
  94633. * Defines if animations should run using a deterministic lock step
  94634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94635. */
  94636. deterministicLockstep?: boolean;
  94637. /** Defines the maximum steps to use with deterministic lock step mode */
  94638. lockstepMaxSteps?: number;
  94639. /**
  94640. * Defines that engine should ignore context lost events
  94641. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94642. */
  94643. doNotHandleContextLost?: boolean;
  94644. /**
  94645. * Defines that engine should ignore modifying touch action attribute and style
  94646. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94647. */
  94648. doNotHandleTouchAction?: boolean;
  94649. /**
  94650. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94651. */
  94652. useHighPrecisionFloats?: boolean;
  94653. }
  94654. /**
  94655. * Defines the interface used by display changed events
  94656. */
  94657. export interface IDisplayChangedEventArgs {
  94658. /** Gets the vrDisplay object (if any) */
  94659. vrDisplay: Nullable<any>;
  94660. /** Gets a boolean indicating if webVR is supported */
  94661. vrSupported: boolean;
  94662. }
  94663. /**
  94664. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94665. */
  94666. export class Engine {
  94667. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94668. static ExceptionList: ({
  94669. key: string;
  94670. capture: string;
  94671. captureConstraint: number;
  94672. targets: string[];
  94673. } | {
  94674. key: string;
  94675. capture: null;
  94676. captureConstraint: null;
  94677. targets: string[];
  94678. })[];
  94679. /** Gets the list of created engines */
  94680. static readonly Instances: Engine[];
  94681. /**
  94682. * Gets the latest created engine
  94683. */
  94684. static readonly LastCreatedEngine: Nullable<Engine>;
  94685. /**
  94686. * Gets the latest created scene
  94687. */
  94688. static readonly LastCreatedScene: Nullable<Scene>;
  94689. /**
  94690. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94691. * @param flag defines which part of the materials must be marked as dirty
  94692. * @param predicate defines a predicate used to filter which materials should be affected
  94693. */
  94694. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94695. /** @hidden */
  94696. static _TextureLoaders: IInternalTextureLoader[];
  94697. /** Defines that alpha blending is disabled */
  94698. static readonly ALPHA_DISABLE: number;
  94699. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94700. static readonly ALPHA_ADD: number;
  94701. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94702. static readonly ALPHA_COMBINE: number;
  94703. /** Defines that alpha blending to DEST - SRC * DEST */
  94704. static readonly ALPHA_SUBTRACT: number;
  94705. /** Defines that alpha blending to SRC * DEST */
  94706. static readonly ALPHA_MULTIPLY: number;
  94707. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94708. static readonly ALPHA_MAXIMIZED: number;
  94709. /** Defines that alpha blending to SRC + DEST */
  94710. static readonly ALPHA_ONEONE: number;
  94711. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94712. static readonly ALPHA_PREMULTIPLIED: number;
  94713. /**
  94714. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94715. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94716. */
  94717. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94718. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94719. static readonly ALPHA_INTERPOLATE: number;
  94720. /**
  94721. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94722. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94723. */
  94724. static readonly ALPHA_SCREENMODE: number;
  94725. /** Defines that the ressource is not delayed*/
  94726. static readonly DELAYLOADSTATE_NONE: number;
  94727. /** Defines that the ressource was successfully delay loaded */
  94728. static readonly DELAYLOADSTATE_LOADED: number;
  94729. /** Defines that the ressource is currently delay loading */
  94730. static readonly DELAYLOADSTATE_LOADING: number;
  94731. /** Defines that the ressource is delayed and has not started loading */
  94732. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94734. static readonly NEVER: number;
  94735. /** 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 */
  94736. static readonly ALWAYS: number;
  94737. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94738. static readonly LESS: number;
  94739. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94740. static readonly EQUAL: number;
  94741. /** 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 */
  94742. static readonly LEQUAL: number;
  94743. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94744. static readonly GREATER: number;
  94745. /** 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 */
  94746. static readonly GEQUAL: number;
  94747. /** 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 */
  94748. static readonly NOTEQUAL: number;
  94749. /** Passed to stencilOperation to specify that stencil value must be kept */
  94750. static readonly KEEP: number;
  94751. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94752. static readonly REPLACE: number;
  94753. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94754. static readonly INCR: number;
  94755. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94756. static readonly DECR: number;
  94757. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94758. static readonly INVERT: number;
  94759. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94760. static readonly INCR_WRAP: number;
  94761. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94762. static readonly DECR_WRAP: number;
  94763. /** Texture is not repeating outside of 0..1 UVs */
  94764. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94765. /** Texture is repeating outside of 0..1 UVs */
  94766. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94767. /** Texture is repeating and mirrored */
  94768. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94769. /** ALPHA */
  94770. static readonly TEXTUREFORMAT_ALPHA: number;
  94771. /** LUMINANCE */
  94772. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94773. /** LUMINANCE_ALPHA */
  94774. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94775. /** RGB */
  94776. static readonly TEXTUREFORMAT_RGB: number;
  94777. /** RGBA */
  94778. static readonly TEXTUREFORMAT_RGBA: number;
  94779. /** RED */
  94780. static readonly TEXTUREFORMAT_RED: number;
  94781. /** RED (2nd reference) */
  94782. static readonly TEXTUREFORMAT_R: number;
  94783. /** RG */
  94784. static readonly TEXTUREFORMAT_RG: number;
  94785. /** RED_INTEGER */
  94786. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94787. /** RED_INTEGER (2nd reference) */
  94788. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94789. /** RG_INTEGER */
  94790. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94791. /** RGB_INTEGER */
  94792. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94793. /** RGBA_INTEGER */
  94794. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94795. /** UNSIGNED_BYTE */
  94796. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94797. /** UNSIGNED_BYTE (2nd reference) */
  94798. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94799. /** FLOAT */
  94800. static readonly TEXTURETYPE_FLOAT: number;
  94801. /** HALF_FLOAT */
  94802. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94803. /** BYTE */
  94804. static readonly TEXTURETYPE_BYTE: number;
  94805. /** SHORT */
  94806. static readonly TEXTURETYPE_SHORT: number;
  94807. /** UNSIGNED_SHORT */
  94808. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94809. /** INT */
  94810. static readonly TEXTURETYPE_INT: number;
  94811. /** UNSIGNED_INT */
  94812. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94813. /** UNSIGNED_SHORT_4_4_4_4 */
  94814. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94815. /** UNSIGNED_SHORT_5_5_5_1 */
  94816. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94817. /** UNSIGNED_SHORT_5_6_5 */
  94818. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94819. /** UNSIGNED_INT_2_10_10_10_REV */
  94820. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94821. /** UNSIGNED_INT_24_8 */
  94822. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94823. /** UNSIGNED_INT_10F_11F_11F_REV */
  94824. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94825. /** UNSIGNED_INT_5_9_9_9_REV */
  94826. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94827. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94828. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94829. /** nearest is mag = nearest and min = nearest and mip = linear */
  94830. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94831. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94832. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94833. /** Trilinear is mag = linear and min = linear and mip = linear */
  94834. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94835. /** nearest is mag = nearest and min = nearest and mip = linear */
  94836. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94839. /** Trilinear is mag = linear and min = linear and mip = linear */
  94840. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94841. /** mag = nearest and min = nearest and mip = nearest */
  94842. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94843. /** mag = nearest and min = linear and mip = nearest */
  94844. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94845. /** mag = nearest and min = linear and mip = linear */
  94846. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94847. /** mag = nearest and min = linear and mip = none */
  94848. static readonly TEXTURE_NEAREST_LINEAR: number;
  94849. /** mag = nearest and min = nearest and mip = none */
  94850. static readonly TEXTURE_NEAREST_NEAREST: number;
  94851. /** mag = linear and min = nearest and mip = nearest */
  94852. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94853. /** mag = linear and min = nearest and mip = linear */
  94854. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94855. /** mag = linear and min = linear and mip = none */
  94856. static readonly TEXTURE_LINEAR_LINEAR: number;
  94857. /** mag = linear and min = nearest and mip = none */
  94858. static readonly TEXTURE_LINEAR_NEAREST: number;
  94859. /** Explicit coordinates mode */
  94860. static readonly TEXTURE_EXPLICIT_MODE: number;
  94861. /** Spherical coordinates mode */
  94862. static readonly TEXTURE_SPHERICAL_MODE: number;
  94863. /** Planar coordinates mode */
  94864. static readonly TEXTURE_PLANAR_MODE: number;
  94865. /** Cubic coordinates mode */
  94866. static readonly TEXTURE_CUBIC_MODE: number;
  94867. /** Projection coordinates mode */
  94868. static readonly TEXTURE_PROJECTION_MODE: number;
  94869. /** Skybox coordinates mode */
  94870. static readonly TEXTURE_SKYBOX_MODE: number;
  94871. /** Inverse Cubic coordinates mode */
  94872. static readonly TEXTURE_INVCUBIC_MODE: number;
  94873. /** Equirectangular coordinates mode */
  94874. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94875. /** Equirectangular Fixed coordinates mode */
  94876. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94877. /** Equirectangular Fixed Mirrored coordinates mode */
  94878. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94879. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94880. static readonly SCALEMODE_FLOOR: number;
  94881. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94882. static readonly SCALEMODE_NEAREST: number;
  94883. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94884. static readonly SCALEMODE_CEILING: number;
  94885. /**
  94886. * Returns the current npm package of the sdk
  94887. */
  94888. static readonly NpmPackage: string;
  94889. /**
  94890. * Returns the current version of the framework
  94891. */
  94892. static readonly Version: string;
  94893. /**
  94894. * Returns a string describing the current engine
  94895. */
  94896. readonly description: string;
  94897. /**
  94898. * Gets or sets the epsilon value used by collision engine
  94899. */
  94900. static CollisionsEpsilon: number;
  94901. /**
  94902. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94903. */
  94904. static ShadersRepository: string;
  94905. /**
  94906. * Method called to create the default loading screen.
  94907. * This can be overriden in your own app.
  94908. * @param canvas The rendering canvas element
  94909. * @returns The loading screen
  94910. */
  94911. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94912. /**
  94913. * Method called to create the default rescale post process on each engine.
  94914. */
  94915. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94916. /** @hidden */
  94917. _shaderProcessor: IShaderProcessor;
  94918. /**
  94919. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94920. */
  94921. forcePOTTextures: boolean;
  94922. /**
  94923. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94924. */
  94925. isFullscreen: boolean;
  94926. /**
  94927. * Gets a boolean indicating if the pointer is currently locked
  94928. */
  94929. isPointerLock: boolean;
  94930. /**
  94931. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94932. */
  94933. cullBackFaces: boolean;
  94934. /**
  94935. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94936. */
  94937. renderEvenInBackground: boolean;
  94938. /**
  94939. * Gets or sets a boolean indicating that cache can be kept between frames
  94940. */
  94941. preventCacheWipeBetweenFrames: boolean;
  94942. /**
  94943. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94944. **/
  94945. enableOfflineSupport: boolean;
  94946. /**
  94947. * 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)
  94948. **/
  94949. disableManifestCheck: boolean;
  94950. /**
  94951. * Gets the list of created scenes
  94952. */
  94953. scenes: Scene[];
  94954. /**
  94955. * Event raised when a new scene is created
  94956. */
  94957. onNewSceneAddedObservable: Observable<Scene>;
  94958. /**
  94959. * Gets the list of created postprocesses
  94960. */
  94961. postProcesses: PostProcess[];
  94962. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94963. validateShaderPrograms: boolean;
  94964. /**
  94965. * Observable event triggered each time the rendering canvas is resized
  94966. */
  94967. onResizeObservable: Observable<Engine>;
  94968. /**
  94969. * Observable event triggered each time the canvas loses focus
  94970. */
  94971. onCanvasBlurObservable: Observable<Engine>;
  94972. /**
  94973. * Observable event triggered each time the canvas gains focus
  94974. */
  94975. onCanvasFocusObservable: Observable<Engine>;
  94976. /**
  94977. * Observable event triggered each time the canvas receives pointerout event
  94978. */
  94979. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94980. /**
  94981. * Observable event triggered before each texture is initialized
  94982. */
  94983. onBeforeTextureInitObservable: Observable<Texture>;
  94984. /**
  94985. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94986. */
  94987. disableUniformBuffers: boolean;
  94988. /** @hidden */
  94989. _uniformBuffers: UniformBuffer[];
  94990. /**
  94991. * Gets a boolean indicating that the engine supports uniform buffers
  94992. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94993. */
  94994. readonly supportsUniformBuffers: boolean;
  94995. /**
  94996. * Observable raised when the engine begins a new frame
  94997. */
  94998. onBeginFrameObservable: Observable<Engine>;
  94999. /**
  95000. * If set, will be used to request the next animation frame for the render loop
  95001. */
  95002. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95003. /**
  95004. * Observable raised when the engine ends the current frame
  95005. */
  95006. onEndFrameObservable: Observable<Engine>;
  95007. /**
  95008. * Observable raised when the engine is about to compile a shader
  95009. */
  95010. onBeforeShaderCompilationObservable: Observable<Engine>;
  95011. /**
  95012. * Observable raised when the engine has jsut compiled a shader
  95013. */
  95014. onAfterShaderCompilationObservable: Observable<Engine>;
  95015. /** @hidden */
  95016. _gl: WebGLRenderingContext;
  95017. private _renderingCanvas;
  95018. private _windowIsBackground;
  95019. private _webGLVersion;
  95020. protected _highPrecisionShadersAllowed: boolean;
  95021. /** @hidden */
  95022. readonly _shouldUseHighPrecisionShader: boolean;
  95023. /**
  95024. * Gets a boolean indicating that only power of 2 textures are supported
  95025. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95026. */
  95027. readonly needPOTTextures: boolean;
  95028. /** @hidden */
  95029. _badOS: boolean;
  95030. /** @hidden */
  95031. _badDesktopOS: boolean;
  95032. /**
  95033. * Gets the audio engine
  95034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95035. * @ignorenaming
  95036. */
  95037. static audioEngine: IAudioEngine;
  95038. /**
  95039. * Default AudioEngine factory responsible of creating the Audio Engine.
  95040. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95041. */
  95042. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95043. /**
  95044. * Default offline support factory responsible of creating a tool used to store data locally.
  95045. * By default, this will create a Database object if the workload has been embedded.
  95046. */
  95047. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95048. private _onFocus;
  95049. private _onBlur;
  95050. private _onCanvasPointerOut;
  95051. private _onCanvasBlur;
  95052. private _onCanvasFocus;
  95053. private _onFullscreenChange;
  95054. private _onPointerLockChange;
  95055. private _hardwareScalingLevel;
  95056. /** @hidden */
  95057. _caps: EngineCapabilities;
  95058. private _pointerLockRequested;
  95059. private _isStencilEnable;
  95060. private _colorWrite;
  95061. private _loadingScreen;
  95062. /** @hidden */
  95063. _drawCalls: PerfCounter;
  95064. private _glVersion;
  95065. private _glRenderer;
  95066. private _glVendor;
  95067. private _videoTextureSupported;
  95068. private _renderingQueueLaunched;
  95069. private _activeRenderLoops;
  95070. private _deterministicLockstep;
  95071. private _lockstepMaxSteps;
  95072. /**
  95073. * Observable signaled when a context lost event is raised
  95074. */
  95075. onContextLostObservable: Observable<Engine>;
  95076. /**
  95077. * Observable signaled when a context restored event is raised
  95078. */
  95079. onContextRestoredObservable: Observable<Engine>;
  95080. private _onContextLost;
  95081. private _onContextRestored;
  95082. private _contextWasLost;
  95083. /** @hidden */
  95084. _doNotHandleContextLost: boolean;
  95085. /**
  95086. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95088. */
  95089. doNotHandleContextLost: boolean;
  95090. private _performanceMonitor;
  95091. private _fps;
  95092. private _deltaTime;
  95093. /**
  95094. * Turn this value on if you want to pause FPS computation when in background
  95095. */
  95096. disablePerformanceMonitorInBackground: boolean;
  95097. /**
  95098. * Gets the performance monitor attached to this engine
  95099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95100. */
  95101. readonly performanceMonitor: PerformanceMonitor;
  95102. /**
  95103. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95104. */
  95105. disableVertexArrayObjects: boolean;
  95106. /** @hidden */
  95107. protected _depthCullingState: _DepthCullingState;
  95108. /** @hidden */
  95109. protected _stencilState: _StencilState;
  95110. /** @hidden */
  95111. protected _alphaState: _AlphaState;
  95112. /** @hidden */
  95113. protected _alphaMode: number;
  95114. /** @hidden */
  95115. _internalTexturesCache: InternalTexture[];
  95116. /** @hidden */
  95117. protected _activeChannel: number;
  95118. private _currentTextureChannel;
  95119. /** @hidden */
  95120. protected _boundTexturesCache: {
  95121. [key: string]: Nullable<InternalTexture>;
  95122. };
  95123. /** @hidden */
  95124. protected _currentEffect: Nullable<Effect>;
  95125. /** @hidden */
  95126. protected _currentProgram: Nullable<WebGLProgram>;
  95127. private _compiledEffects;
  95128. private _vertexAttribArraysEnabled;
  95129. /** @hidden */
  95130. protected _cachedViewport: Nullable<IViewportLike>;
  95131. private _cachedVertexArrayObject;
  95132. /** @hidden */
  95133. protected _cachedVertexBuffers: any;
  95134. /** @hidden */
  95135. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95136. /** @hidden */
  95137. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95138. /** @hidden */
  95139. _currentRenderTarget: Nullable<InternalTexture>;
  95140. private _uintIndicesCurrentlySet;
  95141. private _currentBoundBuffer;
  95142. /** @hidden */
  95143. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95144. private _currentBufferPointers;
  95145. private _currentInstanceLocations;
  95146. private _currentInstanceBuffers;
  95147. private _textureUnits;
  95148. /** @hidden */
  95149. _workingCanvas: Nullable<HTMLCanvasElement>;
  95150. /** @hidden */
  95151. _workingContext: Nullable<CanvasRenderingContext2D>;
  95152. private _rescalePostProcess;
  95153. private _dummyFramebuffer;
  95154. private _externalData;
  95155. /** @hidden */
  95156. _bindedRenderFunction: any;
  95157. private _vaoRecordInProgress;
  95158. private _mustWipeVertexAttributes;
  95159. private _emptyTexture;
  95160. private _emptyCubeTexture;
  95161. private _emptyTexture3D;
  95162. /** @hidden */
  95163. _frameHandler: number;
  95164. private _nextFreeTextureSlots;
  95165. private _maxSimultaneousTextures;
  95166. private _activeRequests;
  95167. private _texturesSupported;
  95168. /** @hidden */
  95169. _textureFormatInUse: Nullable<string>;
  95170. /**
  95171. * Gets the list of texture formats supported
  95172. */
  95173. readonly texturesSupported: Array<string>;
  95174. /**
  95175. * Gets the list of texture formats in use
  95176. */
  95177. readonly textureFormatInUse: Nullable<string>;
  95178. /**
  95179. * Gets the current viewport
  95180. */
  95181. readonly currentViewport: Nullable<IViewportLike>;
  95182. /**
  95183. * Gets the default empty texture
  95184. */
  95185. readonly emptyTexture: InternalTexture;
  95186. /**
  95187. * Gets the default empty 3D texture
  95188. */
  95189. readonly emptyTexture3D: InternalTexture;
  95190. /**
  95191. * Gets the default empty cube texture
  95192. */
  95193. readonly emptyCubeTexture: InternalTexture;
  95194. /**
  95195. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95196. */
  95197. readonly premultipliedAlpha: boolean;
  95198. /**
  95199. * Creates a new engine
  95200. * @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
  95201. * @param antialias defines enable antialiasing (default: false)
  95202. * @param options defines further options to be sent to the getContext() function
  95203. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95204. */
  95205. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95206. /**
  95207. * Initializes a webVR display and starts listening to display change events
  95208. * The onVRDisplayChangedObservable will be notified upon these changes
  95209. * @returns The onVRDisplayChangedObservable
  95210. */
  95211. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95212. /** @hidden */
  95213. _prepareVRComponent(): void;
  95214. /** @hidden */
  95215. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95216. /** @hidden */
  95217. _submitVRFrame(): void;
  95218. /**
  95219. * Call this function to leave webVR mode
  95220. * Will do nothing if webVR is not supported or if there is no webVR device
  95221. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95222. */
  95223. disableVR(): void;
  95224. /**
  95225. * Gets a boolean indicating that the system is in VR mode and is presenting
  95226. * @returns true if VR mode is engaged
  95227. */
  95228. isVRPresenting(): boolean;
  95229. /** @hidden */
  95230. _requestVRFrame(): void;
  95231. private _disableTouchAction;
  95232. private _rebuildInternalTextures;
  95233. private _rebuildEffects;
  95234. /**
  95235. * Gets a boolean indicating if all created effects are ready
  95236. * @returns true if all effects are ready
  95237. */
  95238. areAllEffectsReady(): boolean;
  95239. private _rebuildBuffers;
  95240. private _initGLContext;
  95241. /**
  95242. * Gets version of the current webGL context
  95243. */
  95244. readonly webGLVersion: number;
  95245. /**
  95246. * Gets a string idenfifying the name of the class
  95247. * @returns "Engine" string
  95248. */
  95249. getClassName(): string;
  95250. /**
  95251. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95252. */
  95253. readonly isStencilEnable: boolean;
  95254. /** @hidden */
  95255. _prepareWorkingCanvas(): void;
  95256. /**
  95257. * Reset the texture cache to empty state
  95258. */
  95259. resetTextureCache(): void;
  95260. /**
  95261. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95262. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95263. * @returns true if engine is in deterministic lock step mode
  95264. */
  95265. isDeterministicLockStep(): boolean;
  95266. /**
  95267. * Gets the max steps when engine is running in deterministic lock step
  95268. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95269. * @returns the max steps
  95270. */
  95271. getLockstepMaxSteps(): number;
  95272. /**
  95273. * Gets an object containing information about the current webGL context
  95274. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95275. */
  95276. getGlInfo(): {
  95277. vendor: string;
  95278. renderer: string;
  95279. version: string;
  95280. };
  95281. /**
  95282. * Gets current aspect ratio
  95283. * @param viewportOwner defines the camera to use to get the aspect ratio
  95284. * @param useScreen defines if screen size must be used (or the current render target if any)
  95285. * @returns a number defining the aspect ratio
  95286. */
  95287. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95288. /**
  95289. * Gets current screen aspect ratio
  95290. * @returns a number defining the aspect ratio
  95291. */
  95292. getScreenAspectRatio(): number;
  95293. /**
  95294. * Gets the current render width
  95295. * @param useScreen defines if screen size must be used (or the current render target if any)
  95296. * @returns a number defining the current render width
  95297. */
  95298. getRenderWidth(useScreen?: boolean): number;
  95299. /**
  95300. * Gets the current render height
  95301. * @param useScreen defines if screen size must be used (or the current render target if any)
  95302. * @returns a number defining the current render height
  95303. */
  95304. getRenderHeight(useScreen?: boolean): number;
  95305. /**
  95306. * Gets the HTML canvas attached with the current webGL context
  95307. * @returns a HTML canvas
  95308. */
  95309. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95310. /**
  95311. * Gets host window
  95312. * @returns the host window object
  95313. */
  95314. getHostWindow(): Window;
  95315. /**
  95316. * Gets host document
  95317. * @returns the host document object
  95318. */
  95319. getHostDocument(): Document;
  95320. /**
  95321. * Gets the client rect of the HTML canvas attached with the current webGL context
  95322. * @returns a client rectanglee
  95323. */
  95324. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95325. /**
  95326. * Defines the hardware scaling level.
  95327. * By default the hardware scaling level is computed from the window device ratio.
  95328. * 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.
  95329. * @param level defines the level to use
  95330. */
  95331. setHardwareScalingLevel(level: number): void;
  95332. /**
  95333. * Gets the current hardware scaling level.
  95334. * By default the hardware scaling level is computed from the window device ratio.
  95335. * 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.
  95336. * @returns a number indicating the current hardware scaling level
  95337. */
  95338. getHardwareScalingLevel(): number;
  95339. /**
  95340. * Gets the list of loaded textures
  95341. * @returns an array containing all loaded textures
  95342. */
  95343. getLoadedTexturesCache(): InternalTexture[];
  95344. /**
  95345. * Gets the object containing all engine capabilities
  95346. * @returns the EngineCapabilities object
  95347. */
  95348. getCaps(): EngineCapabilities;
  95349. /**
  95350. * Gets the current depth function
  95351. * @returns a number defining the depth function
  95352. */
  95353. getDepthFunction(): Nullable<number>;
  95354. /**
  95355. * Sets the current depth function
  95356. * @param depthFunc defines the function to use
  95357. */
  95358. setDepthFunction(depthFunc: number): void;
  95359. /**
  95360. * Sets the current depth function to GREATER
  95361. */
  95362. setDepthFunctionToGreater(): void;
  95363. /**
  95364. * Sets the current depth function to GEQUAL
  95365. */
  95366. setDepthFunctionToGreaterOrEqual(): void;
  95367. /**
  95368. * Sets the current depth function to LESS
  95369. */
  95370. setDepthFunctionToLess(): void;
  95371. private _cachedStencilBuffer;
  95372. private _cachedStencilFunction;
  95373. private _cachedStencilMask;
  95374. private _cachedStencilOperationPass;
  95375. private _cachedStencilOperationFail;
  95376. private _cachedStencilOperationDepthFail;
  95377. private _cachedStencilReference;
  95378. /**
  95379. * Caches the the state of the stencil buffer
  95380. */
  95381. cacheStencilState(): void;
  95382. /**
  95383. * Restores the state of the stencil buffer
  95384. */
  95385. restoreStencilState(): void;
  95386. /**
  95387. * Sets the current depth function to LEQUAL
  95388. */
  95389. setDepthFunctionToLessOrEqual(): void;
  95390. /**
  95391. * Gets a boolean indicating if stencil buffer is enabled
  95392. * @returns the current stencil buffer state
  95393. */
  95394. getStencilBuffer(): boolean;
  95395. /**
  95396. * Enable or disable the stencil buffer
  95397. * @param enable defines if the stencil buffer must be enabled or disabled
  95398. */
  95399. setStencilBuffer(enable: boolean): void;
  95400. /**
  95401. * Gets the current stencil mask
  95402. * @returns a number defining the new stencil mask to use
  95403. */
  95404. getStencilMask(): number;
  95405. /**
  95406. * Sets the current stencil mask
  95407. * @param mask defines the new stencil mask to use
  95408. */
  95409. setStencilMask(mask: number): void;
  95410. /**
  95411. * Gets the current stencil function
  95412. * @returns a number defining the stencil function to use
  95413. */
  95414. getStencilFunction(): number;
  95415. /**
  95416. * Gets the current stencil reference value
  95417. * @returns a number defining the stencil reference value to use
  95418. */
  95419. getStencilFunctionReference(): number;
  95420. /**
  95421. * Gets the current stencil mask
  95422. * @returns a number defining the stencil mask to use
  95423. */
  95424. getStencilFunctionMask(): number;
  95425. /**
  95426. * Sets the current stencil function
  95427. * @param stencilFunc defines the new stencil function to use
  95428. */
  95429. setStencilFunction(stencilFunc: number): void;
  95430. /**
  95431. * Sets the current stencil reference
  95432. * @param reference defines the new stencil reference to use
  95433. */
  95434. setStencilFunctionReference(reference: number): void;
  95435. /**
  95436. * Sets the current stencil mask
  95437. * @param mask defines the new stencil mask to use
  95438. */
  95439. setStencilFunctionMask(mask: number): void;
  95440. /**
  95441. * Gets the current stencil operation when stencil fails
  95442. * @returns a number defining stencil operation to use when stencil fails
  95443. */
  95444. getStencilOperationFail(): number;
  95445. /**
  95446. * Gets the current stencil operation when depth fails
  95447. * @returns a number defining stencil operation to use when depth fails
  95448. */
  95449. getStencilOperationDepthFail(): number;
  95450. /**
  95451. * Gets the current stencil operation when stencil passes
  95452. * @returns a number defining stencil operation to use when stencil passes
  95453. */
  95454. getStencilOperationPass(): number;
  95455. /**
  95456. * Sets the stencil operation to use when stencil fails
  95457. * @param operation defines the stencil operation to use when stencil fails
  95458. */
  95459. setStencilOperationFail(operation: number): void;
  95460. /**
  95461. * Sets the stencil operation to use when depth fails
  95462. * @param operation defines the stencil operation to use when depth fails
  95463. */
  95464. setStencilOperationDepthFail(operation: number): void;
  95465. /**
  95466. * Sets the stencil operation to use when stencil passes
  95467. * @param operation defines the stencil operation to use when stencil passes
  95468. */
  95469. setStencilOperationPass(operation: number): void;
  95470. /**
  95471. * Sets a boolean indicating if the dithering state is enabled or disabled
  95472. * @param value defines the dithering state
  95473. */
  95474. setDitheringState(value: boolean): void;
  95475. /**
  95476. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95477. * @param value defines the rasterizer state
  95478. */
  95479. setRasterizerState(value: boolean): void;
  95480. /**
  95481. * stop executing a render loop function and remove it from the execution array
  95482. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95483. */
  95484. stopRenderLoop(renderFunction?: () => void): void;
  95485. /** @hidden */
  95486. _renderLoop(): void;
  95487. /**
  95488. * Register and execute a render loop. The engine can have more than one render function
  95489. * @param renderFunction defines the function to continuously execute
  95490. */
  95491. runRenderLoop(renderFunction: () => void): void;
  95492. /**
  95493. * Toggle full screen mode
  95494. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95495. */
  95496. switchFullscreen(requestPointerLock: boolean): void;
  95497. /**
  95498. * Enters full screen mode
  95499. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95500. */
  95501. enterFullscreen(requestPointerLock: boolean): void;
  95502. /**
  95503. * Exits full screen mode
  95504. */
  95505. exitFullscreen(): void;
  95506. /**
  95507. * Enters Pointerlock mode
  95508. */
  95509. enterPointerlock(): void;
  95510. /**
  95511. * Exits Pointerlock mode
  95512. */
  95513. exitPointerlock(): void;
  95514. /**
  95515. * Clear the current render buffer or the current render target (if any is set up)
  95516. * @param color defines the color to use
  95517. * @param backBuffer defines if the back buffer must be cleared
  95518. * @param depth defines if the depth buffer must be cleared
  95519. * @param stencil defines if the stencil buffer must be cleared
  95520. */
  95521. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95522. /**
  95523. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95524. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95525. * @param y defines the y-coordinate of the corner of the clear rectangle
  95526. * @param width defines the width of the clear rectangle
  95527. * @param height defines the height of the clear rectangle
  95528. * @param clearColor defines the clear color
  95529. */
  95530. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95531. /**
  95532. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95533. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95534. * @param y defines the y-coordinate of the corner of the clear rectangle
  95535. * @param width defines the width of the clear rectangle
  95536. * @param height defines the height of the clear rectangle
  95537. */
  95538. enableScissor(x: number, y: number, width: number, height: number): void;
  95539. /**
  95540. * Disable previously set scissor test rectangle
  95541. */
  95542. disableScissor(): void;
  95543. private _viewportCached;
  95544. /** @hidden */
  95545. _viewport(x: number, y: number, width: number, height: number): void;
  95546. /**
  95547. * Set the WebGL's viewport
  95548. * @param viewport defines the viewport element to be used
  95549. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95550. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95551. */
  95552. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95553. /**
  95554. * Directly set the WebGL Viewport
  95555. * @param x defines the x coordinate of the viewport (in screen space)
  95556. * @param y defines the y coordinate of the viewport (in screen space)
  95557. * @param width defines the width of the viewport (in screen space)
  95558. * @param height defines the height of the viewport (in screen space)
  95559. * @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
  95560. */
  95561. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95562. /**
  95563. * Begin a new frame
  95564. */
  95565. beginFrame(): void;
  95566. /**
  95567. * Enf the current frame
  95568. */
  95569. endFrame(): void;
  95570. /**
  95571. * Resize the view according to the canvas' size
  95572. */
  95573. resize(): void;
  95574. /**
  95575. * Force a specific size of the canvas
  95576. * @param width defines the new canvas' width
  95577. * @param height defines the new canvas' height
  95578. */
  95579. setSize(width: number, height: number): void;
  95580. /**
  95581. * Binds the frame buffer to the specified texture.
  95582. * @param texture The texture to render to or null for the default canvas
  95583. * @param faceIndex The face of the texture to render to in case of cube texture
  95584. * @param requiredWidth The width of the target to render to
  95585. * @param requiredHeight The height of the target to render to
  95586. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95587. * @param depthStencilTexture The depth stencil texture to use to render
  95588. * @param lodLevel defines le lod level to bind to the frame buffer
  95589. */
  95590. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95591. /** @hidden */
  95592. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95593. /**
  95594. * Unbind the current render target texture from the webGL context
  95595. * @param texture defines the render target texture to unbind
  95596. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95597. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95598. */
  95599. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95600. /**
  95601. * Force the mipmap generation for the given render target texture
  95602. * @param texture defines the render target texture to use
  95603. */
  95604. generateMipMapsForCubemap(texture: InternalTexture): void;
  95605. /**
  95606. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95607. */
  95608. flushFramebuffer(): void;
  95609. /**
  95610. * Unbind the current render target and bind the default framebuffer
  95611. */
  95612. restoreDefaultFramebuffer(): void;
  95613. /**
  95614. * Create an uniform buffer
  95615. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95616. * @param elements defines the content of the uniform buffer
  95617. * @returns the webGL uniform buffer
  95618. */
  95619. createUniformBuffer(elements: FloatArray): DataBuffer;
  95620. /**
  95621. * Create a dynamic uniform buffer
  95622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95623. * @param elements defines the content of the uniform buffer
  95624. * @returns the webGL uniform buffer
  95625. */
  95626. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95627. /**
  95628. * Update an existing uniform buffer
  95629. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95630. * @param uniformBuffer defines the target uniform buffer
  95631. * @param elements defines the content to update
  95632. * @param offset defines the offset in the uniform buffer where update should start
  95633. * @param count defines the size of the data to update
  95634. */
  95635. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95636. private _resetVertexBufferBinding;
  95637. /**
  95638. * Creates a vertex buffer
  95639. * @param data the data for the vertex buffer
  95640. * @returns the new WebGL static buffer
  95641. */
  95642. createVertexBuffer(data: DataArray): DataBuffer;
  95643. /**
  95644. * Creates a dynamic vertex buffer
  95645. * @param data the data for the dynamic vertex buffer
  95646. * @returns the new WebGL dynamic buffer
  95647. */
  95648. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95649. /**
  95650. * Update a dynamic index buffer
  95651. * @param indexBuffer defines the target index buffer
  95652. * @param indices defines the data to update
  95653. * @param offset defines the offset in the target index buffer where update should start
  95654. */
  95655. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95656. /**
  95657. * Updates a dynamic vertex buffer.
  95658. * @param vertexBuffer the vertex buffer to update
  95659. * @param data the data used to update the vertex buffer
  95660. * @param byteOffset the byte offset of the data
  95661. * @param byteLength the byte length of the data
  95662. */
  95663. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95664. private _resetIndexBufferBinding;
  95665. /**
  95666. * Creates a new index buffer
  95667. * @param indices defines the content of the index buffer
  95668. * @param updatable defines if the index buffer must be updatable
  95669. * @returns a new webGL buffer
  95670. */
  95671. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95672. /**
  95673. * Bind a webGL buffer to the webGL context
  95674. * @param buffer defines the buffer to bind
  95675. */
  95676. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95677. /**
  95678. * Bind an uniform buffer to the current webGL context
  95679. * @param buffer defines the buffer to bind
  95680. */
  95681. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95682. /**
  95683. * Bind a buffer to the current webGL context at a given location
  95684. * @param buffer defines the buffer to bind
  95685. * @param location defines the index where to bind the buffer
  95686. */
  95687. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95688. /**
  95689. * Bind a specific block at a given index in a specific shader program
  95690. * @param pipelineContext defines the pipeline context to use
  95691. * @param blockName defines the block name
  95692. * @param index defines the index where to bind the block
  95693. */
  95694. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95695. private bindIndexBuffer;
  95696. private bindBuffer;
  95697. /**
  95698. * update the bound buffer with the given data
  95699. * @param data defines the data to update
  95700. */
  95701. updateArrayBuffer(data: Float32Array): void;
  95702. private _vertexAttribPointer;
  95703. private _bindIndexBufferWithCache;
  95704. private _bindVertexBuffersAttributes;
  95705. /**
  95706. * Records a vertex array object
  95707. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95708. * @param vertexBuffers defines the list of vertex buffers to store
  95709. * @param indexBuffer defines the index buffer to store
  95710. * @param effect defines the effect to store
  95711. * @returns the new vertex array object
  95712. */
  95713. recordVertexArrayObject(vertexBuffers: {
  95714. [key: string]: VertexBuffer;
  95715. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95716. /**
  95717. * Bind a specific vertex array object
  95718. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95719. * @param vertexArrayObject defines the vertex array object to bind
  95720. * @param indexBuffer defines the index buffer to bind
  95721. */
  95722. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95723. /**
  95724. * Bind webGl buffers directly to the webGL context
  95725. * @param vertexBuffer defines the vertex buffer to bind
  95726. * @param indexBuffer defines the index buffer to bind
  95727. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95728. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95729. * @param effect defines the effect associated with the vertex buffer
  95730. */
  95731. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95732. private _unbindVertexArrayObject;
  95733. /**
  95734. * Bind a list of vertex buffers to the webGL context
  95735. * @param vertexBuffers defines the list of vertex buffers to bind
  95736. * @param indexBuffer defines the index buffer to bind
  95737. * @param effect defines the effect associated with the vertex buffers
  95738. */
  95739. bindBuffers(vertexBuffers: {
  95740. [key: string]: Nullable<VertexBuffer>;
  95741. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95742. /**
  95743. * Unbind all instance attributes
  95744. */
  95745. unbindInstanceAttributes(): void;
  95746. /**
  95747. * Release and free the memory of a vertex array object
  95748. * @param vao defines the vertex array object to delete
  95749. */
  95750. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95751. /** @hidden */
  95752. _releaseBuffer(buffer: DataBuffer): boolean;
  95753. /**
  95754. * Creates a webGL buffer to use with instanciation
  95755. * @param capacity defines the size of the buffer
  95756. * @returns the webGL buffer
  95757. */
  95758. createInstancesBuffer(capacity: number): DataBuffer;
  95759. /**
  95760. * Delete a webGL buffer used with instanciation
  95761. * @param buffer defines the webGL buffer to delete
  95762. */
  95763. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95764. /**
  95765. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95766. * @param instancesBuffer defines the webGL buffer to update and bind
  95767. * @param data defines the data to store in the buffer
  95768. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95769. */
  95770. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95771. /**
  95772. * Apply all cached states (depth, culling, stencil and alpha)
  95773. */
  95774. applyStates(): void;
  95775. /**
  95776. * Send a draw order
  95777. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95778. * @param indexStart defines the starting index
  95779. * @param indexCount defines the number of index to draw
  95780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95781. */
  95782. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95783. /**
  95784. * Draw a list of points
  95785. * @param verticesStart defines the index of first vertex to draw
  95786. * @param verticesCount defines the count of vertices to draw
  95787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95788. */
  95789. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95790. /**
  95791. * Draw a list of unindexed primitives
  95792. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95793. * @param verticesStart defines the index of first vertex to draw
  95794. * @param verticesCount defines the count of vertices to draw
  95795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95796. */
  95797. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95798. /**
  95799. * Draw a list of indexed primitives
  95800. * @param fillMode defines the primitive to use
  95801. * @param indexStart defines the starting index
  95802. * @param indexCount defines the number of index to draw
  95803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95804. */
  95805. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95806. /**
  95807. * Draw a list of unindexed primitives
  95808. * @param fillMode defines the primitive to use
  95809. * @param verticesStart defines the index of first vertex to draw
  95810. * @param verticesCount defines the count of vertices to draw
  95811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95812. */
  95813. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95814. private _drawMode;
  95815. /** @hidden */
  95816. _releaseEffect(effect: Effect): void;
  95817. /** @hidden */
  95818. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95819. /**
  95820. * Create a new effect (used to store vertex/fragment shaders)
  95821. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95822. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95823. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95824. * @param samplers defines an array of string used to represent textures
  95825. * @param defines defines the string containing the defines to use to compile the shaders
  95826. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95827. * @param onCompiled defines a function to call when the effect creation is successful
  95828. * @param onError defines a function to call when the effect creation has failed
  95829. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95830. * @returns the new Effect
  95831. */
  95832. 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;
  95833. private _compileShader;
  95834. private _compileRawShader;
  95835. /**
  95836. * Directly creates a webGL program
  95837. * @param pipelineContext defines the pipeline context to attach to
  95838. * @param vertexCode defines the vertex shader code to use
  95839. * @param fragmentCode defines the fragment shader code to use
  95840. * @param context defines the webGL context to use (if not set, the current one will be used)
  95841. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95842. * @returns the new webGL program
  95843. */
  95844. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95845. /**
  95846. * Creates a webGL program
  95847. * @param pipelineContext defines the pipeline context to attach to
  95848. * @param vertexCode defines the vertex shader code to use
  95849. * @param fragmentCode defines the fragment shader code to use
  95850. * @param defines defines the string containing the defines to use to compile the shaders
  95851. * @param context defines the webGL context to use (if not set, the current one will be used)
  95852. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95853. * @returns the new webGL program
  95854. */
  95855. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95856. /**
  95857. * Creates a new pipeline context
  95858. * @returns the new pipeline
  95859. */
  95860. createPipelineContext(): WebGLPipelineContext;
  95861. private _createShaderProgram;
  95862. private _finalizePipelineContext;
  95863. /** @hidden */
  95864. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95865. /** @hidden */
  95866. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95867. /** @hidden */
  95868. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95869. /**
  95870. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95871. * @param pipelineContext defines the pipeline context to use
  95872. * @param uniformsNames defines the list of uniform names
  95873. * @returns an array of webGL uniform locations
  95874. */
  95875. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95876. /**
  95877. * Gets the lsit of active attributes for a given webGL program
  95878. * @param pipelineContext defines the pipeline context to use
  95879. * @param attributesNames defines the list of attribute names to get
  95880. * @returns an array of indices indicating the offset of each attribute
  95881. */
  95882. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95883. /**
  95884. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95885. * @param effect defines the effect to activate
  95886. */
  95887. enableEffect(effect: Nullable<Effect>): void;
  95888. /**
  95889. * Set the value of an uniform to an array of int32
  95890. * @param uniform defines the webGL uniform location where to store the value
  95891. * @param array defines the array of int32 to store
  95892. */
  95893. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95894. /**
  95895. * Set the value of an uniform to an array of int32 (stored as vec2)
  95896. * @param uniform defines the webGL uniform location where to store the value
  95897. * @param array defines the array of int32 to store
  95898. */
  95899. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95900. /**
  95901. * Set the value of an uniform to an array of int32 (stored as vec3)
  95902. * @param uniform defines the webGL uniform location where to store the value
  95903. * @param array defines the array of int32 to store
  95904. */
  95905. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95906. /**
  95907. * Set the value of an uniform to an array of int32 (stored as vec4)
  95908. * @param uniform defines the webGL uniform location where to store the value
  95909. * @param array defines the array of int32 to store
  95910. */
  95911. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95912. /**
  95913. * Set the value of an uniform to an array of float32
  95914. * @param uniform defines the webGL uniform location where to store the value
  95915. * @param array defines the array of float32 to store
  95916. */
  95917. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95918. /**
  95919. * Set the value of an uniform to an array of float32 (stored as vec2)
  95920. * @param uniform defines the webGL uniform location where to store the value
  95921. * @param array defines the array of float32 to store
  95922. */
  95923. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95924. /**
  95925. * Set the value of an uniform to an array of float32 (stored as vec3)
  95926. * @param uniform defines the webGL uniform location where to store the value
  95927. * @param array defines the array of float32 to store
  95928. */
  95929. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95930. /**
  95931. * Set the value of an uniform to an array of float32 (stored as vec4)
  95932. * @param uniform defines the webGL uniform location where to store the value
  95933. * @param array defines the array of float32 to store
  95934. */
  95935. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95936. /**
  95937. * Set the value of an uniform to an array of number
  95938. * @param uniform defines the webGL uniform location where to store the value
  95939. * @param array defines the array of number to store
  95940. */
  95941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95942. /**
  95943. * Set the value of an uniform to an array of number (stored as vec2)
  95944. * @param uniform defines the webGL uniform location where to store the value
  95945. * @param array defines the array of number to store
  95946. */
  95947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95948. /**
  95949. * Set the value of an uniform to an array of number (stored as vec3)
  95950. * @param uniform defines the webGL uniform location where to store the value
  95951. * @param array defines the array of number to store
  95952. */
  95953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95954. /**
  95955. * Set the value of an uniform to an array of number (stored as vec4)
  95956. * @param uniform defines the webGL uniform location where to store the value
  95957. * @param array defines the array of number to store
  95958. */
  95959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95960. /**
  95961. * Set the value of an uniform to an array of float32 (stored as matrices)
  95962. * @param uniform defines the webGL uniform location where to store the value
  95963. * @param matrices defines the array of float32 to store
  95964. */
  95965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95966. /**
  95967. * Set the value of an uniform to a matrix (3x3)
  95968. * @param uniform defines the webGL uniform location where to store the value
  95969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95970. */
  95971. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95972. /**
  95973. * Set the value of an uniform to a matrix (2x2)
  95974. * @param uniform defines the webGL uniform location where to store the value
  95975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95976. */
  95977. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95978. /**
  95979. * Set the value of an uniform to a number (int)
  95980. * @param uniform defines the webGL uniform location where to store the value
  95981. * @param value defines the int number to store
  95982. */
  95983. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95984. /**
  95985. * Set the value of an uniform to a number (float)
  95986. * @param uniform defines the webGL uniform location where to store the value
  95987. * @param value defines the float number to store
  95988. */
  95989. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95990. /**
  95991. * Set the value of an uniform to a vec2
  95992. * @param uniform defines the webGL uniform location where to store the value
  95993. * @param x defines the 1st component of the value
  95994. * @param y defines the 2nd component of the value
  95995. */
  95996. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95997. /**
  95998. * Set the value of an uniform to a vec3
  95999. * @param uniform defines the webGL uniform location where to store the value
  96000. * @param x defines the 1st component of the value
  96001. * @param y defines the 2nd component of the value
  96002. * @param z defines the 3rd component of the value
  96003. */
  96004. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96005. /**
  96006. * Set the value of an uniform to a boolean
  96007. * @param uniform defines the webGL uniform location where to store the value
  96008. * @param bool defines the boolean to store
  96009. */
  96010. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96011. /**
  96012. * Set the value of an uniform to a vec4
  96013. * @param uniform defines the webGL uniform location where to store the value
  96014. * @param x defines the 1st component of the value
  96015. * @param y defines the 2nd component of the value
  96016. * @param z defines the 3rd component of the value
  96017. * @param w defines the 4th component of the value
  96018. */
  96019. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96020. /**
  96021. * Sets a Color4 on a uniform variable
  96022. * @param uniform defines the uniform location
  96023. * @param color4 defines the value to be set
  96024. */
  96025. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96026. /**
  96027. * Set various states to the webGL context
  96028. * @param culling defines backface culling state
  96029. * @param zOffset defines the value to apply to zOffset (0 by default)
  96030. * @param force defines if states must be applied even if cache is up to date
  96031. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96032. */
  96033. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96034. /**
  96035. * Set the z offset to apply to current rendering
  96036. * @param value defines the offset to apply
  96037. */
  96038. setZOffset(value: number): void;
  96039. /**
  96040. * Gets the current value of the zOffset
  96041. * @returns the current zOffset state
  96042. */
  96043. getZOffset(): number;
  96044. /**
  96045. * Enable or disable depth buffering
  96046. * @param enable defines the state to set
  96047. */
  96048. setDepthBuffer(enable: boolean): void;
  96049. /**
  96050. * Gets a boolean indicating if depth writing is enabled
  96051. * @returns the current depth writing state
  96052. */
  96053. getDepthWrite(): boolean;
  96054. /**
  96055. * Enable or disable depth writing
  96056. * @param enable defines the state to set
  96057. */
  96058. setDepthWrite(enable: boolean): void;
  96059. /**
  96060. * Enable or disable color writing
  96061. * @param enable defines the state to set
  96062. */
  96063. setColorWrite(enable: boolean): void;
  96064. /**
  96065. * Gets a boolean indicating if color writing is enabled
  96066. * @returns the current color writing state
  96067. */
  96068. getColorWrite(): boolean;
  96069. /**
  96070. * Sets alpha constants used by some alpha blending modes
  96071. * @param r defines the red component
  96072. * @param g defines the green component
  96073. * @param b defines the blue component
  96074. * @param a defines the alpha component
  96075. */
  96076. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96077. /**
  96078. * Sets the current alpha mode
  96079. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96080. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96082. */
  96083. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96084. /**
  96085. * Gets the current alpha mode
  96086. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96087. * @returns the current alpha mode
  96088. */
  96089. getAlphaMode(): number;
  96090. /**
  96091. * Clears the list of texture accessible through engine.
  96092. * This can help preventing texture load conflict due to name collision.
  96093. */
  96094. clearInternalTexturesCache(): void;
  96095. /**
  96096. * Force the entire cache to be cleared
  96097. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96098. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96099. */
  96100. wipeCaches(bruteForce?: boolean): void;
  96101. /**
  96102. * Set the compressed texture format to use, based on the formats you have, and the formats
  96103. * supported by the hardware / browser.
  96104. *
  96105. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96106. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96107. * to API arguments needed to compressed textures. This puts the burden on the container
  96108. * generator to house the arcane code for determining these for current & future formats.
  96109. *
  96110. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96111. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96112. *
  96113. * Note: The result of this call is not taken into account when a texture is base64.
  96114. *
  96115. * @param formatsAvailable defines the list of those format families you have created
  96116. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96117. *
  96118. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96119. * @returns The extension selected.
  96120. */
  96121. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96122. /** @hidden */
  96123. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96124. min: number;
  96125. mag: number;
  96126. };
  96127. /** @hidden */
  96128. _createTexture(): WebGLTexture;
  96129. /**
  96130. * Usually called from Texture.ts.
  96131. * Passed information to create a WebGLTexture
  96132. * @param urlArg defines a value which contains one of the following:
  96133. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96134. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96135. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96136. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96137. * @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)
  96138. * @param scene needed for loading to the correct scene
  96139. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96140. * @param onLoad optional callback to be called upon successful completion
  96141. * @param onError optional callback to be called upon failure
  96142. * @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
  96143. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96144. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96145. * @param forcedExtension defines the extension to use to pick the right loader
  96146. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96147. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96148. */
  96149. 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;
  96150. /**
  96151. * @hidden
  96152. * Rescales a texture
  96153. * @param source input texutre
  96154. * @param destination destination texture
  96155. * @param scene scene to use to render the resize
  96156. * @param internalFormat format to use when resizing
  96157. * @param onComplete callback to be called when resize has completed
  96158. */
  96159. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96160. private _unpackFlipYCached;
  96161. /**
  96162. * In case you are sharing the context with other applications, it might
  96163. * be interested to not cache the unpack flip y state to ensure a consistent
  96164. * value would be set.
  96165. */
  96166. enableUnpackFlipYCached: boolean;
  96167. /** @hidden */
  96168. _unpackFlipY(value: boolean): void;
  96169. /** @hidden */
  96170. _getUnpackAlignement(): number;
  96171. /**
  96172. * Creates a dynamic texture
  96173. * @param width defines the width of the texture
  96174. * @param height defines the height of the texture
  96175. * @param generateMipMaps defines if the engine should generate the mip levels
  96176. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96177. * @returns the dynamic texture inside an InternalTexture
  96178. */
  96179. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96180. /**
  96181. * Update the sampling mode of a given texture
  96182. * @param samplingMode defines the required sampling mode
  96183. * @param texture defines the texture to update
  96184. */
  96185. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96186. /**
  96187. * Update the content of a dynamic texture
  96188. * @param texture defines the texture to update
  96189. * @param canvas defines the canvas containing the source
  96190. * @param invertY defines if data must be stored with Y axis inverted
  96191. * @param premulAlpha defines if alpha is stored as premultiplied
  96192. * @param format defines the format of the data
  96193. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96194. */
  96195. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96196. /**
  96197. * Update a video texture
  96198. * @param texture defines the texture to update
  96199. * @param video defines the video element to use
  96200. * @param invertY defines if data must be stored with Y axis inverted
  96201. */
  96202. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96203. /**
  96204. * Updates a depth texture Comparison Mode and Function.
  96205. * If the comparison Function is equal to 0, the mode will be set to none.
  96206. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96207. * @param texture The texture to set the comparison function for
  96208. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96209. */
  96210. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96211. /** @hidden */
  96212. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96213. width: number;
  96214. height: number;
  96215. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96216. /**
  96217. * Creates a depth stencil texture.
  96218. * This is only available in WebGL 2 or with the depth texture extension available.
  96219. * @param size The size of face edge in the texture.
  96220. * @param options The options defining the texture.
  96221. * @returns The texture
  96222. */
  96223. createDepthStencilTexture(size: number | {
  96224. width: number;
  96225. height: number;
  96226. }, options: DepthTextureCreationOptions): InternalTexture;
  96227. /**
  96228. * Creates a depth stencil texture.
  96229. * This is only available in WebGL 2 or with the depth texture extension available.
  96230. * @param size The size of face edge in the texture.
  96231. * @param options The options defining the texture.
  96232. * @returns The texture
  96233. */
  96234. private _createDepthStencilTexture;
  96235. /**
  96236. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96237. * @param renderTarget The render target to set the frame buffer for
  96238. */
  96239. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96240. /**
  96241. * Creates a new render target texture
  96242. * @param size defines the size of the texture
  96243. * @param options defines the options used to create the texture
  96244. * @returns a new render target texture stored in an InternalTexture
  96245. */
  96246. createRenderTargetTexture(size: number | {
  96247. width: number;
  96248. height: number;
  96249. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96250. /** @hidden */
  96251. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96252. /**
  96253. * Updates the sample count of a render target texture
  96254. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96255. * @param texture defines the texture to update
  96256. * @param samples defines the sample count to set
  96257. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96258. */
  96259. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96260. /** @hidden */
  96261. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96262. /** @hidden */
  96263. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96264. /** @hidden */
  96265. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96266. /** @hidden */
  96267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96268. /**
  96269. * @hidden
  96270. */
  96271. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96272. private _prepareWebGLTextureContinuation;
  96273. private _prepareWebGLTexture;
  96274. /** @hidden */
  96275. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96276. /** @hidden */
  96277. _releaseFramebufferObjects(texture: InternalTexture): void;
  96278. /** @hidden */
  96279. _releaseTexture(texture: InternalTexture): void;
  96280. private setProgram;
  96281. private _boundUniforms;
  96282. /**
  96283. * Binds an effect to the webGL context
  96284. * @param effect defines the effect to bind
  96285. */
  96286. bindSamplers(effect: Effect): void;
  96287. private _activateCurrentTexture;
  96288. /** @hidden */
  96289. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96290. /** @hidden */
  96291. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96292. /**
  96293. * Sets a texture to the webGL context from a postprocess
  96294. * @param channel defines the channel to use
  96295. * @param postProcess defines the source postprocess
  96296. */
  96297. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96298. /**
  96299. * Binds the output of the passed in post process to the texture channel specified
  96300. * @param channel The channel the texture should be bound to
  96301. * @param postProcess The post process which's output should be bound
  96302. */
  96303. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96304. /**
  96305. * Unbind all textures from the webGL context
  96306. */
  96307. unbindAllTextures(): void;
  96308. /**
  96309. * Sets a texture to the according uniform.
  96310. * @param channel The texture channel
  96311. * @param uniform The uniform to set
  96312. * @param texture The texture to apply
  96313. */
  96314. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96315. /**
  96316. * Sets a depth stencil texture from a render target to the according uniform.
  96317. * @param channel The texture channel
  96318. * @param uniform The uniform to set
  96319. * @param texture The render target texture containing the depth stencil texture to apply
  96320. */
  96321. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96322. private _bindSamplerUniformToChannel;
  96323. private _getTextureWrapMode;
  96324. private _setTexture;
  96325. /**
  96326. * Sets an array of texture to the webGL context
  96327. * @param channel defines the channel where the texture array must be set
  96328. * @param uniform defines the associated uniform location
  96329. * @param textures defines the array of textures to bind
  96330. */
  96331. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96332. /** @hidden */
  96333. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96334. private _setTextureParameterFloat;
  96335. private _setTextureParameterInteger;
  96336. /**
  96337. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96338. * @param x defines the x coordinate of the rectangle where pixels must be read
  96339. * @param y defines the y coordinate of the rectangle where pixels must be read
  96340. * @param width defines the width of the rectangle where pixels must be read
  96341. * @param height defines the height of the rectangle where pixels must be read
  96342. * @returns a Uint8Array containing RGBA colors
  96343. */
  96344. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96345. /**
  96346. * Add an externaly attached data from its key.
  96347. * This method call will fail and return false, if such key already exists.
  96348. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96349. * @param key the unique key that identifies the data
  96350. * @param data the data object to associate to the key for this Engine instance
  96351. * @return true if no such key were already present and the data was added successfully, false otherwise
  96352. */
  96353. addExternalData<T>(key: string, data: T): boolean;
  96354. /**
  96355. * Get an externaly attached data from its key
  96356. * @param key the unique key that identifies the data
  96357. * @return the associated data, if present (can be null), or undefined if not present
  96358. */
  96359. getExternalData<T>(key: string): T;
  96360. /**
  96361. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96362. * @param key the unique key that identifies the data
  96363. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96364. * @return the associated data, can be null if the factory returned null.
  96365. */
  96366. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96367. /**
  96368. * Remove an externaly attached data from the Engine instance
  96369. * @param key the unique key that identifies the data
  96370. * @return true if the data was successfully removed, false if it doesn't exist
  96371. */
  96372. removeExternalData(key: string): boolean;
  96373. /**
  96374. * Unbind all vertex attributes from the webGL context
  96375. */
  96376. unbindAllAttributes(): void;
  96377. /**
  96378. * 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
  96379. */
  96380. releaseEffects(): void;
  96381. /**
  96382. * Dispose and release all associated resources
  96383. */
  96384. dispose(): void;
  96385. /**
  96386. * Display the loading screen
  96387. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96388. */
  96389. displayLoadingUI(): void;
  96390. /**
  96391. * Hide the loading screen
  96392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96393. */
  96394. hideLoadingUI(): void;
  96395. /**
  96396. * Gets the current loading screen object
  96397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96398. */
  96399. /**
  96400. * Sets the current loading screen object
  96401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96402. */
  96403. loadingScreen: ILoadingScreen;
  96404. /**
  96405. * Sets the current loading screen text
  96406. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96407. */
  96408. loadingUIText: string;
  96409. /**
  96410. * Sets the current loading screen background color
  96411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96412. */
  96413. loadingUIBackgroundColor: string;
  96414. /**
  96415. * Attach a new callback raised when context lost event is fired
  96416. * @param callback defines the callback to call
  96417. */
  96418. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96419. /**
  96420. * Attach a new callback raised when context restored event is fired
  96421. * @param callback defines the callback to call
  96422. */
  96423. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96424. /**
  96425. * Gets the source code of the vertex shader associated with a specific webGL program
  96426. * @param program defines the program to use
  96427. * @returns a string containing the source code of the vertex shader associated with the program
  96428. */
  96429. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96430. /**
  96431. * Gets the source code of the fragment shader associated with a specific webGL program
  96432. * @param program defines the program to use
  96433. * @returns a string containing the source code of the fragment shader associated with the program
  96434. */
  96435. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96436. /**
  96437. * Get the current error code of the webGL context
  96438. * @returns the error code
  96439. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96440. */
  96441. getError(): number;
  96442. /**
  96443. * Gets the current framerate
  96444. * @returns a number representing the framerate
  96445. */
  96446. getFps(): number;
  96447. /**
  96448. * Gets the time spent between current and previous frame
  96449. * @returns a number representing the delta time in ms
  96450. */
  96451. getDeltaTime(): number;
  96452. private _measureFps;
  96453. /** @hidden */
  96454. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96455. private _canRenderToFloatFramebuffer;
  96456. private _canRenderToHalfFloatFramebuffer;
  96457. private _canRenderToFramebuffer;
  96458. /** @hidden */
  96459. _getWebGLTextureType(type: number): number;
  96460. /** @hidden */
  96461. _getInternalFormat(format: number): number;
  96462. /** @hidden */
  96463. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96464. /** @hidden */
  96465. _getRGBAMultiSampleBufferFormat(type: number): number;
  96466. /** @hidden */
  96467. _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;
  96468. /** @hidden */
  96469. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96470. /**
  96471. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96472. * @returns true if the engine can be created
  96473. * @ignorenaming
  96474. */
  96475. static isSupported(): boolean;
  96476. /**
  96477. * Find the next highest power of two.
  96478. * @param x Number to start search from.
  96479. * @return Next highest power of two.
  96480. */
  96481. static CeilingPOT(x: number): number;
  96482. /**
  96483. * Find the next lowest power of two.
  96484. * @param x Number to start search from.
  96485. * @return Next lowest power of two.
  96486. */
  96487. static FloorPOT(x: number): number;
  96488. /**
  96489. * Find the nearest power of two.
  96490. * @param x Number to start search from.
  96491. * @return Next nearest power of two.
  96492. */
  96493. static NearestPOT(x: number): number;
  96494. /**
  96495. * Get the closest exponent of two
  96496. * @param value defines the value to approximate
  96497. * @param max defines the maximum value to return
  96498. * @param mode defines how to define the closest value
  96499. * @returns closest exponent of two of the given value
  96500. */
  96501. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96502. /**
  96503. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96504. * @param func - the function to be called
  96505. * @param requester - the object that will request the next frame. Falls back to window.
  96506. * @returns frame number
  96507. */
  96508. static QueueNewFrame(func: () => void, requester?: any): number;
  96509. /**
  96510. * Ask the browser to promote the current element to pointerlock mode
  96511. * @param element defines the DOM element to promote
  96512. */
  96513. static _RequestPointerlock(element: HTMLElement): void;
  96514. /**
  96515. * Asks the browser to exit pointerlock mode
  96516. */
  96517. static _ExitPointerlock(): void;
  96518. /**
  96519. * Ask the browser to promote the current element to fullscreen rendering mode
  96520. * @param element defines the DOM element to promote
  96521. */
  96522. static _RequestFullscreen(element: HTMLElement): void;
  96523. /**
  96524. * Asks the browser to exit fullscreen mode
  96525. */
  96526. static _ExitFullscreen(): void;
  96527. }
  96528. }
  96529. declare module BABYLON {
  96530. /**
  96531. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96532. * during the life time of the application.
  96533. */
  96534. export class EngineStore {
  96535. /** Gets the list of created engines */
  96536. static Instances: Engine[];
  96537. /** @hidden */
  96538. static _LastCreatedScene: Nullable<Scene>;
  96539. /**
  96540. * Gets the latest created engine
  96541. */
  96542. static readonly LastCreatedEngine: Nullable<Engine>;
  96543. /**
  96544. * Gets the latest created scene
  96545. */
  96546. static readonly LastCreatedScene: Nullable<Scene>;
  96547. /**
  96548. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96549. * @ignorenaming
  96550. */
  96551. static UseFallbackTexture: boolean;
  96552. /**
  96553. * Texture content used if a texture cannot loaded
  96554. * @ignorenaming
  96555. */
  96556. static FallbackTexture: string;
  96557. }
  96558. }
  96559. declare module BABYLON {
  96560. /**
  96561. * Helper class that provides a small promise polyfill
  96562. */
  96563. export class PromisePolyfill {
  96564. /**
  96565. * Static function used to check if the polyfill is required
  96566. * If this is the case then the function will inject the polyfill to window.Promise
  96567. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96568. */
  96569. static Apply(force?: boolean): void;
  96570. }
  96571. }
  96572. declare module BABYLON {
  96573. /**
  96574. * Interface for screenshot methods with describe argument called `size` as object with options
  96575. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96576. */
  96577. export interface IScreenshotSize {
  96578. /**
  96579. * number in pixels for canvas height
  96580. */
  96581. height?: number;
  96582. /**
  96583. * multiplier allowing render at a higher or lower resolution
  96584. * If value is defined then height and width will be ignored and taken from camera
  96585. */
  96586. precision?: number;
  96587. /**
  96588. * number in pixels for canvas width
  96589. */
  96590. width?: number;
  96591. }
  96592. }
  96593. declare module BABYLON {
  96594. interface IColor4Like {
  96595. r: float;
  96596. g: float;
  96597. b: float;
  96598. a: float;
  96599. }
  96600. /**
  96601. * Class containing a set of static utilities functions
  96602. */
  96603. export class Tools {
  96604. /**
  96605. * Gets or sets the base URL to use to load assets
  96606. */
  96607. static BaseUrl: string;
  96608. /**
  96609. * Enable/Disable Custom HTTP Request Headers globally.
  96610. * default = false
  96611. * @see CustomRequestHeaders
  96612. */
  96613. static UseCustomRequestHeaders: boolean;
  96614. /**
  96615. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96616. * i.e. when loading files, where the server/service expects an Authorization header
  96617. */
  96618. static CustomRequestHeaders: {
  96619. [key: string]: string;
  96620. };
  96621. /**
  96622. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96623. */
  96624. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96625. /**
  96626. * Default behaviour for cors in the application.
  96627. * It can be a string if the expected behavior is identical in the entire app.
  96628. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96629. */
  96630. static CorsBehavior: string | ((url: string | string[]) => string);
  96631. /**
  96632. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96633. * @ignorenaming
  96634. */
  96635. static UseFallbackTexture: boolean;
  96636. /**
  96637. * Use this object to register external classes like custom textures or material
  96638. * to allow the laoders to instantiate them
  96639. */
  96640. static RegisteredExternalClasses: {
  96641. [key: string]: Object;
  96642. };
  96643. /**
  96644. * Texture content used if a texture cannot loaded
  96645. * @ignorenaming
  96646. */
  96647. static fallbackTexture: string;
  96648. /**
  96649. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96650. * @param u defines the coordinate on X axis
  96651. * @param v defines the coordinate on Y axis
  96652. * @param width defines the width of the source data
  96653. * @param height defines the height of the source data
  96654. * @param pixels defines the source byte array
  96655. * @param color defines the output color
  96656. */
  96657. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96658. /**
  96659. * Interpolates between a and b via alpha
  96660. * @param a The lower value (returned when alpha = 0)
  96661. * @param b The upper value (returned when alpha = 1)
  96662. * @param alpha The interpolation-factor
  96663. * @return The mixed value
  96664. */
  96665. static Mix(a: number, b: number, alpha: number): number;
  96666. /**
  96667. * Tries to instantiate a new object from a given class name
  96668. * @param className defines the class name to instantiate
  96669. * @returns the new object or null if the system was not able to do the instantiation
  96670. */
  96671. static Instantiate(className: string): any;
  96672. /**
  96673. * Provides a slice function that will work even on IE
  96674. * @param data defines the array to slice
  96675. * @param start defines the start of the data (optional)
  96676. * @param end defines the end of the data (optional)
  96677. * @returns the new sliced array
  96678. */
  96679. static Slice<T>(data: T, start?: number, end?: number): T;
  96680. /**
  96681. * Polyfill for setImmediate
  96682. * @param action defines the action to execute after the current execution block
  96683. */
  96684. static SetImmediate(action: () => void): void;
  96685. /**
  96686. * Function indicating if a number is an exponent of 2
  96687. * @param value defines the value to test
  96688. * @returns true if the value is an exponent of 2
  96689. */
  96690. static IsExponentOfTwo(value: number): boolean;
  96691. private static _tmpFloatArray;
  96692. /**
  96693. * Returns the nearest 32-bit single precision float representation of a Number
  96694. * @param value A Number. If the parameter is of a different type, it will get converted
  96695. * to a number or to NaN if it cannot be converted
  96696. * @returns number
  96697. */
  96698. static FloatRound(value: number): number;
  96699. /**
  96700. * Extracts the filename from a path
  96701. * @param path defines the path to use
  96702. * @returns the filename
  96703. */
  96704. static GetFilename(path: string): string;
  96705. /**
  96706. * Extracts the "folder" part of a path (everything before the filename).
  96707. * @param uri The URI to extract the info from
  96708. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96709. * @returns The "folder" part of the path
  96710. */
  96711. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96712. /**
  96713. * Extracts text content from a DOM element hierarchy
  96714. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96715. */
  96716. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96717. /**
  96718. * Convert an angle in radians to degrees
  96719. * @param angle defines the angle to convert
  96720. * @returns the angle in degrees
  96721. */
  96722. static ToDegrees(angle: number): number;
  96723. /**
  96724. * Convert an angle in degrees to radians
  96725. * @param angle defines the angle to convert
  96726. * @returns the angle in radians
  96727. */
  96728. static ToRadians(angle: number): number;
  96729. /**
  96730. * Encode a buffer to a base64 string
  96731. * @param buffer defines the buffer to encode
  96732. * @returns the encoded string
  96733. */
  96734. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96735. /**
  96736. * Returns an array if obj is not an array
  96737. * @param obj defines the object to evaluate as an array
  96738. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96739. * @returns either obj directly if obj is an array or a new array containing obj
  96740. */
  96741. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96742. /**
  96743. * Gets the pointer prefix to use
  96744. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96745. */
  96746. static GetPointerPrefix(): string;
  96747. /**
  96748. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96749. * @param url define the url we are trying
  96750. * @param element define the dom element where to configure the cors policy
  96751. */
  96752. static SetCorsBehavior(url: string | string[], element: {
  96753. crossOrigin: string | null;
  96754. }): void;
  96755. /**
  96756. * Removes unwanted characters from an url
  96757. * @param url defines the url to clean
  96758. * @returns the cleaned url
  96759. */
  96760. static CleanUrl(url: string): string;
  96761. /**
  96762. * Gets or sets a function used to pre-process url before using them to load assets
  96763. */
  96764. static PreprocessUrl: (url: string) => string;
  96765. /**
  96766. * Loads an image as an HTMLImageElement.
  96767. * @param input url string, ArrayBuffer, or Blob to load
  96768. * @param onLoad callback called when the image successfully loads
  96769. * @param onError callback called when the image fails to load
  96770. * @param offlineProvider offline provider for caching
  96771. * @returns the HTMLImageElement of the loaded image
  96772. */
  96773. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96774. /**
  96775. * Loads a file
  96776. * @param url url string, ArrayBuffer, or Blob to load
  96777. * @param onSuccess callback called when the file successfully loads
  96778. * @param onProgress callback called while file is loading (if the server supports this mode)
  96779. * @param offlineProvider defines the offline provider for caching
  96780. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96781. * @param onError callback called when the file fails to load
  96782. * @returns a file request object
  96783. */
  96784. 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;
  96785. /**
  96786. * Loads a file from a url
  96787. * @param url the file url to load
  96788. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96789. */
  96790. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96791. /**
  96792. * Load a script (identified by an url). When the url returns, the
  96793. * content of this file is added into a new script element, attached to the DOM (body element)
  96794. * @param scriptUrl defines the url of the script to laod
  96795. * @param onSuccess defines the callback called when the script is loaded
  96796. * @param onError defines the callback to call if an error occurs
  96797. * @param scriptId defines the id of the script element
  96798. */
  96799. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96800. /**
  96801. * Load an asynchronous script (identified by an url). When the url returns, the
  96802. * content of this file is added into a new script element, attached to the DOM (body element)
  96803. * @param scriptUrl defines the url of the script to laod
  96804. * @param scriptId defines the id of the script element
  96805. * @returns a promise request object
  96806. */
  96807. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96808. /**
  96809. * Loads a file from a blob
  96810. * @param fileToLoad defines the blob to use
  96811. * @param callback defines the callback to call when data is loaded
  96812. * @param progressCallback defines the callback to call during loading process
  96813. * @returns a file request object
  96814. */
  96815. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96816. /**
  96817. * Loads a file
  96818. * @param fileToLoad defines the file to load
  96819. * @param callback defines the callback to call when data is loaded
  96820. * @param progressCallBack defines the callback to call during loading process
  96821. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96822. * @returns a file request object
  96823. */
  96824. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96825. /**
  96826. * Creates a data url from a given string content
  96827. * @param content defines the content to convert
  96828. * @returns the new data url link
  96829. */
  96830. static FileAsURL(content: string): string;
  96831. /**
  96832. * Format the given number to a specific decimal format
  96833. * @param value defines the number to format
  96834. * @param decimals defines the number of decimals to use
  96835. * @returns the formatted string
  96836. */
  96837. static Format(value: number, decimals?: number): string;
  96838. /**
  96839. * Tries to copy an object by duplicating every property
  96840. * @param source defines the source object
  96841. * @param destination defines the target object
  96842. * @param doNotCopyList defines a list of properties to avoid
  96843. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96844. */
  96845. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96846. /**
  96847. * Gets a boolean indicating if the given object has no own property
  96848. * @param obj defines the object to test
  96849. * @returns true if object has no own property
  96850. */
  96851. static IsEmpty(obj: any): boolean;
  96852. /**
  96853. * Function used to register events at window level
  96854. * @param windowElement defines the Window object to use
  96855. * @param events defines the events to register
  96856. */
  96857. static RegisterTopRootEvents(windowElement: Window, events: {
  96858. name: string;
  96859. handler: Nullable<(e: FocusEvent) => any>;
  96860. }[]): void;
  96861. /**
  96862. * Function used to unregister events from window level
  96863. * @param windowElement defines the Window object to use
  96864. * @param events defines the events to unregister
  96865. */
  96866. static UnregisterTopRootEvents(windowElement: Window, events: {
  96867. name: string;
  96868. handler: Nullable<(e: FocusEvent) => any>;
  96869. }[]): void;
  96870. /**
  96871. * @ignore
  96872. */
  96873. static _ScreenshotCanvas: HTMLCanvasElement;
  96874. /**
  96875. * Dumps the current bound framebuffer
  96876. * @param width defines the rendering width
  96877. * @param height defines the rendering height
  96878. * @param engine defines the hosting engine
  96879. * @param successCallback defines the callback triggered once the data are available
  96880. * @param mimeType defines the mime type of the result
  96881. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96882. */
  96883. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96884. /**
  96885. * Converts the canvas data to blob.
  96886. * This acts as a polyfill for browsers not supporting the to blob function.
  96887. * @param canvas Defines the canvas to extract the data from
  96888. * @param successCallback Defines the callback triggered once the data are available
  96889. * @param mimeType Defines the mime type of the result
  96890. */
  96891. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96892. /**
  96893. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96894. * @param successCallback defines the callback triggered once the data are available
  96895. * @param mimeType defines the mime type of the result
  96896. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96897. */
  96898. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96899. /**
  96900. * Downloads a blob in the browser
  96901. * @param blob defines the blob to download
  96902. * @param fileName defines the name of the downloaded file
  96903. */
  96904. static Download(blob: Blob, fileName: string): void;
  96905. /**
  96906. * Captures a screenshot of the current rendering
  96907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96908. * @param engine defines the rendering engine
  96909. * @param camera defines the source camera
  96910. * @param size This parameter can be set to a single number or to an object with the
  96911. * following (optional) properties: precision, width, height. If a single number is passed,
  96912. * it will be used for both width and height. If an object is passed, the screenshot size
  96913. * will be derived from the parameters. The precision property is a multiplier allowing
  96914. * rendering at a higher or lower resolution
  96915. * @param successCallback defines the callback receives a single parameter which contains the
  96916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96917. * src parameter of an <img> to display it
  96918. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96919. * Check your browser for supported MIME types
  96920. */
  96921. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96922. /**
  96923. * Captures a screenshot of the current rendering
  96924. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96925. * @param engine defines the rendering engine
  96926. * @param camera defines the source camera
  96927. * @param size This parameter can be set to a single number or to an object with the
  96928. * following (optional) properties: precision, width, height. If a single number is passed,
  96929. * it will be used for both width and height. If an object is passed, the screenshot size
  96930. * will be derived from the parameters. The precision property is a multiplier allowing
  96931. * rendering at a higher or lower resolution
  96932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96933. * Check your browser for supported MIME types
  96934. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96935. * to the src parameter of an <img> to display it
  96936. */
  96937. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96938. /**
  96939. * Generates an image screenshot from the specified camera.
  96940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96941. * @param engine The engine to use for rendering
  96942. * @param camera The camera to use for rendering
  96943. * @param size This parameter can be set to a single number or to an object with the
  96944. * following (optional) properties: precision, width, height. If a single number is passed,
  96945. * it will be used for both width and height. If an object is passed, the screenshot size
  96946. * will be derived from the parameters. The precision property is a multiplier allowing
  96947. * rendering at a higher or lower resolution
  96948. * @param successCallback The callback receives a single parameter which contains the
  96949. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96950. * src parameter of an <img> to display it
  96951. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96952. * Check your browser for supported MIME types
  96953. * @param samples Texture samples (default: 1)
  96954. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96955. * @param fileName A name for for the downloaded file.
  96956. */
  96957. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96958. /**
  96959. * Generates an image screenshot from the specified camera.
  96960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96961. * @param engine The engine to use for rendering
  96962. * @param camera The camera to use for rendering
  96963. * @param size This parameter can be set to a single number or to an object with the
  96964. * following (optional) properties: precision, width, height. If a single number is passed,
  96965. * it will be used for both width and height. If an object is passed, the screenshot size
  96966. * will be derived from the parameters. The precision property is a multiplier allowing
  96967. * rendering at a higher or lower resolution
  96968. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96969. * Check your browser for supported MIME types
  96970. * @param samples Texture samples (default: 1)
  96971. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96972. * @param fileName A name for for the downloaded file.
  96973. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96974. * to the src parameter of an <img> to display it
  96975. */
  96976. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96977. /**
  96978. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96979. * Be aware Math.random() could cause collisions, but:
  96980. * "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"
  96981. * @returns a pseudo random id
  96982. */
  96983. static RandomId(): string;
  96984. /**
  96985. * Test if the given uri is a base64 string
  96986. * @param uri The uri to test
  96987. * @return True if the uri is a base64 string or false otherwise
  96988. */
  96989. static IsBase64(uri: string): boolean;
  96990. /**
  96991. * Decode the given base64 uri.
  96992. * @param uri The uri to decode
  96993. * @return The decoded base64 data.
  96994. */
  96995. static DecodeBase64(uri: string): ArrayBuffer;
  96996. /**
  96997. * Gets the absolute url.
  96998. * @param url the input url
  96999. * @return the absolute url
  97000. */
  97001. static GetAbsoluteUrl(url: string): string;
  97002. /**
  97003. * No log
  97004. */
  97005. static readonly NoneLogLevel: number;
  97006. /**
  97007. * Only message logs
  97008. */
  97009. static readonly MessageLogLevel: number;
  97010. /**
  97011. * Only warning logs
  97012. */
  97013. static readonly WarningLogLevel: number;
  97014. /**
  97015. * Only error logs
  97016. */
  97017. static readonly ErrorLogLevel: number;
  97018. /**
  97019. * All logs
  97020. */
  97021. static readonly AllLogLevel: number;
  97022. /**
  97023. * Gets a value indicating the number of loading errors
  97024. * @ignorenaming
  97025. */
  97026. static readonly errorsCount: number;
  97027. /**
  97028. * Callback called when a new log is added
  97029. */
  97030. static OnNewCacheEntry: (entry: string) => void;
  97031. /**
  97032. * Log a message to the console
  97033. * @param message defines the message to log
  97034. */
  97035. static Log(message: string): void;
  97036. /**
  97037. * Write a warning message to the console
  97038. * @param message defines the message to log
  97039. */
  97040. static Warn(message: string): void;
  97041. /**
  97042. * Write an error message to the console
  97043. * @param message defines the message to log
  97044. */
  97045. static Error(message: string): void;
  97046. /**
  97047. * Gets current log cache (list of logs)
  97048. */
  97049. static readonly LogCache: string;
  97050. /**
  97051. * Clears the log cache
  97052. */
  97053. static ClearLogCache(): void;
  97054. /**
  97055. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97056. */
  97057. static LogLevels: number;
  97058. /**
  97059. * Checks if the window object exists
  97060. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97061. */
  97062. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97063. /**
  97064. * No performance log
  97065. */
  97066. static readonly PerformanceNoneLogLevel: number;
  97067. /**
  97068. * Use user marks to log performance
  97069. */
  97070. static readonly PerformanceUserMarkLogLevel: number;
  97071. /**
  97072. * Log performance to the console
  97073. */
  97074. static readonly PerformanceConsoleLogLevel: number;
  97075. private static _performance;
  97076. /**
  97077. * Sets the current performance log level
  97078. */
  97079. static PerformanceLogLevel: number;
  97080. private static _StartPerformanceCounterDisabled;
  97081. private static _EndPerformanceCounterDisabled;
  97082. private static _StartUserMark;
  97083. private static _EndUserMark;
  97084. private static _StartPerformanceConsole;
  97085. private static _EndPerformanceConsole;
  97086. /**
  97087. * Starts a performance counter
  97088. */
  97089. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97090. /**
  97091. * Ends a specific performance coutner
  97092. */
  97093. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97094. /**
  97095. * Gets either window.performance.now() if supported or Date.now() else
  97096. */
  97097. static readonly Now: number;
  97098. /**
  97099. * This method will return the name of the class used to create the instance of the given object.
  97100. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97101. * @param object the object to get the class name from
  97102. * @param isType defines if the object is actually a type
  97103. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97104. */
  97105. static GetClassName(object: any, isType?: boolean): string;
  97106. /**
  97107. * Gets the first element of an array satisfying a given predicate
  97108. * @param array defines the array to browse
  97109. * @param predicate defines the predicate to use
  97110. * @returns null if not found or the element
  97111. */
  97112. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97113. /**
  97114. * This method will return the name of the full name of the class, including its owning module (if any).
  97115. * 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).
  97116. * @param object the object to get the class name from
  97117. * @param isType defines if the object is actually a type
  97118. * @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.
  97119. * @ignorenaming
  97120. */
  97121. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97122. /**
  97123. * Returns a promise that resolves after the given amount of time.
  97124. * @param delay Number of milliseconds to delay
  97125. * @returns Promise that resolves after the given amount of time
  97126. */
  97127. static DelayAsync(delay: number): Promise<void>;
  97128. }
  97129. /**
  97130. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97131. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97132. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97133. * @param name The name of the class, case should be preserved
  97134. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97135. */
  97136. export function className(name: string, module?: string): (target: Object) => void;
  97137. /**
  97138. * An implementation of a loop for asynchronous functions.
  97139. */
  97140. export class AsyncLoop {
  97141. /**
  97142. * Defines the number of iterations for the loop
  97143. */
  97144. iterations: number;
  97145. /**
  97146. * Defines the current index of the loop.
  97147. */
  97148. index: number;
  97149. private _done;
  97150. private _fn;
  97151. private _successCallback;
  97152. /**
  97153. * Constructor.
  97154. * @param iterations the number of iterations.
  97155. * @param func the function to run each iteration
  97156. * @param successCallback the callback that will be called upon succesful execution
  97157. * @param offset starting offset.
  97158. */
  97159. constructor(
  97160. /**
  97161. * Defines the number of iterations for the loop
  97162. */
  97163. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97164. /**
  97165. * Execute the next iteration. Must be called after the last iteration was finished.
  97166. */
  97167. executeNext(): void;
  97168. /**
  97169. * Break the loop and run the success callback.
  97170. */
  97171. breakLoop(): void;
  97172. /**
  97173. * Create and run an async loop.
  97174. * @param iterations the number of iterations.
  97175. * @param fn the function to run each iteration
  97176. * @param successCallback the callback that will be called upon succesful execution
  97177. * @param offset starting offset.
  97178. * @returns the created async loop object
  97179. */
  97180. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97181. /**
  97182. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97183. * @param iterations total number of iterations
  97184. * @param syncedIterations number of synchronous iterations in each async iteration.
  97185. * @param fn the function to call each iteration.
  97186. * @param callback a success call back that will be called when iterating stops.
  97187. * @param breakFunction a break condition (optional)
  97188. * @param timeout timeout settings for the setTimeout function. default - 0.
  97189. * @returns the created async loop object
  97190. */
  97191. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97192. }
  97193. }
  97194. declare module BABYLON {
  97195. /** @hidden */
  97196. export interface ICollisionCoordinator {
  97197. createCollider(): Collider;
  97198. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97199. init(scene: Scene): void;
  97200. }
  97201. /** @hidden */
  97202. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97203. private _scene;
  97204. private _scaledPosition;
  97205. private _scaledVelocity;
  97206. private _finalPosition;
  97207. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97208. createCollider(): Collider;
  97209. init(scene: Scene): void;
  97210. private _collideWithWorld;
  97211. }
  97212. }
  97213. declare module BABYLON {
  97214. /**
  97215. * Class used to manage all inputs for the scene.
  97216. */
  97217. export class InputManager {
  97218. /** The distance in pixel that you have to move to prevent some events */
  97219. static DragMovementThreshold: number;
  97220. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97221. static LongPressDelay: number;
  97222. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97223. static DoubleClickDelay: number;
  97224. /** If you need to check double click without raising a single click at first click, enable this flag */
  97225. static ExclusiveDoubleClickMode: boolean;
  97226. private _wheelEventName;
  97227. private _onPointerMove;
  97228. private _onPointerDown;
  97229. private _onPointerUp;
  97230. private _initClickEvent;
  97231. private _initActionManager;
  97232. private _delayedSimpleClick;
  97233. private _delayedSimpleClickTimeout;
  97234. private _previousDelayedSimpleClickTimeout;
  97235. private _meshPickProceed;
  97236. private _previousButtonPressed;
  97237. private _currentPickResult;
  97238. private _previousPickResult;
  97239. private _totalPointersPressed;
  97240. private _doubleClickOccured;
  97241. private _pointerOverMesh;
  97242. private _pickedDownMesh;
  97243. private _pickedUpMesh;
  97244. private _pointerX;
  97245. private _pointerY;
  97246. private _unTranslatedPointerX;
  97247. private _unTranslatedPointerY;
  97248. private _startingPointerPosition;
  97249. private _previousStartingPointerPosition;
  97250. private _startingPointerTime;
  97251. private _previousStartingPointerTime;
  97252. private _pointerCaptures;
  97253. private _onKeyDown;
  97254. private _onKeyUp;
  97255. private _onCanvasFocusObserver;
  97256. private _onCanvasBlurObserver;
  97257. private _scene;
  97258. /**
  97259. * Creates a new InputManager
  97260. * @param scene defines the hosting scene
  97261. */
  97262. constructor(scene: Scene);
  97263. /**
  97264. * Gets the mesh that is currently under the pointer
  97265. */
  97266. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97267. /**
  97268. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97269. */
  97270. readonly unTranslatedPointer: Vector2;
  97271. /**
  97272. * Gets or sets the current on-screen X position of the pointer
  97273. */
  97274. pointerX: number;
  97275. /**
  97276. * Gets or sets the current on-screen Y position of the pointer
  97277. */
  97278. pointerY: number;
  97279. private _updatePointerPosition;
  97280. private _processPointerMove;
  97281. private _setRayOnPointerInfo;
  97282. private _checkPrePointerObservable;
  97283. /**
  97284. * Use this method to simulate a pointer move on a mesh
  97285. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97286. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97287. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97288. */
  97289. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97290. /**
  97291. * Use this method to simulate a pointer down on a mesh
  97292. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97293. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97294. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97295. */
  97296. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97297. private _processPointerDown;
  97298. /** @hidden */
  97299. _isPointerSwiping(): boolean;
  97300. /**
  97301. * Use this method to simulate a pointer up on a mesh
  97302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97305. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97306. */
  97307. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97308. private _processPointerUp;
  97309. /**
  97310. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97311. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97312. * @returns true if the pointer was captured
  97313. */
  97314. isPointerCaptured(pointerId?: number): boolean;
  97315. /**
  97316. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97317. * @param attachUp defines if you want to attach events to pointerup
  97318. * @param attachDown defines if you want to attach events to pointerdown
  97319. * @param attachMove defines if you want to attach events to pointermove
  97320. */
  97321. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97322. /**
  97323. * Detaches all event handlers
  97324. */
  97325. detachControl(): void;
  97326. /**
  97327. * Force the value of meshUnderPointer
  97328. * @param mesh defines the mesh to use
  97329. */
  97330. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97331. /**
  97332. * Gets the mesh under the pointer
  97333. * @returns a Mesh or null if no mesh is under the pointer
  97334. */
  97335. getPointerOverMesh(): Nullable<AbstractMesh>;
  97336. }
  97337. }
  97338. declare module BABYLON {
  97339. /**
  97340. * Helper class used to generate session unique ID
  97341. */
  97342. export class UniqueIdGenerator {
  97343. private static _UniqueIdCounter;
  97344. /**
  97345. * Gets an unique (relatively to the current scene) Id
  97346. */
  97347. static readonly UniqueId: number;
  97348. }
  97349. }
  97350. declare module BABYLON {
  97351. /**
  97352. * This class defines the direct association between an animation and a target
  97353. */
  97354. export class TargetedAnimation {
  97355. /**
  97356. * Animation to perform
  97357. */
  97358. animation: Animation;
  97359. /**
  97360. * Target to animate
  97361. */
  97362. target: any;
  97363. /**
  97364. * Serialize the object
  97365. * @returns the JSON object representing the current entity
  97366. */
  97367. serialize(): any;
  97368. }
  97369. /**
  97370. * Use this class to create coordinated animations on multiple targets
  97371. */
  97372. export class AnimationGroup implements IDisposable {
  97373. /** The name of the animation group */
  97374. name: string;
  97375. private _scene;
  97376. private _targetedAnimations;
  97377. private _animatables;
  97378. private _from;
  97379. private _to;
  97380. private _isStarted;
  97381. private _isPaused;
  97382. private _speedRatio;
  97383. private _loopAnimation;
  97384. /**
  97385. * Gets or sets the unique id of the node
  97386. */
  97387. uniqueId: number;
  97388. /**
  97389. * This observable will notify when one animation have ended
  97390. */
  97391. onAnimationEndObservable: Observable<TargetedAnimation>;
  97392. /**
  97393. * Observer raised when one animation loops
  97394. */
  97395. onAnimationLoopObservable: Observable<TargetedAnimation>;
  97396. /**
  97397. * This observable will notify when all animations have ended.
  97398. */
  97399. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  97400. /**
  97401. * This observable will notify when all animations have paused.
  97402. */
  97403. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  97404. /**
  97405. * This observable will notify when all animations are playing.
  97406. */
  97407. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  97408. /**
  97409. * Gets the first frame
  97410. */
  97411. readonly from: number;
  97412. /**
  97413. * Gets the last frame
  97414. */
  97415. readonly to: number;
  97416. /**
  97417. * Define if the animations are started
  97418. */
  97419. readonly isStarted: boolean;
  97420. /**
  97421. * Gets a value indicating that the current group is playing
  97422. */
  97423. readonly isPlaying: boolean;
  97424. /**
  97425. * Gets or sets the speed ratio to use for all animations
  97426. */
  97427. /**
  97428. * Gets or sets the speed ratio to use for all animations
  97429. */
  97430. speedRatio: number;
  97431. /**
  97432. * Gets or sets if all animations should loop or not
  97433. */
  97434. loopAnimation: boolean;
  97435. /**
  97436. * Gets the targeted animations for this animation group
  97437. */
  97438. readonly targetedAnimations: Array<TargetedAnimation>;
  97439. /**
  97440. * returning the list of animatables controlled by this animation group.
  97441. */
  97442. readonly animatables: Array<Animatable>;
  97443. /**
  97444. * Instantiates a new Animation Group.
  97445. * This helps managing several animations at once.
  97446. * @see http://doc.babylonjs.com/how_to/group
  97447. * @param name Defines the name of the group
  97448. * @param scene Defines the scene the group belongs to
  97449. */
  97450. constructor(
  97451. /** The name of the animation group */
  97452. name: string, scene?: Nullable<Scene>);
  97453. /**
  97454. * Add an animation (with its target) in the group
  97455. * @param animation defines the animation we want to add
  97456. * @param target defines the target of the animation
  97457. * @returns the TargetedAnimation object
  97458. */
  97459. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97460. /**
  97461. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97462. * It can add constant keys at begin or end
  97463. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97464. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97465. * @returns the animation group
  97466. */
  97467. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97468. /**
  97469. * Start all animations on given targets
  97470. * @param loop defines if animations must loop
  97471. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97472. * @param from defines the from key (optional)
  97473. * @param to defines the to key (optional)
  97474. * @returns the current animation group
  97475. */
  97476. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97477. /**
  97478. * Pause all animations
  97479. * @returns the animation group
  97480. */
  97481. pause(): AnimationGroup;
  97482. /**
  97483. * Play all animations to initial state
  97484. * This function will start() the animations if they were not started or will restart() them if they were paused
  97485. * @param loop defines if animations must loop
  97486. * @returns the animation group
  97487. */
  97488. play(loop?: boolean): AnimationGroup;
  97489. /**
  97490. * Reset all animations to initial state
  97491. * @returns the animation group
  97492. */
  97493. reset(): AnimationGroup;
  97494. /**
  97495. * Restart animations from key 0
  97496. * @returns the animation group
  97497. */
  97498. restart(): AnimationGroup;
  97499. /**
  97500. * Stop all animations
  97501. * @returns the animation group
  97502. */
  97503. stop(): AnimationGroup;
  97504. /**
  97505. * Set animation weight for all animatables
  97506. * @param weight defines the weight to use
  97507. * @return the animationGroup
  97508. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97509. */
  97510. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97511. /**
  97512. * Synchronize and normalize all animatables with a source animatable
  97513. * @param root defines the root animatable to synchronize with
  97514. * @return the animationGroup
  97515. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97516. */
  97517. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97518. /**
  97519. * Goes to a specific frame in this animation group
  97520. * @param frame the frame number to go to
  97521. * @return the animationGroup
  97522. */
  97523. goToFrame(frame: number): AnimationGroup;
  97524. /**
  97525. * Dispose all associated resources
  97526. */
  97527. dispose(): void;
  97528. private _checkAnimationGroupEnded;
  97529. /**
  97530. * Clone the current animation group and returns a copy
  97531. * @param newName defines the name of the new group
  97532. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97533. * @returns the new aniamtion group
  97534. */
  97535. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97536. /**
  97537. * Serializes the animationGroup to an object
  97538. * @returns Serialized object
  97539. */
  97540. serialize(): any;
  97541. /**
  97542. * Returns a new AnimationGroup object parsed from the source provided.
  97543. * @param parsedAnimationGroup defines the source
  97544. * @param scene defines the scene that will receive the animationGroup
  97545. * @returns a new AnimationGroup
  97546. */
  97547. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97548. /**
  97549. * Returns the string "AnimationGroup"
  97550. * @returns "AnimationGroup"
  97551. */
  97552. getClassName(): string;
  97553. /**
  97554. * Creates a detailled string about the object
  97555. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97556. * @returns a string representing the object
  97557. */
  97558. toString(fullDetails?: boolean): string;
  97559. }
  97560. }
  97561. declare module BABYLON {
  97562. /**
  97563. * Define an interface for all classes that will hold resources
  97564. */
  97565. export interface IDisposable {
  97566. /**
  97567. * Releases all held resources
  97568. */
  97569. dispose(): void;
  97570. }
  97571. /** Interface defining initialization parameters for Scene class */
  97572. export interface SceneOptions {
  97573. /**
  97574. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97575. * It will improve performance when the number of geometries becomes important.
  97576. */
  97577. useGeometryUniqueIdsMap?: boolean;
  97578. /**
  97579. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97580. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97581. */
  97582. useMaterialMeshMap?: boolean;
  97583. /**
  97584. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97585. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97586. */
  97587. useClonedMeshhMap?: boolean;
  97588. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97589. virtual?: boolean;
  97590. }
  97591. /**
  97592. * Represents a scene to be rendered by the engine.
  97593. * @see http://doc.babylonjs.com/features/scene
  97594. */
  97595. export class Scene extends AbstractScene implements IAnimatable {
  97596. /** The fog is deactivated */
  97597. static readonly FOGMODE_NONE: number;
  97598. /** The fog density is following an exponential function */
  97599. static readonly FOGMODE_EXP: number;
  97600. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97601. static readonly FOGMODE_EXP2: number;
  97602. /** The fog density is following a linear function. */
  97603. static readonly FOGMODE_LINEAR: number;
  97604. /**
  97605. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97606. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97607. */
  97608. static MinDeltaTime: number;
  97609. /**
  97610. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97611. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97612. */
  97613. static MaxDeltaTime: number;
  97614. /**
  97615. * Factory used to create the default material.
  97616. * @param name The name of the material to create
  97617. * @param scene The scene to create the material for
  97618. * @returns The default material
  97619. */
  97620. static DefaultMaterialFactory(scene: Scene): Material;
  97621. /**
  97622. * Factory used to create the a collision coordinator.
  97623. * @returns The collision coordinator
  97624. */
  97625. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97626. /** @hidden */
  97627. _inputManager: InputManager;
  97628. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97629. cameraToUseForPointers: Nullable<Camera>;
  97630. /** @hidden */
  97631. readonly _isScene: boolean;
  97632. /**
  97633. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97634. */
  97635. autoClear: boolean;
  97636. /**
  97637. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97638. */
  97639. autoClearDepthAndStencil: boolean;
  97640. /**
  97641. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97642. */
  97643. clearColor: Color4;
  97644. /**
  97645. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97646. */
  97647. ambientColor: Color3;
  97648. /**
  97649. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97650. * It should only be one of the following (if not the default embedded one):
  97651. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97652. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97653. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97654. * The material properties need to be setup according to the type of texture in use.
  97655. */
  97656. environmentBRDFTexture: BaseTexture;
  97657. /** @hidden */
  97658. protected _environmentTexture: Nullable<BaseTexture>;
  97659. /**
  97660. * Texture used in all pbr material as the reflection texture.
  97661. * As in the majority of the scene they are the same (exception for multi room and so on),
  97662. * this is easier to reference from here than from all the materials.
  97663. */
  97664. /**
  97665. * Texture used in all pbr material as the reflection texture.
  97666. * As in the majority of the scene they are the same (exception for multi room and so on),
  97667. * this is easier to set here than in all the materials.
  97668. */
  97669. environmentTexture: Nullable<BaseTexture>;
  97670. /** @hidden */
  97671. protected _environmentIntensity: number;
  97672. /**
  97673. * Intensity of the environment in all pbr material.
  97674. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97675. * As in the majority of the scene they are the same (exception for multi room and so on),
  97676. * this is easier to reference from here than from all the materials.
  97677. */
  97678. /**
  97679. * Intensity of the environment in all pbr material.
  97680. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97681. * As in the majority of the scene they are the same (exception for multi room and so on),
  97682. * this is easier to set here than in all the materials.
  97683. */
  97684. environmentIntensity: number;
  97685. /** @hidden */
  97686. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97687. /**
  97688. * Default image processing configuration used either in the rendering
  97689. * Forward main pass or through the imageProcessingPostProcess if present.
  97690. * As in the majority of the scene they are the same (exception for multi camera),
  97691. * this is easier to reference from here than from all the materials and post process.
  97692. *
  97693. * No setter as we it is a shared configuration, you can set the values instead.
  97694. */
  97695. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97696. private _forceWireframe;
  97697. /**
  97698. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97699. */
  97700. forceWireframe: boolean;
  97701. private _forcePointsCloud;
  97702. /**
  97703. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97704. */
  97705. forcePointsCloud: boolean;
  97706. /**
  97707. * Gets or sets the active clipplane 1
  97708. */
  97709. clipPlane: Nullable<Plane>;
  97710. /**
  97711. * Gets or sets the active clipplane 2
  97712. */
  97713. clipPlane2: Nullable<Plane>;
  97714. /**
  97715. * Gets or sets the active clipplane 3
  97716. */
  97717. clipPlane3: Nullable<Plane>;
  97718. /**
  97719. * Gets or sets the active clipplane 4
  97720. */
  97721. clipPlane4: Nullable<Plane>;
  97722. /**
  97723. * Gets or sets a boolean indicating if animations are enabled
  97724. */
  97725. animationsEnabled: boolean;
  97726. private _animationPropertiesOverride;
  97727. /**
  97728. * Gets or sets the animation properties override
  97729. */
  97730. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97731. /**
  97732. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97733. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97734. */
  97735. useConstantAnimationDeltaTime: boolean;
  97736. /**
  97737. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97738. * Please note that it requires to run a ray cast through the scene on every frame
  97739. */
  97740. constantlyUpdateMeshUnderPointer: boolean;
  97741. /**
  97742. * Defines the HTML cursor to use when hovering over interactive elements
  97743. */
  97744. hoverCursor: string;
  97745. /**
  97746. * Defines the HTML default cursor to use (empty by default)
  97747. */
  97748. defaultCursor: string;
  97749. /**
  97750. * This is used to call preventDefault() on pointer down
  97751. * in order to block unwanted artifacts like system double clicks
  97752. */
  97753. preventDefaultOnPointerDown: boolean;
  97754. /**
  97755. * This is used to call preventDefault() on pointer up
  97756. * in order to block unwanted artifacts like system double clicks
  97757. */
  97758. preventDefaultOnPointerUp: boolean;
  97759. /**
  97760. * Gets or sets user defined metadata
  97761. */
  97762. metadata: any;
  97763. /**
  97764. * For internal use only. Please do not use.
  97765. */
  97766. reservedDataStore: any;
  97767. /**
  97768. * Gets the name of the plugin used to load this scene (null by default)
  97769. */
  97770. loadingPluginName: string;
  97771. /**
  97772. * Use this array to add regular expressions used to disable offline support for specific urls
  97773. */
  97774. disableOfflineSupportExceptionRules: RegExp[];
  97775. /**
  97776. * An event triggered when the scene is disposed.
  97777. */
  97778. onDisposeObservable: Observable<Scene>;
  97779. private _onDisposeObserver;
  97780. /** Sets a function to be executed when this scene is disposed. */
  97781. onDispose: () => void;
  97782. /**
  97783. * An event triggered before rendering the scene (right after animations and physics)
  97784. */
  97785. onBeforeRenderObservable: Observable<Scene>;
  97786. private _onBeforeRenderObserver;
  97787. /** Sets a function to be executed before rendering this scene */
  97788. beforeRender: Nullable<() => void>;
  97789. /**
  97790. * An event triggered after rendering the scene
  97791. */
  97792. onAfterRenderObservable: Observable<Scene>;
  97793. /**
  97794. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97795. */
  97796. onAfterRenderCameraObservable: Observable<Camera>;
  97797. private _onAfterRenderObserver;
  97798. /** Sets a function to be executed after rendering this scene */
  97799. afterRender: Nullable<() => void>;
  97800. /**
  97801. * An event triggered before animating the scene
  97802. */
  97803. onBeforeAnimationsObservable: Observable<Scene>;
  97804. /**
  97805. * An event triggered after animations processing
  97806. */
  97807. onAfterAnimationsObservable: Observable<Scene>;
  97808. /**
  97809. * An event triggered before draw calls are ready to be sent
  97810. */
  97811. onBeforeDrawPhaseObservable: Observable<Scene>;
  97812. /**
  97813. * An event triggered after draw calls have been sent
  97814. */
  97815. onAfterDrawPhaseObservable: Observable<Scene>;
  97816. /**
  97817. * An event triggered when the scene is ready
  97818. */
  97819. onReadyObservable: Observable<Scene>;
  97820. /**
  97821. * An event triggered before rendering a camera
  97822. */
  97823. onBeforeCameraRenderObservable: Observable<Camera>;
  97824. private _onBeforeCameraRenderObserver;
  97825. /** Sets a function to be executed before rendering a camera*/
  97826. beforeCameraRender: () => void;
  97827. /**
  97828. * An event triggered after rendering a camera
  97829. */
  97830. onAfterCameraRenderObservable: Observable<Camera>;
  97831. private _onAfterCameraRenderObserver;
  97832. /** Sets a function to be executed after rendering a camera*/
  97833. afterCameraRender: () => void;
  97834. /**
  97835. * An event triggered when active meshes evaluation is about to start
  97836. */
  97837. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97838. /**
  97839. * An event triggered when active meshes evaluation is done
  97840. */
  97841. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97842. /**
  97843. * An event triggered when particles rendering is about to start
  97844. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97845. */
  97846. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97847. /**
  97848. * An event triggered when particles rendering is done
  97849. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97850. */
  97851. onAfterParticlesRenderingObservable: Observable<Scene>;
  97852. /**
  97853. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97854. */
  97855. onDataLoadedObservable: Observable<Scene>;
  97856. /**
  97857. * An event triggered when a camera is created
  97858. */
  97859. onNewCameraAddedObservable: Observable<Camera>;
  97860. /**
  97861. * An event triggered when a camera is removed
  97862. */
  97863. onCameraRemovedObservable: Observable<Camera>;
  97864. /**
  97865. * An event triggered when a light is created
  97866. */
  97867. onNewLightAddedObservable: Observable<Light>;
  97868. /**
  97869. * An event triggered when a light is removed
  97870. */
  97871. onLightRemovedObservable: Observable<Light>;
  97872. /**
  97873. * An event triggered when a geometry is created
  97874. */
  97875. onNewGeometryAddedObservable: Observable<Geometry>;
  97876. /**
  97877. * An event triggered when a geometry is removed
  97878. */
  97879. onGeometryRemovedObservable: Observable<Geometry>;
  97880. /**
  97881. * An event triggered when a transform node is created
  97882. */
  97883. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97884. /**
  97885. * An event triggered when a transform node is removed
  97886. */
  97887. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97888. /**
  97889. * An event triggered when a mesh is created
  97890. */
  97891. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97892. /**
  97893. * An event triggered when a mesh is removed
  97894. */
  97895. onMeshRemovedObservable: Observable<AbstractMesh>;
  97896. /**
  97897. * An event triggered when a skeleton is created
  97898. */
  97899. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97900. /**
  97901. * An event triggered when a skeleton is removed
  97902. */
  97903. onSkeletonRemovedObservable: Observable<Skeleton>;
  97904. /**
  97905. * An event triggered when a material is created
  97906. */
  97907. onNewMaterialAddedObservable: Observable<Material>;
  97908. /**
  97909. * An event triggered when a material is removed
  97910. */
  97911. onMaterialRemovedObservable: Observable<Material>;
  97912. /**
  97913. * An event triggered when a texture is created
  97914. */
  97915. onNewTextureAddedObservable: Observable<BaseTexture>;
  97916. /**
  97917. * An event triggered when a texture is removed
  97918. */
  97919. onTextureRemovedObservable: Observable<BaseTexture>;
  97920. /**
  97921. * An event triggered when render targets are about to be rendered
  97922. * Can happen multiple times per frame.
  97923. */
  97924. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97925. /**
  97926. * An event triggered when render targets were rendered.
  97927. * Can happen multiple times per frame.
  97928. */
  97929. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97930. /**
  97931. * An event triggered before calculating deterministic simulation step
  97932. */
  97933. onBeforeStepObservable: Observable<Scene>;
  97934. /**
  97935. * An event triggered after calculating deterministic simulation step
  97936. */
  97937. onAfterStepObservable: Observable<Scene>;
  97938. /**
  97939. * An event triggered when the activeCamera property is updated
  97940. */
  97941. onActiveCameraChanged: Observable<Scene>;
  97942. /**
  97943. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97944. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97945. * 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)
  97946. */
  97947. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97948. /**
  97949. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97950. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97951. * 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)
  97952. */
  97953. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97954. /**
  97955. * This Observable will when a mesh has been imported into the scene.
  97956. */
  97957. onMeshImportedObservable: Observable<AbstractMesh>;
  97958. /**
  97959. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97960. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97961. */
  97962. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97963. /** @hidden */
  97964. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97965. /**
  97966. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97967. */
  97968. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97969. /**
  97970. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97971. */
  97972. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97973. /**
  97974. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97975. */
  97976. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97977. /** Callback called when a pointer move is detected */
  97978. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97979. /** Callback called when a pointer down is detected */
  97980. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97981. /** Callback called when a pointer up is detected */
  97982. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97983. /** Callback called when a pointer pick is detected */
  97984. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97985. /**
  97986. * 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).
  97987. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97988. */
  97989. onPrePointerObservable: Observable<PointerInfoPre>;
  97990. /**
  97991. * Observable event triggered each time an input event is received from the rendering canvas
  97992. */
  97993. onPointerObservable: Observable<PointerInfo>;
  97994. /**
  97995. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97996. */
  97997. readonly unTranslatedPointer: Vector2;
  97998. /**
  97999. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98000. */
  98001. static DragMovementThreshold: number;
  98002. /**
  98003. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98004. */
  98005. static LongPressDelay: number;
  98006. /**
  98007. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98008. */
  98009. static DoubleClickDelay: number;
  98010. /** If you need to check double click without raising a single click at first click, enable this flag */
  98011. static ExclusiveDoubleClickMode: boolean;
  98012. /** @hidden */
  98013. _mirroredCameraPosition: Nullable<Vector3>;
  98014. /**
  98015. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98016. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98017. */
  98018. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98019. /**
  98020. * Observable event triggered each time an keyboard event is received from the hosting window
  98021. */
  98022. onKeyboardObservable: Observable<KeyboardInfo>;
  98023. private _useRightHandedSystem;
  98024. /**
  98025. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98026. */
  98027. useRightHandedSystem: boolean;
  98028. private _timeAccumulator;
  98029. private _currentStepId;
  98030. private _currentInternalStep;
  98031. /**
  98032. * Sets the step Id used by deterministic lock step
  98033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98034. * @param newStepId defines the step Id
  98035. */
  98036. setStepId(newStepId: number): void;
  98037. /**
  98038. * Gets the step Id used by deterministic lock step
  98039. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98040. * @returns the step Id
  98041. */
  98042. getStepId(): number;
  98043. /**
  98044. * Gets the internal step used by deterministic lock step
  98045. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98046. * @returns the internal step
  98047. */
  98048. getInternalStep(): number;
  98049. private _fogEnabled;
  98050. /**
  98051. * Gets or sets a boolean indicating if fog is enabled on this scene
  98052. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98053. * (Default is true)
  98054. */
  98055. fogEnabled: boolean;
  98056. private _fogMode;
  98057. /**
  98058. * Gets or sets the fog mode to use
  98059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98060. * | mode | value |
  98061. * | --- | --- |
  98062. * | FOGMODE_NONE | 0 |
  98063. * | FOGMODE_EXP | 1 |
  98064. * | FOGMODE_EXP2 | 2 |
  98065. * | FOGMODE_LINEAR | 3 |
  98066. */
  98067. fogMode: number;
  98068. /**
  98069. * Gets or sets the fog color to use
  98070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98071. * (Default is Color3(0.2, 0.2, 0.3))
  98072. */
  98073. fogColor: Color3;
  98074. /**
  98075. * Gets or sets the fog density to use
  98076. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98077. * (Default is 0.1)
  98078. */
  98079. fogDensity: number;
  98080. /**
  98081. * Gets or sets the fog start distance to use
  98082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98083. * (Default is 0)
  98084. */
  98085. fogStart: number;
  98086. /**
  98087. * Gets or sets the fog end distance to use
  98088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98089. * (Default is 1000)
  98090. */
  98091. fogEnd: number;
  98092. private _shadowsEnabled;
  98093. /**
  98094. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98095. */
  98096. shadowsEnabled: boolean;
  98097. private _lightsEnabled;
  98098. /**
  98099. * Gets or sets a boolean indicating if lights are enabled on this scene
  98100. */
  98101. lightsEnabled: boolean;
  98102. /** All of the active cameras added to this scene. */
  98103. activeCameras: Camera[];
  98104. /** @hidden */
  98105. _activeCamera: Nullable<Camera>;
  98106. /** Gets or sets the current active camera */
  98107. activeCamera: Nullable<Camera>;
  98108. private _defaultMaterial;
  98109. /** The default material used on meshes when no material is affected */
  98110. /** The default material used on meshes when no material is affected */
  98111. defaultMaterial: Material;
  98112. private _texturesEnabled;
  98113. /**
  98114. * Gets or sets a boolean indicating if textures are enabled on this scene
  98115. */
  98116. texturesEnabled: boolean;
  98117. /**
  98118. * Gets or sets a boolean indicating if particles are enabled on this scene
  98119. */
  98120. particlesEnabled: boolean;
  98121. /**
  98122. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98123. */
  98124. spritesEnabled: boolean;
  98125. private _skeletonsEnabled;
  98126. /**
  98127. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98128. */
  98129. skeletonsEnabled: boolean;
  98130. /**
  98131. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98132. */
  98133. lensFlaresEnabled: boolean;
  98134. /**
  98135. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98137. */
  98138. collisionsEnabled: boolean;
  98139. private _collisionCoordinator;
  98140. /** @hidden */
  98141. readonly collisionCoordinator: ICollisionCoordinator;
  98142. /**
  98143. * Defines the gravity applied to this scene (used only for collisions)
  98144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98145. */
  98146. gravity: Vector3;
  98147. /**
  98148. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98149. */
  98150. postProcessesEnabled: boolean;
  98151. /**
  98152. * The list of postprocesses added to the scene
  98153. */
  98154. postProcesses: PostProcess[];
  98155. /**
  98156. * Gets the current postprocess manager
  98157. */
  98158. postProcessManager: PostProcessManager;
  98159. /**
  98160. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98161. */
  98162. renderTargetsEnabled: boolean;
  98163. /**
  98164. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98165. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98166. */
  98167. dumpNextRenderTargets: boolean;
  98168. /**
  98169. * The list of user defined render targets added to the scene
  98170. */
  98171. customRenderTargets: RenderTargetTexture[];
  98172. /**
  98173. * Defines if texture loading must be delayed
  98174. * If true, textures will only be loaded when they need to be rendered
  98175. */
  98176. useDelayedTextureLoading: boolean;
  98177. /**
  98178. * Gets the list of meshes imported to the scene through SceneLoader
  98179. */
  98180. importedMeshesFiles: String[];
  98181. /**
  98182. * Gets or sets a boolean indicating if probes are enabled on this scene
  98183. */
  98184. probesEnabled: boolean;
  98185. /**
  98186. * Gets or sets the current offline provider to use to store scene data
  98187. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98188. */
  98189. offlineProvider: IOfflineProvider;
  98190. /**
  98191. * Gets or sets the action manager associated with the scene
  98192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98193. */
  98194. actionManager: AbstractActionManager;
  98195. private _meshesForIntersections;
  98196. /**
  98197. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98198. */
  98199. proceduralTexturesEnabled: boolean;
  98200. private _engine;
  98201. private _totalVertices;
  98202. /** @hidden */
  98203. _activeIndices: PerfCounter;
  98204. /** @hidden */
  98205. _activeParticles: PerfCounter;
  98206. /** @hidden */
  98207. _activeBones: PerfCounter;
  98208. private _animationRatio;
  98209. /** @hidden */
  98210. _animationTimeLast: number;
  98211. /** @hidden */
  98212. _animationTime: number;
  98213. /**
  98214. * Gets or sets a general scale for animation speed
  98215. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98216. */
  98217. animationTimeScale: number;
  98218. /** @hidden */
  98219. _cachedMaterial: Nullable<Material>;
  98220. /** @hidden */
  98221. _cachedEffect: Nullable<Effect>;
  98222. /** @hidden */
  98223. _cachedVisibility: Nullable<number>;
  98224. private _renderId;
  98225. private _frameId;
  98226. private _executeWhenReadyTimeoutId;
  98227. private _intermediateRendering;
  98228. private _viewUpdateFlag;
  98229. private _projectionUpdateFlag;
  98230. /** @hidden */
  98231. _toBeDisposed: Nullable<IDisposable>[];
  98232. private _activeRequests;
  98233. /** @hidden */
  98234. _pendingData: any[];
  98235. private _isDisposed;
  98236. /**
  98237. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98238. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98239. */
  98240. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98241. private _activeMeshes;
  98242. private _processedMaterials;
  98243. private _renderTargets;
  98244. /** @hidden */
  98245. _activeParticleSystems: SmartArray<IParticleSystem>;
  98246. private _activeSkeletons;
  98247. private _softwareSkinnedMeshes;
  98248. private _renderingManager;
  98249. /** @hidden */
  98250. _activeAnimatables: Animatable[];
  98251. private _transformMatrix;
  98252. private _sceneUbo;
  98253. /** @hidden */
  98254. _viewMatrix: Matrix;
  98255. private _projectionMatrix;
  98256. /** @hidden */
  98257. _forcedViewPosition: Nullable<Vector3>;
  98258. /** @hidden */
  98259. _frustumPlanes: Plane[];
  98260. /**
  98261. * Gets the list of frustum planes (built from the active camera)
  98262. */
  98263. readonly frustumPlanes: Plane[];
  98264. /**
  98265. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98266. * This is useful if there are more lights that the maximum simulteanous authorized
  98267. */
  98268. requireLightSorting: boolean;
  98269. /** @hidden */
  98270. readonly useMaterialMeshMap: boolean;
  98271. /** @hidden */
  98272. readonly useClonedMeshhMap: boolean;
  98273. private _externalData;
  98274. private _uid;
  98275. /**
  98276. * @hidden
  98277. * Backing store of defined scene components.
  98278. */
  98279. _components: ISceneComponent[];
  98280. /**
  98281. * @hidden
  98282. * Backing store of defined scene components.
  98283. */
  98284. _serializableComponents: ISceneSerializableComponent[];
  98285. /**
  98286. * List of components to register on the next registration step.
  98287. */
  98288. private _transientComponents;
  98289. /**
  98290. * Registers the transient components if needed.
  98291. */
  98292. private _registerTransientComponents;
  98293. /**
  98294. * @hidden
  98295. * Add a component to the scene.
  98296. * Note that the ccomponent could be registered on th next frame if this is called after
  98297. * the register component stage.
  98298. * @param component Defines the component to add to the scene
  98299. */
  98300. _addComponent(component: ISceneComponent): void;
  98301. /**
  98302. * @hidden
  98303. * Gets a component from the scene.
  98304. * @param name defines the name of the component to retrieve
  98305. * @returns the component or null if not present
  98306. */
  98307. _getComponent(name: string): Nullable<ISceneComponent>;
  98308. /**
  98309. * @hidden
  98310. * Defines the actions happening before camera updates.
  98311. */
  98312. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98313. /**
  98314. * @hidden
  98315. * Defines the actions happening before clear the canvas.
  98316. */
  98317. _beforeClearStage: Stage<SimpleStageAction>;
  98318. /**
  98319. * @hidden
  98320. * Defines the actions when collecting render targets for the frame.
  98321. */
  98322. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98323. /**
  98324. * @hidden
  98325. * Defines the actions happening for one camera in the frame.
  98326. */
  98327. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98328. /**
  98329. * @hidden
  98330. * Defines the actions happening during the per mesh ready checks.
  98331. */
  98332. _isReadyForMeshStage: Stage<MeshStageAction>;
  98333. /**
  98334. * @hidden
  98335. * Defines the actions happening before evaluate active mesh checks.
  98336. */
  98337. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98338. /**
  98339. * @hidden
  98340. * Defines the actions happening during the evaluate sub mesh checks.
  98341. */
  98342. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98343. /**
  98344. * @hidden
  98345. * Defines the actions happening during the active mesh stage.
  98346. */
  98347. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98348. /**
  98349. * @hidden
  98350. * Defines the actions happening during the per camera render target step.
  98351. */
  98352. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98353. /**
  98354. * @hidden
  98355. * Defines the actions happening just before the active camera is drawing.
  98356. */
  98357. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98358. /**
  98359. * @hidden
  98360. * Defines the actions happening just before a render target is drawing.
  98361. */
  98362. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98363. /**
  98364. * @hidden
  98365. * Defines the actions happening just before a rendering group is drawing.
  98366. */
  98367. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98368. /**
  98369. * @hidden
  98370. * Defines the actions happening just before a mesh is drawing.
  98371. */
  98372. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98373. /**
  98374. * @hidden
  98375. * Defines the actions happening just after a mesh has been drawn.
  98376. */
  98377. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98378. /**
  98379. * @hidden
  98380. * Defines the actions happening just after a rendering group has been drawn.
  98381. */
  98382. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98383. /**
  98384. * @hidden
  98385. * Defines the actions happening just after the active camera has been drawn.
  98386. */
  98387. _afterCameraDrawStage: Stage<CameraStageAction>;
  98388. /**
  98389. * @hidden
  98390. * Defines the actions happening just after a render target has been drawn.
  98391. */
  98392. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98393. /**
  98394. * @hidden
  98395. * Defines the actions happening just after rendering all cameras and computing intersections.
  98396. */
  98397. _afterRenderStage: Stage<SimpleStageAction>;
  98398. /**
  98399. * @hidden
  98400. * Defines the actions happening when a pointer move event happens.
  98401. */
  98402. _pointerMoveStage: Stage<PointerMoveStageAction>;
  98403. /**
  98404. * @hidden
  98405. * Defines the actions happening when a pointer down event happens.
  98406. */
  98407. _pointerDownStage: Stage<PointerUpDownStageAction>;
  98408. /**
  98409. * @hidden
  98410. * Defines the actions happening when a pointer up event happens.
  98411. */
  98412. _pointerUpStage: Stage<PointerUpDownStageAction>;
  98413. /**
  98414. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  98415. */
  98416. private geometriesByUniqueId;
  98417. /**
  98418. * Creates a new Scene
  98419. * @param engine defines the engine to use to render this scene
  98420. * @param options defines the scene options
  98421. */
  98422. constructor(engine: Engine, options?: SceneOptions);
  98423. /**
  98424. * Gets a string idenfifying the name of the class
  98425. * @returns "Scene" string
  98426. */
  98427. getClassName(): string;
  98428. private _defaultMeshCandidates;
  98429. /**
  98430. * @hidden
  98431. */
  98432. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98433. private _defaultSubMeshCandidates;
  98434. /**
  98435. * @hidden
  98436. */
  98437. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98438. /**
  98439. * Sets the default candidate providers for the scene.
  98440. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98441. * and getCollidingSubMeshCandidates to their default function
  98442. */
  98443. setDefaultCandidateProviders(): void;
  98444. /**
  98445. * Gets the mesh that is currently under the pointer
  98446. */
  98447. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98448. /**
  98449. * Gets or sets the current on-screen X position of the pointer
  98450. */
  98451. pointerX: number;
  98452. /**
  98453. * Gets or sets the current on-screen Y position of the pointer
  98454. */
  98455. pointerY: number;
  98456. /**
  98457. * Gets the cached material (ie. the latest rendered one)
  98458. * @returns the cached material
  98459. */
  98460. getCachedMaterial(): Nullable<Material>;
  98461. /**
  98462. * Gets the cached effect (ie. the latest rendered one)
  98463. * @returns the cached effect
  98464. */
  98465. getCachedEffect(): Nullable<Effect>;
  98466. /**
  98467. * Gets the cached visibility state (ie. the latest rendered one)
  98468. * @returns the cached visibility state
  98469. */
  98470. getCachedVisibility(): Nullable<number>;
  98471. /**
  98472. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98473. * @param material defines the current material
  98474. * @param effect defines the current effect
  98475. * @param visibility defines the current visibility state
  98476. * @returns true if one parameter is not cached
  98477. */
  98478. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98479. /**
  98480. * Gets the engine associated with the scene
  98481. * @returns an Engine
  98482. */
  98483. getEngine(): Engine;
  98484. /**
  98485. * Gets the total number of vertices rendered per frame
  98486. * @returns the total number of vertices rendered per frame
  98487. */
  98488. getTotalVertices(): number;
  98489. /**
  98490. * Gets the performance counter for total vertices
  98491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98492. */
  98493. readonly totalVerticesPerfCounter: PerfCounter;
  98494. /**
  98495. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98496. * @returns the total number of active indices rendered per frame
  98497. */
  98498. getActiveIndices(): number;
  98499. /**
  98500. * Gets the performance counter for active indices
  98501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98502. */
  98503. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98504. /**
  98505. * Gets the total number of active particles rendered per frame
  98506. * @returns the total number of active particles rendered per frame
  98507. */
  98508. getActiveParticles(): number;
  98509. /**
  98510. * Gets the performance counter for active particles
  98511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98512. */
  98513. readonly activeParticlesPerfCounter: PerfCounter;
  98514. /**
  98515. * Gets the total number of active bones rendered per frame
  98516. * @returns the total number of active bones rendered per frame
  98517. */
  98518. getActiveBones(): number;
  98519. /**
  98520. * Gets the performance counter for active bones
  98521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98522. */
  98523. readonly activeBonesPerfCounter: PerfCounter;
  98524. /**
  98525. * Gets the array of active meshes
  98526. * @returns an array of AbstractMesh
  98527. */
  98528. getActiveMeshes(): SmartArray<AbstractMesh>;
  98529. /**
  98530. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98531. * @returns a number
  98532. */
  98533. getAnimationRatio(): number;
  98534. /**
  98535. * Gets an unique Id for the current render phase
  98536. * @returns a number
  98537. */
  98538. getRenderId(): number;
  98539. /**
  98540. * Gets an unique Id for the current frame
  98541. * @returns a number
  98542. */
  98543. getFrameId(): number;
  98544. /** Call this function if you want to manually increment the render Id*/
  98545. incrementRenderId(): void;
  98546. private _createUbo;
  98547. /**
  98548. * Use this method to simulate a pointer move on a mesh
  98549. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98550. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98551. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98552. * @returns the current scene
  98553. */
  98554. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98555. /**
  98556. * Use this method to simulate a pointer down on a mesh
  98557. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98558. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98559. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98560. * @returns the current scene
  98561. */
  98562. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98563. /**
  98564. * Use this method to simulate a pointer up on a mesh
  98565. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98566. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98567. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98568. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98569. * @returns the current scene
  98570. */
  98571. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98572. /**
  98573. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98574. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98575. * @returns true if the pointer was captured
  98576. */
  98577. isPointerCaptured(pointerId?: number): boolean;
  98578. /**
  98579. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98580. * @param attachUp defines if you want to attach events to pointerup
  98581. * @param attachDown defines if you want to attach events to pointerdown
  98582. * @param attachMove defines if you want to attach events to pointermove
  98583. */
  98584. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98585. /** Detaches all event handlers*/
  98586. detachControl(): void;
  98587. /**
  98588. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98589. * Delay loaded resources are not taking in account
  98590. * @return true if all required resources are ready
  98591. */
  98592. isReady(): boolean;
  98593. /** Resets all cached information relative to material (including effect and visibility) */
  98594. resetCachedMaterial(): void;
  98595. /**
  98596. * Registers a function to be called before every frame render
  98597. * @param func defines the function to register
  98598. */
  98599. registerBeforeRender(func: () => void): void;
  98600. /**
  98601. * Unregisters a function called before every frame render
  98602. * @param func defines the function to unregister
  98603. */
  98604. unregisterBeforeRender(func: () => void): void;
  98605. /**
  98606. * Registers a function to be called after every frame render
  98607. * @param func defines the function to register
  98608. */
  98609. registerAfterRender(func: () => void): void;
  98610. /**
  98611. * Unregisters a function called after every frame render
  98612. * @param func defines the function to unregister
  98613. */
  98614. unregisterAfterRender(func: () => void): void;
  98615. private _executeOnceBeforeRender;
  98616. /**
  98617. * The provided function will run before render once and will be disposed afterwards.
  98618. * A timeout delay can be provided so that the function will be executed in N ms.
  98619. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98620. * @param func The function to be executed.
  98621. * @param timeout optional delay in ms
  98622. */
  98623. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98624. /** @hidden */
  98625. _addPendingData(data: any): void;
  98626. /** @hidden */
  98627. _removePendingData(data: any): void;
  98628. /**
  98629. * Returns the number of items waiting to be loaded
  98630. * @returns the number of items waiting to be loaded
  98631. */
  98632. getWaitingItemsCount(): number;
  98633. /**
  98634. * Returns a boolean indicating if the scene is still loading data
  98635. */
  98636. readonly isLoading: boolean;
  98637. /**
  98638. * Registers a function to be executed when the scene is ready
  98639. * @param {Function} func - the function to be executed
  98640. */
  98641. executeWhenReady(func: () => void): void;
  98642. /**
  98643. * Returns a promise that resolves when the scene is ready
  98644. * @returns A promise that resolves when the scene is ready
  98645. */
  98646. whenReadyAsync(): Promise<void>;
  98647. /** @hidden */
  98648. _checkIsReady(): void;
  98649. /**
  98650. * Gets all animatable attached to the scene
  98651. */
  98652. readonly animatables: Animatable[];
  98653. /**
  98654. * Resets the last animation time frame.
  98655. * Useful to override when animations start running when loading a scene for the first time.
  98656. */
  98657. resetLastAnimationTimeFrame(): void;
  98658. /**
  98659. * Gets the current view matrix
  98660. * @returns a Matrix
  98661. */
  98662. getViewMatrix(): Matrix;
  98663. /**
  98664. * Gets the current projection matrix
  98665. * @returns a Matrix
  98666. */
  98667. getProjectionMatrix(): Matrix;
  98668. /**
  98669. * Gets the current transform matrix
  98670. * @returns a Matrix made of View * Projection
  98671. */
  98672. getTransformMatrix(): Matrix;
  98673. /**
  98674. * Sets the current transform matrix
  98675. * @param viewL defines the View matrix to use
  98676. * @param projectionL defines the Projection matrix to use
  98677. * @param viewR defines the right View matrix to use (if provided)
  98678. * @param projectionR defines the right Projection matrix to use (if provided)
  98679. */
  98680. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98681. /**
  98682. * Gets the uniform buffer used to store scene data
  98683. * @returns a UniformBuffer
  98684. */
  98685. getSceneUniformBuffer(): UniformBuffer;
  98686. /**
  98687. * Gets an unique (relatively to the current scene) Id
  98688. * @returns an unique number for the scene
  98689. */
  98690. getUniqueId(): number;
  98691. /**
  98692. * Add a mesh to the list of scene's meshes
  98693. * @param newMesh defines the mesh to add
  98694. * @param recursive if all child meshes should also be added to the scene
  98695. */
  98696. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98697. /**
  98698. * Remove a mesh for the list of scene's meshes
  98699. * @param toRemove defines the mesh to remove
  98700. * @param recursive if all child meshes should also be removed from the scene
  98701. * @returns the index where the mesh was in the mesh list
  98702. */
  98703. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98704. /**
  98705. * Add a transform node to the list of scene's transform nodes
  98706. * @param newTransformNode defines the transform node to add
  98707. */
  98708. addTransformNode(newTransformNode: TransformNode): void;
  98709. /**
  98710. * Remove a transform node for the list of scene's transform nodes
  98711. * @param toRemove defines the transform node to remove
  98712. * @returns the index where the transform node was in the transform node list
  98713. */
  98714. removeTransformNode(toRemove: TransformNode): number;
  98715. /**
  98716. * Remove a skeleton for the list of scene's skeletons
  98717. * @param toRemove defines the skeleton to remove
  98718. * @returns the index where the skeleton was in the skeleton list
  98719. */
  98720. removeSkeleton(toRemove: Skeleton): number;
  98721. /**
  98722. * Remove a morph target for the list of scene's morph targets
  98723. * @param toRemove defines the morph target to remove
  98724. * @returns the index where the morph target was in the morph target list
  98725. */
  98726. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98727. /**
  98728. * Remove a light for the list of scene's lights
  98729. * @param toRemove defines the light to remove
  98730. * @returns the index where the light was in the light list
  98731. */
  98732. removeLight(toRemove: Light): number;
  98733. /**
  98734. * Remove a camera for the list of scene's cameras
  98735. * @param toRemove defines the camera to remove
  98736. * @returns the index where the camera was in the camera list
  98737. */
  98738. removeCamera(toRemove: Camera): number;
  98739. /**
  98740. * Remove a particle system for the list of scene's particle systems
  98741. * @param toRemove defines the particle system to remove
  98742. * @returns the index where the particle system was in the particle system list
  98743. */
  98744. removeParticleSystem(toRemove: IParticleSystem): number;
  98745. /**
  98746. * Remove a animation for the list of scene's animations
  98747. * @param toRemove defines the animation to remove
  98748. * @returns the index where the animation was in the animation list
  98749. */
  98750. removeAnimation(toRemove: Animation): number;
  98751. /**
  98752. * Will stop the animation of the given target
  98753. * @param target - the target
  98754. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98755. * @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)
  98756. */
  98757. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98758. /**
  98759. * Removes the given animation group from this scene.
  98760. * @param toRemove The animation group to remove
  98761. * @returns The index of the removed animation group
  98762. */
  98763. removeAnimationGroup(toRemove: AnimationGroup): number;
  98764. /**
  98765. * Removes the given multi-material from this scene.
  98766. * @param toRemove The multi-material to remove
  98767. * @returns The index of the removed multi-material
  98768. */
  98769. removeMultiMaterial(toRemove: MultiMaterial): number;
  98770. /**
  98771. * Removes the given material from this scene.
  98772. * @param toRemove The material to remove
  98773. * @returns The index of the removed material
  98774. */
  98775. removeMaterial(toRemove: Material): number;
  98776. /**
  98777. * Removes the given action manager from this scene.
  98778. * @param toRemove The action manager to remove
  98779. * @returns The index of the removed action manager
  98780. */
  98781. removeActionManager(toRemove: AbstractActionManager): number;
  98782. /**
  98783. * Removes the given texture from this scene.
  98784. * @param toRemove The texture to remove
  98785. * @returns The index of the removed texture
  98786. */
  98787. removeTexture(toRemove: BaseTexture): number;
  98788. /**
  98789. * Adds the given light to this scene
  98790. * @param newLight The light to add
  98791. */
  98792. addLight(newLight: Light): void;
  98793. /**
  98794. * Sorts the list list based on light priorities
  98795. */
  98796. sortLightsByPriority(): void;
  98797. /**
  98798. * Adds the given camera to this scene
  98799. * @param newCamera The camera to add
  98800. */
  98801. addCamera(newCamera: Camera): void;
  98802. /**
  98803. * Adds the given skeleton to this scene
  98804. * @param newSkeleton The skeleton to add
  98805. */
  98806. addSkeleton(newSkeleton: Skeleton): void;
  98807. /**
  98808. * Adds the given particle system to this scene
  98809. * @param newParticleSystem The particle system to add
  98810. */
  98811. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98812. /**
  98813. * Adds the given animation to this scene
  98814. * @param newAnimation The animation to add
  98815. */
  98816. addAnimation(newAnimation: Animation): void;
  98817. /**
  98818. * Adds the given animation group to this scene.
  98819. * @param newAnimationGroup The animation group to add
  98820. */
  98821. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98822. /**
  98823. * Adds the given multi-material to this scene
  98824. * @param newMultiMaterial The multi-material to add
  98825. */
  98826. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98827. /**
  98828. * Adds the given material to this scene
  98829. * @param newMaterial The material to add
  98830. */
  98831. addMaterial(newMaterial: Material): void;
  98832. /**
  98833. * Adds the given morph target to this scene
  98834. * @param newMorphTargetManager The morph target to add
  98835. */
  98836. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98837. /**
  98838. * Adds the given geometry to this scene
  98839. * @param newGeometry The geometry to add
  98840. */
  98841. addGeometry(newGeometry: Geometry): void;
  98842. /**
  98843. * Adds the given action manager to this scene
  98844. * @param newActionManager The action manager to add
  98845. */
  98846. addActionManager(newActionManager: AbstractActionManager): void;
  98847. /**
  98848. * Adds the given texture to this scene.
  98849. * @param newTexture The texture to add
  98850. */
  98851. addTexture(newTexture: BaseTexture): void;
  98852. /**
  98853. * Switch active camera
  98854. * @param newCamera defines the new active camera
  98855. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98856. */
  98857. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98858. /**
  98859. * sets the active camera of the scene using its ID
  98860. * @param id defines the camera's ID
  98861. * @return the new active camera or null if none found.
  98862. */
  98863. setActiveCameraByID(id: string): Nullable<Camera>;
  98864. /**
  98865. * sets the active camera of the scene using its name
  98866. * @param name defines the camera's name
  98867. * @returns the new active camera or null if none found.
  98868. */
  98869. setActiveCameraByName(name: string): Nullable<Camera>;
  98870. /**
  98871. * get an animation group using its name
  98872. * @param name defines the material's name
  98873. * @return the animation group or null if none found.
  98874. */
  98875. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98876. /**
  98877. * Get a material using its unique id
  98878. * @param uniqueId defines the material's unique id
  98879. * @return the material or null if none found.
  98880. */
  98881. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98882. /**
  98883. * get a material using its id
  98884. * @param id defines the material's ID
  98885. * @return the material or null if none found.
  98886. */
  98887. getMaterialByID(id: string): Nullable<Material>;
  98888. /**
  98889. * Gets a the last added material using a given id
  98890. * @param id defines the material's ID
  98891. * @return the last material with the given id or null if none found.
  98892. */
  98893. getLastMaterialByID(id: string): Nullable<Material>;
  98894. /**
  98895. * Gets a material using its name
  98896. * @param name defines the material's name
  98897. * @return the material or null if none found.
  98898. */
  98899. getMaterialByName(name: string): Nullable<Material>;
  98900. /**
  98901. * Get a texture using its unique id
  98902. * @param uniqueId defines the texture's unique id
  98903. * @return the texture or null if none found.
  98904. */
  98905. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98906. /**
  98907. * Gets a camera using its id
  98908. * @param id defines the id to look for
  98909. * @returns the camera or null if not found
  98910. */
  98911. getCameraByID(id: string): Nullable<Camera>;
  98912. /**
  98913. * Gets a camera using its unique id
  98914. * @param uniqueId defines the unique id to look for
  98915. * @returns the camera or null if not found
  98916. */
  98917. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98918. /**
  98919. * Gets a camera using its name
  98920. * @param name defines the camera's name
  98921. * @return the camera or null if none found.
  98922. */
  98923. getCameraByName(name: string): Nullable<Camera>;
  98924. /**
  98925. * Gets a bone using its id
  98926. * @param id defines the bone's id
  98927. * @return the bone or null if not found
  98928. */
  98929. getBoneByID(id: string): Nullable<Bone>;
  98930. /**
  98931. * Gets a bone using its id
  98932. * @param name defines the bone's name
  98933. * @return the bone or null if not found
  98934. */
  98935. getBoneByName(name: string): Nullable<Bone>;
  98936. /**
  98937. * Gets a light node using its name
  98938. * @param name defines the the light's name
  98939. * @return the light or null if none found.
  98940. */
  98941. getLightByName(name: string): Nullable<Light>;
  98942. /**
  98943. * Gets a light node using its id
  98944. * @param id defines the light's id
  98945. * @return the light or null if none found.
  98946. */
  98947. getLightByID(id: string): Nullable<Light>;
  98948. /**
  98949. * Gets a light node using its scene-generated unique ID
  98950. * @param uniqueId defines the light's unique id
  98951. * @return the light or null if none found.
  98952. */
  98953. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98954. /**
  98955. * Gets a particle system by id
  98956. * @param id defines the particle system id
  98957. * @return the corresponding system or null if none found
  98958. */
  98959. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98960. /**
  98961. * Gets a geometry using its ID
  98962. * @param id defines the geometry's id
  98963. * @return the geometry or null if none found.
  98964. */
  98965. getGeometryByID(id: string): Nullable<Geometry>;
  98966. private _getGeometryByUniqueID;
  98967. /**
  98968. * Add a new geometry to this scene
  98969. * @param geometry defines the geometry to be added to the scene.
  98970. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98971. * @return a boolean defining if the geometry was added or not
  98972. */
  98973. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98974. /**
  98975. * Removes an existing geometry
  98976. * @param geometry defines the geometry to be removed from the scene
  98977. * @return a boolean defining if the geometry was removed or not
  98978. */
  98979. removeGeometry(geometry: Geometry): boolean;
  98980. /**
  98981. * Gets the list of geometries attached to the scene
  98982. * @returns an array of Geometry
  98983. */
  98984. getGeometries(): Geometry[];
  98985. /**
  98986. * Gets the first added mesh found of a given ID
  98987. * @param id defines the id to search for
  98988. * @return the mesh found or null if not found at all
  98989. */
  98990. getMeshByID(id: string): Nullable<AbstractMesh>;
  98991. /**
  98992. * Gets a list of meshes using their id
  98993. * @param id defines the id to search for
  98994. * @returns a list of meshes
  98995. */
  98996. getMeshesByID(id: string): Array<AbstractMesh>;
  98997. /**
  98998. * Gets the first added transform node found of a given ID
  98999. * @param id defines the id to search for
  99000. * @return the found transform node or null if not found at all.
  99001. */
  99002. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99003. /**
  99004. * Gets a transform node with its auto-generated unique id
  99005. * @param uniqueId efines the unique id to search for
  99006. * @return the found transform node or null if not found at all.
  99007. */
  99008. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99009. /**
  99010. * Gets a list of transform nodes using their id
  99011. * @param id defines the id to search for
  99012. * @returns a list of transform nodes
  99013. */
  99014. getTransformNodesByID(id: string): Array<TransformNode>;
  99015. /**
  99016. * Gets a mesh with its auto-generated unique id
  99017. * @param uniqueId defines the unique id to search for
  99018. * @return the found mesh or null if not found at all.
  99019. */
  99020. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99021. /**
  99022. * Gets a the last added mesh using a given id
  99023. * @param id defines the id to search for
  99024. * @return the found mesh or null if not found at all.
  99025. */
  99026. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99027. /**
  99028. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99029. * @param id defines the id to search for
  99030. * @return the found node or null if not found at all
  99031. */
  99032. getLastEntryByID(id: string): Nullable<Node>;
  99033. /**
  99034. * Gets a node (Mesh, Camera, Light) using a given id
  99035. * @param id defines the id to search for
  99036. * @return the found node or null if not found at all
  99037. */
  99038. getNodeByID(id: string): Nullable<Node>;
  99039. /**
  99040. * Gets a node (Mesh, Camera, Light) using a given name
  99041. * @param name defines the name to search for
  99042. * @return the found node or null if not found at all.
  99043. */
  99044. getNodeByName(name: string): Nullable<Node>;
  99045. /**
  99046. * Gets a mesh using a given name
  99047. * @param name defines the name to search for
  99048. * @return the found mesh or null if not found at all.
  99049. */
  99050. getMeshByName(name: string): Nullable<AbstractMesh>;
  99051. /**
  99052. * Gets a transform node using a given name
  99053. * @param name defines the name to search for
  99054. * @return the found transform node or null if not found at all.
  99055. */
  99056. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99057. /**
  99058. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99059. * @param id defines the id to search for
  99060. * @return the found skeleton or null if not found at all.
  99061. */
  99062. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99063. /**
  99064. * Gets a skeleton using a given auto generated unique id
  99065. * @param uniqueId defines the unique id to search for
  99066. * @return the found skeleton or null if not found at all.
  99067. */
  99068. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99069. /**
  99070. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99071. * @param id defines the id to search for
  99072. * @return the found skeleton or null if not found at all.
  99073. */
  99074. getSkeletonById(id: string): Nullable<Skeleton>;
  99075. /**
  99076. * Gets a skeleton using a given name
  99077. * @param name defines the name to search for
  99078. * @return the found skeleton or null if not found at all.
  99079. */
  99080. getSkeletonByName(name: string): Nullable<Skeleton>;
  99081. /**
  99082. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99083. * @param id defines the id to search for
  99084. * @return the found morph target manager or null if not found at all.
  99085. */
  99086. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99087. /**
  99088. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99089. * @param id defines the id to search for
  99090. * @return the found morph target or null if not found at all.
  99091. */
  99092. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99093. /**
  99094. * Gets a boolean indicating if the given mesh is active
  99095. * @param mesh defines the mesh to look for
  99096. * @returns true if the mesh is in the active list
  99097. */
  99098. isActiveMesh(mesh: AbstractMesh): boolean;
  99099. /**
  99100. * Return a unique id as a string which can serve as an identifier for the scene
  99101. */
  99102. readonly uid: string;
  99103. /**
  99104. * Add an externaly attached data from its key.
  99105. * This method call will fail and return false, if such key already exists.
  99106. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99107. * @param key the unique key that identifies the data
  99108. * @param data the data object to associate to the key for this Engine instance
  99109. * @return true if no such key were already present and the data was added successfully, false otherwise
  99110. */
  99111. addExternalData<T>(key: string, data: T): boolean;
  99112. /**
  99113. * Get an externaly attached data from its key
  99114. * @param key the unique key that identifies the data
  99115. * @return the associated data, if present (can be null), or undefined if not present
  99116. */
  99117. getExternalData<T>(key: string): Nullable<T>;
  99118. /**
  99119. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99120. * @param key the unique key that identifies the data
  99121. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99122. * @return the associated data, can be null if the factory returned null.
  99123. */
  99124. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99125. /**
  99126. * Remove an externaly attached data from the Engine instance
  99127. * @param key the unique key that identifies the data
  99128. * @return true if the data was successfully removed, false if it doesn't exist
  99129. */
  99130. removeExternalData(key: string): boolean;
  99131. private _evaluateSubMesh;
  99132. /**
  99133. * Clear the processed materials smart array preventing retention point in material dispose.
  99134. */
  99135. freeProcessedMaterials(): void;
  99136. private _preventFreeActiveMeshesAndRenderingGroups;
  99137. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99138. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99139. * when disposing several meshes in a row or a hierarchy of meshes.
  99140. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99141. */
  99142. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99143. /**
  99144. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99145. */
  99146. freeActiveMeshes(): void;
  99147. /**
  99148. * Clear the info related to rendering groups preventing retention points during dispose.
  99149. */
  99150. freeRenderingGroups(): void;
  99151. /** @hidden */
  99152. _isInIntermediateRendering(): boolean;
  99153. /**
  99154. * Lambda returning the list of potentially active meshes.
  99155. */
  99156. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99157. /**
  99158. * Lambda returning the list of potentially active sub meshes.
  99159. */
  99160. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99161. /**
  99162. * Lambda returning the list of potentially intersecting sub meshes.
  99163. */
  99164. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99165. /**
  99166. * Lambda returning the list of potentially colliding sub meshes.
  99167. */
  99168. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99169. private _activeMeshesFrozen;
  99170. /**
  99171. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99172. * @returns the current scene
  99173. */
  99174. freezeActiveMeshes(): Scene;
  99175. /**
  99176. * Use this function to restart evaluating active meshes on every frame
  99177. * @returns the current scene
  99178. */
  99179. unfreezeActiveMeshes(): Scene;
  99180. private _evaluateActiveMeshes;
  99181. private _activeMesh;
  99182. /**
  99183. * Update the transform matrix to update from the current active camera
  99184. * @param force defines a boolean used to force the update even if cache is up to date
  99185. */
  99186. updateTransformMatrix(force?: boolean): void;
  99187. private _bindFrameBuffer;
  99188. /** @hidden */
  99189. _allowPostProcessClearColor: boolean;
  99190. /** @hidden */
  99191. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99192. private _processSubCameras;
  99193. private _checkIntersections;
  99194. /** @hidden */
  99195. _advancePhysicsEngineStep(step: number): void;
  99196. /**
  99197. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99198. */
  99199. getDeterministicFrameTime: () => number;
  99200. /** @hidden */
  99201. _animate(): void;
  99202. /** Execute all animations (for a frame) */
  99203. animate(): void;
  99204. /**
  99205. * Render the scene
  99206. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99207. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99208. */
  99209. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99210. /**
  99211. * Freeze all materials
  99212. * A frozen material will not be updatable but should be faster to render
  99213. */
  99214. freezeMaterials(): void;
  99215. /**
  99216. * Unfreeze all materials
  99217. * A frozen material will not be updatable but should be faster to render
  99218. */
  99219. unfreezeMaterials(): void;
  99220. /**
  99221. * Releases all held ressources
  99222. */
  99223. dispose(): void;
  99224. /**
  99225. * Gets if the scene is already disposed
  99226. */
  99227. readonly isDisposed: boolean;
  99228. /**
  99229. * Call this function to reduce memory footprint of the scene.
  99230. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99231. */
  99232. clearCachedVertexData(): void;
  99233. /**
  99234. * This function will remove the local cached buffer data from texture.
  99235. * It will save memory but will prevent the texture from being rebuilt
  99236. */
  99237. cleanCachedTextureBuffer(): void;
  99238. /**
  99239. * Get the world extend vectors with an optional filter
  99240. *
  99241. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99242. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99243. */
  99244. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99245. min: Vector3;
  99246. max: Vector3;
  99247. };
  99248. /**
  99249. * Creates a ray that can be used to pick in the scene
  99250. * @param x defines the x coordinate of the origin (on-screen)
  99251. * @param y defines the y coordinate of the origin (on-screen)
  99252. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99253. * @param camera defines the camera to use for the picking
  99254. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99255. * @returns a Ray
  99256. */
  99257. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99258. /**
  99259. * Creates a ray that can be used to pick in the scene
  99260. * @param x defines the x coordinate of the origin (on-screen)
  99261. * @param y defines the y coordinate of the origin (on-screen)
  99262. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99263. * @param result defines the ray where to store the picking ray
  99264. * @param camera defines the camera to use for the picking
  99265. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99266. * @returns the current scene
  99267. */
  99268. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99269. /**
  99270. * Creates a ray that can be used to pick in the scene
  99271. * @param x defines the x coordinate of the origin (on-screen)
  99272. * @param y defines the y coordinate of the origin (on-screen)
  99273. * @param camera defines the camera to use for the picking
  99274. * @returns a Ray
  99275. */
  99276. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  99277. /**
  99278. * Creates a ray that can be used to pick in the scene
  99279. * @param x defines the x coordinate of the origin (on-screen)
  99280. * @param y defines the y coordinate of the origin (on-screen)
  99281. * @param result defines the ray where to store the picking ray
  99282. * @param camera defines the camera to use for the picking
  99283. * @returns the current scene
  99284. */
  99285. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99286. /** Launch a ray to try to pick a mesh in the scene
  99287. * @param x position on screen
  99288. * @param y position on screen
  99289. * @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
  99290. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99291. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99292. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99293. * @returns a PickingInfo
  99294. */
  99295. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99296. /** Use the given ray to pick a mesh in the scene
  99297. * @param ray The ray to use to pick meshes
  99298. * @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
  99299. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99300. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99301. * @returns a PickingInfo
  99302. */
  99303. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99304. /**
  99305. * Launch a ray to try to pick a mesh in the scene
  99306. * @param x X position on screen
  99307. * @param y Y position on screen
  99308. * @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
  99309. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99310. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99311. * @returns an array of PickingInfo
  99312. */
  99313. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99314. /**
  99315. * Launch a ray to try to pick a mesh in the scene
  99316. * @param ray Ray to use
  99317. * @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
  99318. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99319. * @returns an array of PickingInfo
  99320. */
  99321. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99322. /**
  99323. * Force the value of meshUnderPointer
  99324. * @param mesh defines the mesh to use
  99325. */
  99326. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99327. /**
  99328. * Gets the mesh under the pointer
  99329. * @returns a Mesh or null if no mesh is under the pointer
  99330. */
  99331. getPointerOverMesh(): Nullable<AbstractMesh>;
  99332. /** @hidden */
  99333. _rebuildGeometries(): void;
  99334. /** @hidden */
  99335. _rebuildTextures(): void;
  99336. private _getByTags;
  99337. /**
  99338. * Get a list of meshes by tags
  99339. * @param tagsQuery defines the tags query to use
  99340. * @param forEach defines a predicate used to filter results
  99341. * @returns an array of Mesh
  99342. */
  99343. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99344. /**
  99345. * Get a list of cameras by tags
  99346. * @param tagsQuery defines the tags query to use
  99347. * @param forEach defines a predicate used to filter results
  99348. * @returns an array of Camera
  99349. */
  99350. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99351. /**
  99352. * Get a list of lights by tags
  99353. * @param tagsQuery defines the tags query to use
  99354. * @param forEach defines a predicate used to filter results
  99355. * @returns an array of Light
  99356. */
  99357. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99358. /**
  99359. * Get a list of materials by tags
  99360. * @param tagsQuery defines the tags query to use
  99361. * @param forEach defines a predicate used to filter results
  99362. * @returns an array of Material
  99363. */
  99364. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99365. /**
  99366. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99367. * This allowed control for front to back rendering or reversly depending of the special needs.
  99368. *
  99369. * @param renderingGroupId The rendering group id corresponding to its index
  99370. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99371. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99372. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99373. */
  99374. 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;
  99375. /**
  99376. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99377. *
  99378. * @param renderingGroupId The rendering group id corresponding to its index
  99379. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99380. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99381. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99382. */
  99383. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99384. /**
  99385. * Gets the current auto clear configuration for one rendering group of the rendering
  99386. * manager.
  99387. * @param index the rendering group index to get the information for
  99388. * @returns The auto clear setup for the requested rendering group
  99389. */
  99390. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99391. private _blockMaterialDirtyMechanism;
  99392. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99393. blockMaterialDirtyMechanism: boolean;
  99394. /**
  99395. * Will flag all materials as dirty to trigger new shader compilation
  99396. * @param flag defines the flag used to specify which material part must be marked as dirty
  99397. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  99398. */
  99399. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99400. /** @hidden */
  99401. _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;
  99402. /** @hidden */
  99403. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99404. }
  99405. }
  99406. declare module BABYLON {
  99407. /**
  99408. * Set of assets to keep when moving a scene into an asset container.
  99409. */
  99410. export class KeepAssets extends AbstractScene {
  99411. }
  99412. /**
  99413. * Container with a set of assets that can be added or removed from a scene.
  99414. */
  99415. export class AssetContainer extends AbstractScene {
  99416. /**
  99417. * The scene the AssetContainer belongs to.
  99418. */
  99419. scene: Scene;
  99420. /**
  99421. * Instantiates an AssetContainer.
  99422. * @param scene The scene the AssetContainer belongs to.
  99423. */
  99424. constructor(scene: Scene);
  99425. /**
  99426. * Adds all the assets from the container to the scene.
  99427. */
  99428. addAllToScene(): void;
  99429. /**
  99430. * Removes all the assets in the container from the scene
  99431. */
  99432. removeAllFromScene(): void;
  99433. /**
  99434. * Disposes all the assets in the container
  99435. */
  99436. dispose(): void;
  99437. private _moveAssets;
  99438. /**
  99439. * Removes all the assets contained in the scene and adds them to the container.
  99440. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99441. */
  99442. moveAllFromScene(keepAssets?: KeepAssets): void;
  99443. /**
  99444. * 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.
  99445. * @returns the root mesh
  99446. */
  99447. createRootMesh(): Mesh;
  99448. }
  99449. }
  99450. declare module BABYLON {
  99451. /**
  99452. * Defines how the parser contract is defined.
  99453. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99454. */
  99455. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99456. /**
  99457. * Defines how the individual parser contract is defined.
  99458. * These parser can parse an individual asset
  99459. */
  99460. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99461. /**
  99462. * Base class of the scene acting as a container for the different elements composing a scene.
  99463. * This class is dynamically extended by the different components of the scene increasing
  99464. * flexibility and reducing coupling
  99465. */
  99466. export abstract class AbstractScene {
  99467. /**
  99468. * Stores the list of available parsers in the application.
  99469. */
  99470. private static _BabylonFileParsers;
  99471. /**
  99472. * Stores the list of available individual parsers in the application.
  99473. */
  99474. private static _IndividualBabylonFileParsers;
  99475. /**
  99476. * Adds a parser in the list of available ones
  99477. * @param name Defines the name of the parser
  99478. * @param parser Defines the parser to add
  99479. */
  99480. static AddParser(name: string, parser: BabylonFileParser): void;
  99481. /**
  99482. * Gets a general parser from the list of avaialble ones
  99483. * @param name Defines the name of the parser
  99484. * @returns the requested parser or null
  99485. */
  99486. static GetParser(name: string): Nullable<BabylonFileParser>;
  99487. /**
  99488. * Adds n individual parser in the list of available ones
  99489. * @param name Defines the name of the parser
  99490. * @param parser Defines the parser to add
  99491. */
  99492. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99493. /**
  99494. * Gets an individual parser from the list of avaialble ones
  99495. * @param name Defines the name of the parser
  99496. * @returns the requested parser or null
  99497. */
  99498. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99499. /**
  99500. * Parser json data and populate both a scene and its associated container object
  99501. * @param jsonData Defines the data to parse
  99502. * @param scene Defines the scene to parse the data for
  99503. * @param container Defines the container attached to the parsing sequence
  99504. * @param rootUrl Defines the root url of the data
  99505. */
  99506. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99507. /**
  99508. * Gets the list of root nodes (ie. nodes with no parent)
  99509. */
  99510. rootNodes: Node[];
  99511. /** All of the cameras added to this scene
  99512. * @see http://doc.babylonjs.com/babylon101/cameras
  99513. */
  99514. cameras: Camera[];
  99515. /**
  99516. * All of the lights added to this scene
  99517. * @see http://doc.babylonjs.com/babylon101/lights
  99518. */
  99519. lights: Light[];
  99520. /**
  99521. * All of the (abstract) meshes added to this scene
  99522. */
  99523. meshes: AbstractMesh[];
  99524. /**
  99525. * The list of skeletons added to the scene
  99526. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99527. */
  99528. skeletons: Skeleton[];
  99529. /**
  99530. * All of the particle systems added to this scene
  99531. * @see http://doc.babylonjs.com/babylon101/particles
  99532. */
  99533. particleSystems: IParticleSystem[];
  99534. /**
  99535. * Gets a list of Animations associated with the scene
  99536. */
  99537. animations: Animation[];
  99538. /**
  99539. * All of the animation groups added to this scene
  99540. * @see http://doc.babylonjs.com/how_to/group
  99541. */
  99542. animationGroups: AnimationGroup[];
  99543. /**
  99544. * All of the multi-materials added to this scene
  99545. * @see http://doc.babylonjs.com/how_to/multi_materials
  99546. */
  99547. multiMaterials: MultiMaterial[];
  99548. /**
  99549. * All of the materials added to this scene
  99550. * In the context of a Scene, it is not supposed to be modified manually.
  99551. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99552. * Note also that the order of the Material wihin the array is not significant and might change.
  99553. * @see http://doc.babylonjs.com/babylon101/materials
  99554. */
  99555. materials: Material[];
  99556. /**
  99557. * The list of morph target managers added to the scene
  99558. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99559. */
  99560. morphTargetManagers: MorphTargetManager[];
  99561. /**
  99562. * The list of geometries used in the scene.
  99563. */
  99564. geometries: Geometry[];
  99565. /**
  99566. * All of the tranform nodes added to this scene
  99567. * In the context of a Scene, it is not supposed to be modified manually.
  99568. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99569. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99570. * @see http://doc.babylonjs.com/how_to/transformnode
  99571. */
  99572. transformNodes: TransformNode[];
  99573. /**
  99574. * ActionManagers available on the scene.
  99575. */
  99576. actionManagers: AbstractActionManager[];
  99577. /**
  99578. * Textures to keep.
  99579. */
  99580. textures: BaseTexture[];
  99581. /**
  99582. * Environment texture for the scene
  99583. */
  99584. environmentTexture: Nullable<BaseTexture>;
  99585. }
  99586. }
  99587. declare module BABYLON {
  99588. /**
  99589. * Interface used to define options for Sound class
  99590. */
  99591. export interface ISoundOptions {
  99592. /**
  99593. * Does the sound autoplay once loaded.
  99594. */
  99595. autoplay?: boolean;
  99596. /**
  99597. * Does the sound loop after it finishes playing once.
  99598. */
  99599. loop?: boolean;
  99600. /**
  99601. * Sound's volume
  99602. */
  99603. volume?: number;
  99604. /**
  99605. * Is it a spatial sound?
  99606. */
  99607. spatialSound?: boolean;
  99608. /**
  99609. * Maximum distance to hear that sound
  99610. */
  99611. maxDistance?: number;
  99612. /**
  99613. * Uses user defined attenuation function
  99614. */
  99615. useCustomAttenuation?: boolean;
  99616. /**
  99617. * Define the roll off factor of spatial sounds.
  99618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99619. */
  99620. rolloffFactor?: number;
  99621. /**
  99622. * Define the reference distance the sound should be heard perfectly.
  99623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99624. */
  99625. refDistance?: number;
  99626. /**
  99627. * Define the distance attenuation model the sound will follow.
  99628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99629. */
  99630. distanceModel?: string;
  99631. /**
  99632. * Defines the playback speed (1 by default)
  99633. */
  99634. playbackRate?: number;
  99635. /**
  99636. * Defines if the sound is from a streaming source
  99637. */
  99638. streaming?: boolean;
  99639. /**
  99640. * Defines an optional length (in seconds) inside the sound file
  99641. */
  99642. length?: number;
  99643. /**
  99644. * Defines an optional offset (in seconds) inside the sound file
  99645. */
  99646. offset?: number;
  99647. /**
  99648. * If true, URLs will not be required to state the audio file codec to use.
  99649. */
  99650. skipCodecCheck?: boolean;
  99651. }
  99652. /**
  99653. * Defines a sound that can be played in the application.
  99654. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99656. */
  99657. export class Sound {
  99658. /**
  99659. * The name of the sound in the scene.
  99660. */
  99661. name: string;
  99662. /**
  99663. * Does the sound autoplay once loaded.
  99664. */
  99665. autoplay: boolean;
  99666. /**
  99667. * Does the sound loop after it finishes playing once.
  99668. */
  99669. loop: boolean;
  99670. /**
  99671. * Does the sound use a custom attenuation curve to simulate the falloff
  99672. * happening when the source gets further away from the camera.
  99673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99674. */
  99675. useCustomAttenuation: boolean;
  99676. /**
  99677. * The sound track id this sound belongs to.
  99678. */
  99679. soundTrackId: number;
  99680. /**
  99681. * Is this sound currently played.
  99682. */
  99683. isPlaying: boolean;
  99684. /**
  99685. * Is this sound currently paused.
  99686. */
  99687. isPaused: boolean;
  99688. /**
  99689. * Does this sound enables spatial sound.
  99690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99691. */
  99692. spatialSound: boolean;
  99693. /**
  99694. * Define the reference distance the sound should be heard perfectly.
  99695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99696. */
  99697. refDistance: number;
  99698. /**
  99699. * Define the roll off factor of spatial sounds.
  99700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99701. */
  99702. rolloffFactor: number;
  99703. /**
  99704. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99706. */
  99707. maxDistance: number;
  99708. /**
  99709. * Define the distance attenuation model the sound will follow.
  99710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99711. */
  99712. distanceModel: string;
  99713. /**
  99714. * @hidden
  99715. * Back Compat
  99716. **/
  99717. onended: () => any;
  99718. /**
  99719. * Observable event when the current playing sound finishes.
  99720. */
  99721. onEndedObservable: Observable<Sound>;
  99722. private _panningModel;
  99723. private _playbackRate;
  99724. private _streaming;
  99725. private _startTime;
  99726. private _startOffset;
  99727. private _position;
  99728. /** @hidden */
  99729. _positionInEmitterSpace: boolean;
  99730. private _localDirection;
  99731. private _volume;
  99732. private _isReadyToPlay;
  99733. private _isDirectional;
  99734. private _readyToPlayCallback;
  99735. private _audioBuffer;
  99736. private _soundSource;
  99737. private _streamingSource;
  99738. private _soundPanner;
  99739. private _soundGain;
  99740. private _inputAudioNode;
  99741. private _outputAudioNode;
  99742. private _coneInnerAngle;
  99743. private _coneOuterAngle;
  99744. private _coneOuterGain;
  99745. private _scene;
  99746. private _connectedTransformNode;
  99747. private _customAttenuationFunction;
  99748. private _registerFunc;
  99749. private _isOutputConnected;
  99750. private _htmlAudioElement;
  99751. private _urlType;
  99752. private _length?;
  99753. private _offset?;
  99754. /** @hidden */
  99755. static _SceneComponentInitialization: (scene: Scene) => void;
  99756. /**
  99757. * Create a sound and attach it to a scene
  99758. * @param name Name of your sound
  99759. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99760. * @param scene defines the scene the sound belongs to
  99761. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99762. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99763. */
  99764. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99765. /**
  99766. * Release the sound and its associated resources
  99767. */
  99768. dispose(): void;
  99769. /**
  99770. * Gets if the sounds is ready to be played or not.
  99771. * @returns true if ready, otherwise false
  99772. */
  99773. isReady(): boolean;
  99774. private _soundLoaded;
  99775. /**
  99776. * Sets the data of the sound from an audiobuffer
  99777. * @param audioBuffer The audioBuffer containing the data
  99778. */
  99779. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99780. /**
  99781. * Updates the current sounds options such as maxdistance, loop...
  99782. * @param options A JSON object containing values named as the object properties
  99783. */
  99784. updateOptions(options: ISoundOptions): void;
  99785. private _createSpatialParameters;
  99786. private _updateSpatialParameters;
  99787. /**
  99788. * Switch the panning model to HRTF:
  99789. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99791. */
  99792. switchPanningModelToHRTF(): void;
  99793. /**
  99794. * Switch the panning model to Equal Power:
  99795. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99797. */
  99798. switchPanningModelToEqualPower(): void;
  99799. private _switchPanningModel;
  99800. /**
  99801. * Connect this sound to a sound track audio node like gain...
  99802. * @param soundTrackAudioNode the sound track audio node to connect to
  99803. */
  99804. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99805. /**
  99806. * Transform this sound into a directional source
  99807. * @param coneInnerAngle Size of the inner cone in degree
  99808. * @param coneOuterAngle Size of the outer cone in degree
  99809. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99810. */
  99811. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99812. /**
  99813. * Gets or sets the inner angle for the directional cone.
  99814. */
  99815. /**
  99816. * Gets or sets the inner angle for the directional cone.
  99817. */
  99818. directionalConeInnerAngle: number;
  99819. /**
  99820. * Gets or sets the outer angle for the directional cone.
  99821. */
  99822. /**
  99823. * Gets or sets the outer angle for the directional cone.
  99824. */
  99825. directionalConeOuterAngle: number;
  99826. /**
  99827. * Sets the position of the emitter if spatial sound is enabled
  99828. * @param newPosition Defines the new posisiton
  99829. */
  99830. setPosition(newPosition: Vector3): void;
  99831. /**
  99832. * Sets the local direction of the emitter if spatial sound is enabled
  99833. * @param newLocalDirection Defines the new local direction
  99834. */
  99835. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99836. private _updateDirection;
  99837. /** @hidden */
  99838. updateDistanceFromListener(): void;
  99839. /**
  99840. * Sets a new custom attenuation function for the sound.
  99841. * @param callback Defines the function used for the attenuation
  99842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99843. */
  99844. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99845. /**
  99846. * Play the sound
  99847. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99848. * @param offset (optional) Start the sound at a specific time in seconds
  99849. * @param length (optional) Sound duration (in seconds)
  99850. */
  99851. play(time?: number, offset?: number, length?: number): void;
  99852. private _onended;
  99853. /**
  99854. * Stop the sound
  99855. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99856. */
  99857. stop(time?: number): void;
  99858. /**
  99859. * Put the sound in pause
  99860. */
  99861. pause(): void;
  99862. /**
  99863. * Sets a dedicated volume for this sounds
  99864. * @param newVolume Define the new volume of the sound
  99865. * @param time Define time for gradual change to new volume
  99866. */
  99867. setVolume(newVolume: number, time?: number): void;
  99868. /**
  99869. * Set the sound play back rate
  99870. * @param newPlaybackRate Define the playback rate the sound should be played at
  99871. */
  99872. setPlaybackRate(newPlaybackRate: number): void;
  99873. /**
  99874. * Gets the volume of the sound.
  99875. * @returns the volume of the sound
  99876. */
  99877. getVolume(): number;
  99878. /**
  99879. * Attach the sound to a dedicated mesh
  99880. * @param transformNode The transform node to connect the sound with
  99881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99882. */
  99883. attachToMesh(transformNode: TransformNode): void;
  99884. /**
  99885. * Detach the sound from the previously attached mesh
  99886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99887. */
  99888. detachFromMesh(): void;
  99889. private _onRegisterAfterWorldMatrixUpdate;
  99890. /**
  99891. * Clone the current sound in the scene.
  99892. * @returns the new sound clone
  99893. */
  99894. clone(): Nullable<Sound>;
  99895. /**
  99896. * Gets the current underlying audio buffer containing the data
  99897. * @returns the audio buffer
  99898. */
  99899. getAudioBuffer(): Nullable<AudioBuffer>;
  99900. /**
  99901. * Serializes the Sound in a JSON representation
  99902. * @returns the JSON representation of the sound
  99903. */
  99904. serialize(): any;
  99905. /**
  99906. * Parse a JSON representation of a sound to innstantiate in a given scene
  99907. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99908. * @param scene Define the scene the new parsed sound should be created in
  99909. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99910. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99911. * @returns the newly parsed sound
  99912. */
  99913. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99914. }
  99915. }
  99916. declare module BABYLON {
  99917. /**
  99918. * This defines an action helpful to play a defined sound on a triggered action.
  99919. */
  99920. export class PlaySoundAction extends Action {
  99921. private _sound;
  99922. /**
  99923. * Instantiate the action
  99924. * @param triggerOptions defines the trigger options
  99925. * @param sound defines the sound to play
  99926. * @param condition defines the trigger related conditions
  99927. */
  99928. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99929. /** @hidden */
  99930. _prepare(): void;
  99931. /**
  99932. * Execute the action and play the sound.
  99933. */
  99934. execute(): void;
  99935. /**
  99936. * Serializes the actions and its related information.
  99937. * @param parent defines the object to serialize in
  99938. * @returns the serialized object
  99939. */
  99940. serialize(parent: any): any;
  99941. }
  99942. /**
  99943. * This defines an action helpful to stop a defined sound on a triggered action.
  99944. */
  99945. export class StopSoundAction extends Action {
  99946. private _sound;
  99947. /**
  99948. * Instantiate the action
  99949. * @param triggerOptions defines the trigger options
  99950. * @param sound defines the sound to stop
  99951. * @param condition defines the trigger related conditions
  99952. */
  99953. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99954. /** @hidden */
  99955. _prepare(): void;
  99956. /**
  99957. * Execute the action and stop the sound.
  99958. */
  99959. execute(): void;
  99960. /**
  99961. * Serializes the actions and its related information.
  99962. * @param parent defines the object to serialize in
  99963. * @returns the serialized object
  99964. */
  99965. serialize(parent: any): any;
  99966. }
  99967. }
  99968. declare module BABYLON {
  99969. /**
  99970. * This defines an action responsible to change the value of a property
  99971. * by interpolating between its current value and the newly set one once triggered.
  99972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99973. */
  99974. export class InterpolateValueAction extends Action {
  99975. /**
  99976. * Defines the path of the property where the value should be interpolated
  99977. */
  99978. propertyPath: string;
  99979. /**
  99980. * Defines the target value at the end of the interpolation.
  99981. */
  99982. value: any;
  99983. /**
  99984. * Defines the time it will take for the property to interpolate to the value.
  99985. */
  99986. duration: number;
  99987. /**
  99988. * Defines if the other scene animations should be stopped when the action has been triggered
  99989. */
  99990. stopOtherAnimations?: boolean;
  99991. /**
  99992. * Defines a callback raised once the interpolation animation has been done.
  99993. */
  99994. onInterpolationDone?: () => void;
  99995. /**
  99996. * Observable triggered once the interpolation animation has been done.
  99997. */
  99998. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99999. private _target;
  100000. private _effectiveTarget;
  100001. private _property;
  100002. /**
  100003. * Instantiate the action
  100004. * @param triggerOptions defines the trigger options
  100005. * @param target defines the object containing the value to interpolate
  100006. * @param propertyPath defines the path to the property in the target object
  100007. * @param value defines the target value at the end of the interpolation
  100008. * @param duration deines the time it will take for the property to interpolate to the value.
  100009. * @param condition defines the trigger related conditions
  100010. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100011. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100012. */
  100013. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100014. /** @hidden */
  100015. _prepare(): void;
  100016. /**
  100017. * Execute the action starts the value interpolation.
  100018. */
  100019. execute(): void;
  100020. /**
  100021. * Serializes the actions and its related information.
  100022. * @param parent defines the object to serialize in
  100023. * @returns the serialized object
  100024. */
  100025. serialize(parent: any): any;
  100026. }
  100027. }
  100028. declare module BABYLON {
  100029. /**
  100030. * Options allowed during the creation of a sound track.
  100031. */
  100032. export interface ISoundTrackOptions {
  100033. /**
  100034. * The volume the sound track should take during creation
  100035. */
  100036. volume?: number;
  100037. /**
  100038. * Define if the sound track is the main sound track of the scene
  100039. */
  100040. mainTrack?: boolean;
  100041. }
  100042. /**
  100043. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100044. * It will be also used in a future release to apply effects on a specific track.
  100045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100046. */
  100047. export class SoundTrack {
  100048. /**
  100049. * The unique identifier of the sound track in the scene.
  100050. */
  100051. id: number;
  100052. /**
  100053. * The list of sounds included in the sound track.
  100054. */
  100055. soundCollection: Array<Sound>;
  100056. private _outputAudioNode;
  100057. private _scene;
  100058. private _isMainTrack;
  100059. private _connectedAnalyser;
  100060. private _options;
  100061. private _isInitialized;
  100062. /**
  100063. * Creates a new sound track.
  100064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100065. * @param scene Define the scene the sound track belongs to
  100066. * @param options
  100067. */
  100068. constructor(scene: Scene, options?: ISoundTrackOptions);
  100069. private _initializeSoundTrackAudioGraph;
  100070. /**
  100071. * Release the sound track and its associated resources
  100072. */
  100073. dispose(): void;
  100074. /**
  100075. * Adds a sound to this sound track
  100076. * @param sound define the cound to add
  100077. * @ignoreNaming
  100078. */
  100079. AddSound(sound: Sound): void;
  100080. /**
  100081. * Removes a sound to this sound track
  100082. * @param sound define the cound to remove
  100083. * @ignoreNaming
  100084. */
  100085. RemoveSound(sound: Sound): void;
  100086. /**
  100087. * Set a global volume for the full sound track.
  100088. * @param newVolume Define the new volume of the sound track
  100089. */
  100090. setVolume(newVolume: number): void;
  100091. /**
  100092. * Switch the panning model to HRTF:
  100093. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100095. */
  100096. switchPanningModelToHRTF(): void;
  100097. /**
  100098. * Switch the panning model to Equal Power:
  100099. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100101. */
  100102. switchPanningModelToEqualPower(): void;
  100103. /**
  100104. * Connect the sound track to an audio analyser allowing some amazing
  100105. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100107. * @param analyser The analyser to connect to the engine
  100108. */
  100109. connectToAnalyser(analyser: Analyser): void;
  100110. }
  100111. }
  100112. declare module BABYLON {
  100113. interface AbstractScene {
  100114. /**
  100115. * The list of sounds used in the scene.
  100116. */
  100117. sounds: Nullable<Array<Sound>>;
  100118. }
  100119. interface Scene {
  100120. /**
  100121. * @hidden
  100122. * Backing field
  100123. */
  100124. _mainSoundTrack: SoundTrack;
  100125. /**
  100126. * The main sound track played by the scene.
  100127. * It cotains your primary collection of sounds.
  100128. */
  100129. mainSoundTrack: SoundTrack;
  100130. /**
  100131. * The list of sound tracks added to the scene
  100132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100133. */
  100134. soundTracks: Nullable<Array<SoundTrack>>;
  100135. /**
  100136. * Gets a sound using a given name
  100137. * @param name defines the name to search for
  100138. * @return the found sound or null if not found at all.
  100139. */
  100140. getSoundByName(name: string): Nullable<Sound>;
  100141. /**
  100142. * Gets or sets if audio support is enabled
  100143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100144. */
  100145. audioEnabled: boolean;
  100146. /**
  100147. * Gets or sets if audio will be output to headphones
  100148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100149. */
  100150. headphone: boolean;
  100151. /**
  100152. * Gets or sets custom audio listener position provider
  100153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100154. */
  100155. audioListenerPositionProvider: Nullable<() => Vector3>;
  100156. }
  100157. /**
  100158. * Defines the sound scene component responsible to manage any sounds
  100159. * in a given scene.
  100160. */
  100161. export class AudioSceneComponent implements ISceneSerializableComponent {
  100162. /**
  100163. * The component name helpfull to identify the component in the list of scene components.
  100164. */
  100165. readonly name: string;
  100166. /**
  100167. * The scene the component belongs to.
  100168. */
  100169. scene: Scene;
  100170. private _audioEnabled;
  100171. /**
  100172. * Gets whether audio is enabled or not.
  100173. * Please use related enable/disable method to switch state.
  100174. */
  100175. readonly audioEnabled: boolean;
  100176. private _headphone;
  100177. /**
  100178. * Gets whether audio is outputing to headphone or not.
  100179. * Please use the according Switch methods to change output.
  100180. */
  100181. readonly headphone: boolean;
  100182. private _audioListenerPositionProvider;
  100183. /**
  100184. * Gets the current audio listener position provider
  100185. */
  100186. /**
  100187. * Sets a custom listener position for all sounds in the scene
  100188. * By default, this is the position of the first active camera
  100189. */
  100190. audioListenerPositionProvider: Nullable<() => Vector3>;
  100191. /**
  100192. * Creates a new instance of the component for the given scene
  100193. * @param scene Defines the scene to register the component in
  100194. */
  100195. constructor(scene: Scene);
  100196. /**
  100197. * Registers the component in a given scene
  100198. */
  100199. register(): void;
  100200. /**
  100201. * Rebuilds the elements related to this component in case of
  100202. * context lost for instance.
  100203. */
  100204. rebuild(): void;
  100205. /**
  100206. * Serializes the component data to the specified json object
  100207. * @param serializationObject The object to serialize to
  100208. */
  100209. serialize(serializationObject: any): void;
  100210. /**
  100211. * Adds all the elements from the container to the scene
  100212. * @param container the container holding the elements
  100213. */
  100214. addFromContainer(container: AbstractScene): void;
  100215. /**
  100216. * Removes all the elements in the container from the scene
  100217. * @param container contains the elements to remove
  100218. * @param dispose if the removed element should be disposed (default: false)
  100219. */
  100220. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100221. /**
  100222. * Disposes the component and the associated ressources.
  100223. */
  100224. dispose(): void;
  100225. /**
  100226. * Disables audio in the associated scene.
  100227. */
  100228. disableAudio(): void;
  100229. /**
  100230. * Enables audio in the associated scene.
  100231. */
  100232. enableAudio(): void;
  100233. /**
  100234. * Switch audio to headphone output.
  100235. */
  100236. switchAudioModeForHeadphones(): void;
  100237. /**
  100238. * Switch audio to normal speakers.
  100239. */
  100240. switchAudioModeForNormalSpeakers(): void;
  100241. private _afterRender;
  100242. }
  100243. }
  100244. declare module BABYLON {
  100245. /**
  100246. * Wraps one or more Sound objects and selects one with random weight for playback.
  100247. */
  100248. export class WeightedSound {
  100249. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100250. loop: boolean;
  100251. private _coneInnerAngle;
  100252. private _coneOuterAngle;
  100253. private _volume;
  100254. /** A Sound is currently playing. */
  100255. isPlaying: boolean;
  100256. /** A Sound is currently paused. */
  100257. isPaused: boolean;
  100258. private _sounds;
  100259. private _weights;
  100260. private _currentIndex?;
  100261. /**
  100262. * Creates a new WeightedSound from the list of sounds given.
  100263. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100264. * @param sounds Array of Sounds that will be selected from.
  100265. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100266. */
  100267. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100268. /**
  100269. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100270. */
  100271. /**
  100272. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100273. */
  100274. directionalConeInnerAngle: number;
  100275. /**
  100276. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100277. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100278. */
  100279. /**
  100280. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100281. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100282. */
  100283. directionalConeOuterAngle: number;
  100284. /**
  100285. * Playback volume.
  100286. */
  100287. /**
  100288. * Playback volume.
  100289. */
  100290. volume: number;
  100291. private _onended;
  100292. /**
  100293. * Suspend playback
  100294. */
  100295. pause(): void;
  100296. /**
  100297. * Stop playback
  100298. */
  100299. stop(): void;
  100300. /**
  100301. * Start playback.
  100302. * @param startOffset Position the clip head at a specific time in seconds.
  100303. */
  100304. play(startOffset?: number): void;
  100305. }
  100306. }
  100307. declare module BABYLON {
  100308. /**
  100309. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100311. */
  100312. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100313. /**
  100314. * Gets the name of the behavior.
  100315. */
  100316. readonly name: string;
  100317. /**
  100318. * The easing function used by animations
  100319. */
  100320. static EasingFunction: BackEase;
  100321. /**
  100322. * The easing mode used by animations
  100323. */
  100324. static EasingMode: number;
  100325. /**
  100326. * The duration of the animation, in milliseconds
  100327. */
  100328. transitionDuration: number;
  100329. /**
  100330. * Length of the distance animated by the transition when lower radius is reached
  100331. */
  100332. lowerRadiusTransitionRange: number;
  100333. /**
  100334. * Length of the distance animated by the transition when upper radius is reached
  100335. */
  100336. upperRadiusTransitionRange: number;
  100337. private _autoTransitionRange;
  100338. /**
  100339. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100340. */
  100341. /**
  100342. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100343. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100344. */
  100345. autoTransitionRange: boolean;
  100346. private _attachedCamera;
  100347. private _onAfterCheckInputsObserver;
  100348. private _onMeshTargetChangedObserver;
  100349. /**
  100350. * Initializes the behavior.
  100351. */
  100352. init(): void;
  100353. /**
  100354. * Attaches the behavior to its arc rotate camera.
  100355. * @param camera Defines the camera to attach the behavior to
  100356. */
  100357. attach(camera: ArcRotateCamera): void;
  100358. /**
  100359. * Detaches the behavior from its current arc rotate camera.
  100360. */
  100361. detach(): void;
  100362. private _radiusIsAnimating;
  100363. private _radiusBounceTransition;
  100364. private _animatables;
  100365. private _cachedWheelPrecision;
  100366. /**
  100367. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100368. * @param radiusLimit The limit to check against.
  100369. * @return Bool to indicate if at limit.
  100370. */
  100371. private _isRadiusAtLimit;
  100372. /**
  100373. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100374. * @param radiusDelta The delta by which to animate to. Can be negative.
  100375. */
  100376. private _applyBoundRadiusAnimation;
  100377. /**
  100378. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100379. */
  100380. protected _clearAnimationLocks(): void;
  100381. /**
  100382. * Stops and removes all animations that have been applied to the camera
  100383. */
  100384. stopAllAnimations(): void;
  100385. }
  100386. }
  100387. declare module BABYLON {
  100388. /**
  100389. * 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.
  100390. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100391. */
  100392. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100393. /**
  100394. * Gets the name of the behavior.
  100395. */
  100396. readonly name: string;
  100397. private _mode;
  100398. private _radiusScale;
  100399. private _positionScale;
  100400. private _defaultElevation;
  100401. private _elevationReturnTime;
  100402. private _elevationReturnWaitTime;
  100403. private _zoomStopsAnimation;
  100404. private _framingTime;
  100405. /**
  100406. * The easing function used by animations
  100407. */
  100408. static EasingFunction: ExponentialEase;
  100409. /**
  100410. * The easing mode used by animations
  100411. */
  100412. static EasingMode: number;
  100413. /**
  100414. * Sets the current mode used by the behavior
  100415. */
  100416. /**
  100417. * Gets current mode used by the behavior.
  100418. */
  100419. mode: number;
  100420. /**
  100421. * Sets the scale applied to the radius (1 by default)
  100422. */
  100423. /**
  100424. * Gets the scale applied to the radius
  100425. */
  100426. radiusScale: number;
  100427. /**
  100428. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100429. */
  100430. /**
  100431. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100432. */
  100433. positionScale: number;
  100434. /**
  100435. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100436. * behaviour is triggered, in radians.
  100437. */
  100438. /**
  100439. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100440. * behaviour is triggered, in radians.
  100441. */
  100442. defaultElevation: number;
  100443. /**
  100444. * Sets the time (in milliseconds) taken to return to the default beta position.
  100445. * Negative value indicates camera should not return to default.
  100446. */
  100447. /**
  100448. * Gets the time (in milliseconds) taken to return to the default beta position.
  100449. * Negative value indicates camera should not return to default.
  100450. */
  100451. elevationReturnTime: number;
  100452. /**
  100453. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100454. */
  100455. /**
  100456. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100457. */
  100458. elevationReturnWaitTime: number;
  100459. /**
  100460. * Sets the flag that indicates if user zooming should stop animation.
  100461. */
  100462. /**
  100463. * Gets the flag that indicates if user zooming should stop animation.
  100464. */
  100465. zoomStopsAnimation: boolean;
  100466. /**
  100467. * Sets the transition time when framing the mesh, in milliseconds
  100468. */
  100469. /**
  100470. * Gets the transition time when framing the mesh, in milliseconds
  100471. */
  100472. framingTime: number;
  100473. /**
  100474. * Define if the behavior should automatically change the configured
  100475. * camera limits and sensibilities.
  100476. */
  100477. autoCorrectCameraLimitsAndSensibility: boolean;
  100478. private _onPrePointerObservableObserver;
  100479. private _onAfterCheckInputsObserver;
  100480. private _onMeshTargetChangedObserver;
  100481. private _attachedCamera;
  100482. private _isPointerDown;
  100483. private _lastInteractionTime;
  100484. /**
  100485. * Initializes the behavior.
  100486. */
  100487. init(): void;
  100488. /**
  100489. * Attaches the behavior to its arc rotate camera.
  100490. * @param camera Defines the camera to attach the behavior to
  100491. */
  100492. attach(camera: ArcRotateCamera): void;
  100493. /**
  100494. * Detaches the behavior from its current arc rotate camera.
  100495. */
  100496. detach(): void;
  100497. private _animatables;
  100498. private _betaIsAnimating;
  100499. private _betaTransition;
  100500. private _radiusTransition;
  100501. private _vectorTransition;
  100502. /**
  100503. * Targets the given mesh and updates zoom level accordingly.
  100504. * @param mesh The mesh to target.
  100505. * @param radius Optional. If a cached radius position already exists, overrides default.
  100506. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100507. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100508. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100509. */
  100510. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100511. /**
  100512. * Targets the given mesh with its children and updates zoom level accordingly.
  100513. * @param mesh The mesh to target.
  100514. * @param radius Optional. If a cached radius position already exists, overrides default.
  100515. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100516. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100517. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100518. */
  100519. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100520. /**
  100521. * Targets the given meshes with their children and updates zoom level accordingly.
  100522. * @param meshes The mesh to target.
  100523. * @param radius Optional. If a cached radius position already exists, overrides default.
  100524. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100525. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100526. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100527. */
  100528. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100529. /**
  100530. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100531. * @param minimumWorld Determines the smaller position of the bounding box extend
  100532. * @param maximumWorld Determines the bigger position of the bounding box extend
  100533. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100534. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100535. */
  100536. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100537. /**
  100538. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100539. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100540. * frustum width.
  100541. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100542. * to fully enclose the mesh in the viewing frustum.
  100543. */
  100544. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100545. /**
  100546. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100547. * is automatically returned to its default position (expected to be above ground plane).
  100548. */
  100549. private _maintainCameraAboveGround;
  100550. /**
  100551. * Returns the frustum slope based on the canvas ratio and camera FOV
  100552. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100553. */
  100554. private _getFrustumSlope;
  100555. /**
  100556. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100557. */
  100558. private _clearAnimationLocks;
  100559. /**
  100560. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100561. */
  100562. private _applyUserInteraction;
  100563. /**
  100564. * Stops and removes all animations that have been applied to the camera
  100565. */
  100566. stopAllAnimations(): void;
  100567. /**
  100568. * Gets a value indicating if the user is moving the camera
  100569. */
  100570. readonly isUserIsMoving: boolean;
  100571. /**
  100572. * The camera can move all the way towards the mesh.
  100573. */
  100574. static IgnoreBoundsSizeMode: number;
  100575. /**
  100576. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100577. */
  100578. static FitFrustumSidesMode: number;
  100579. }
  100580. }
  100581. declare module BABYLON {
  100582. /**
  100583. * Base class for Camera Pointer Inputs.
  100584. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100585. * for example usage.
  100586. */
  100587. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100588. /**
  100589. * Defines the camera the input is attached to.
  100590. */
  100591. abstract camera: Camera;
  100592. /**
  100593. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100594. */
  100595. protected _altKey: boolean;
  100596. protected _ctrlKey: boolean;
  100597. protected _metaKey: boolean;
  100598. protected _shiftKey: boolean;
  100599. /**
  100600. * Which mouse buttons were pressed at time of last mouse event.
  100601. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100602. */
  100603. protected _buttonsPressed: number;
  100604. /**
  100605. * Defines the buttons associated with the input to handle camera move.
  100606. */
  100607. buttons: number[];
  100608. /**
  100609. * Attach the input controls to a specific dom element to get the input from.
  100610. * @param element Defines the element the controls should be listened from
  100611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100612. */
  100613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100614. /**
  100615. * Detach the current controls from the specified dom element.
  100616. * @param element Defines the element to stop listening the inputs from
  100617. */
  100618. detachControl(element: Nullable<HTMLElement>): void;
  100619. /**
  100620. * Gets the class name of the current input.
  100621. * @returns the class name
  100622. */
  100623. getClassName(): string;
  100624. /**
  100625. * Get the friendly name associated with the input class.
  100626. * @returns the input friendly name
  100627. */
  100628. getSimpleName(): string;
  100629. /**
  100630. * Called on pointer POINTERDOUBLETAP event.
  100631. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100632. */
  100633. protected onDoubleTap(type: string): void;
  100634. /**
  100635. * Called on pointer POINTERMOVE event if only a single touch is active.
  100636. * Override this method to provide functionality.
  100637. */
  100638. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100639. /**
  100640. * Called on pointer POINTERMOVE event if multiple touches are active.
  100641. * Override this method to provide functionality.
  100642. */
  100643. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100644. /**
  100645. * Called on JS contextmenu event.
  100646. * Override this method to provide functionality.
  100647. */
  100648. protected onContextMenu(evt: PointerEvent): void;
  100649. /**
  100650. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100651. * press.
  100652. * Override this method to provide functionality.
  100653. */
  100654. protected onButtonDown(evt: PointerEvent): void;
  100655. /**
  100656. * Called each time a new POINTERUP event occurs. Ie, for each button
  100657. * release.
  100658. * Override this method to provide functionality.
  100659. */
  100660. protected onButtonUp(evt: PointerEvent): void;
  100661. /**
  100662. * Called when window becomes inactive.
  100663. * Override this method to provide functionality.
  100664. */
  100665. protected onLostFocus(): void;
  100666. private _pointerInput;
  100667. private _observer;
  100668. private _onLostFocus;
  100669. private pointA;
  100670. private pointB;
  100671. }
  100672. }
  100673. declare module BABYLON {
  100674. /**
  100675. * Manage the pointers inputs to control an arc rotate camera.
  100676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100677. */
  100678. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100679. /**
  100680. * Defines the camera the input is attached to.
  100681. */
  100682. camera: ArcRotateCamera;
  100683. /**
  100684. * Gets the class name of the current input.
  100685. * @returns the class name
  100686. */
  100687. getClassName(): string;
  100688. /**
  100689. * Defines the buttons associated with the input to handle camera move.
  100690. */
  100691. buttons: number[];
  100692. /**
  100693. * Defines the pointer angular sensibility along the X axis or how fast is
  100694. * the camera rotating.
  100695. */
  100696. angularSensibilityX: number;
  100697. /**
  100698. * Defines the pointer angular sensibility along the Y axis or how fast is
  100699. * the camera rotating.
  100700. */
  100701. angularSensibilityY: number;
  100702. /**
  100703. * Defines the pointer pinch precision or how fast is the camera zooming.
  100704. */
  100705. pinchPrecision: number;
  100706. /**
  100707. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100708. * from 0.
  100709. * It defines the percentage of current camera.radius to use as delta when
  100710. * pinch zoom is used.
  100711. */
  100712. pinchDeltaPercentage: number;
  100713. /**
  100714. * Defines the pointer panning sensibility or how fast is the camera moving.
  100715. */
  100716. panningSensibility: number;
  100717. /**
  100718. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100719. */
  100720. multiTouchPanning: boolean;
  100721. /**
  100722. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100723. * zoom (pinch) through multitouch.
  100724. */
  100725. multiTouchPanAndZoom: boolean;
  100726. /**
  100727. * Revers pinch action direction.
  100728. */
  100729. pinchInwards: boolean;
  100730. private _isPanClick;
  100731. private _twoFingerActivityCount;
  100732. private _isPinching;
  100733. /**
  100734. * Called on pointer POINTERMOVE event if only a single touch is active.
  100735. */
  100736. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100737. /**
  100738. * Called on pointer POINTERDOUBLETAP event.
  100739. */
  100740. protected onDoubleTap(type: string): void;
  100741. /**
  100742. * Called on pointer POINTERMOVE event if multiple touches are active.
  100743. */
  100744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100745. /**
  100746. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100747. * press.
  100748. */
  100749. protected onButtonDown(evt: PointerEvent): void;
  100750. /**
  100751. * Called each time a new POINTERUP event occurs. Ie, for each button
  100752. * release.
  100753. */
  100754. protected onButtonUp(evt: PointerEvent): void;
  100755. /**
  100756. * Called when window becomes inactive.
  100757. */
  100758. protected onLostFocus(): void;
  100759. }
  100760. }
  100761. declare module BABYLON {
  100762. /**
  100763. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100765. */
  100766. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100767. /**
  100768. * Defines the camera the input is attached to.
  100769. */
  100770. camera: ArcRotateCamera;
  100771. /**
  100772. * Defines the list of key codes associated with the up action (increase alpha)
  100773. */
  100774. keysUp: number[];
  100775. /**
  100776. * Defines the list of key codes associated with the down action (decrease alpha)
  100777. */
  100778. keysDown: number[];
  100779. /**
  100780. * Defines the list of key codes associated with the left action (increase beta)
  100781. */
  100782. keysLeft: number[];
  100783. /**
  100784. * Defines the list of key codes associated with the right action (decrease beta)
  100785. */
  100786. keysRight: number[];
  100787. /**
  100788. * Defines the list of key codes associated with the reset action.
  100789. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100790. */
  100791. keysReset: number[];
  100792. /**
  100793. * Defines the panning sensibility of the inputs.
  100794. * (How fast is the camera paning)
  100795. */
  100796. panningSensibility: number;
  100797. /**
  100798. * Defines the zooming sensibility of the inputs.
  100799. * (How fast is the camera zooming)
  100800. */
  100801. zoomingSensibility: number;
  100802. /**
  100803. * Defines wether maintaining the alt key down switch the movement mode from
  100804. * orientation to zoom.
  100805. */
  100806. useAltToZoom: boolean;
  100807. /**
  100808. * Rotation speed of the camera
  100809. */
  100810. angularSpeed: number;
  100811. private _keys;
  100812. private _ctrlPressed;
  100813. private _altPressed;
  100814. private _onCanvasBlurObserver;
  100815. private _onKeyboardObserver;
  100816. private _engine;
  100817. private _scene;
  100818. /**
  100819. * Attach the input controls to a specific dom element to get the input from.
  100820. * @param element Defines the element the controls should be listened from
  100821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100822. */
  100823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100824. /**
  100825. * Detach the current controls from the specified dom element.
  100826. * @param element Defines the element to stop listening the inputs from
  100827. */
  100828. detachControl(element: Nullable<HTMLElement>): void;
  100829. /**
  100830. * Update the current camera state depending on the inputs that have been used this frame.
  100831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100832. */
  100833. checkInputs(): void;
  100834. /**
  100835. * Gets the class name of the current intput.
  100836. * @returns the class name
  100837. */
  100838. getClassName(): string;
  100839. /**
  100840. * Get the friendly name associated with the input class.
  100841. * @returns the input friendly name
  100842. */
  100843. getSimpleName(): string;
  100844. }
  100845. }
  100846. declare module BABYLON {
  100847. /**
  100848. * Manage the mouse wheel inputs to control an arc rotate camera.
  100849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100850. */
  100851. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100852. /**
  100853. * Defines the camera the input is attached to.
  100854. */
  100855. camera: ArcRotateCamera;
  100856. /**
  100857. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100858. */
  100859. wheelPrecision: number;
  100860. /**
  100861. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100862. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100863. */
  100864. wheelDeltaPercentage: number;
  100865. private _wheel;
  100866. private _observer;
  100867. private computeDeltaFromMouseWheelLegacyEvent;
  100868. /**
  100869. * Attach the input controls to a specific dom element to get the input from.
  100870. * @param element Defines the element the controls should be listened from
  100871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100872. */
  100873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100874. /**
  100875. * Detach the current controls from the specified dom element.
  100876. * @param element Defines the element to stop listening the inputs from
  100877. */
  100878. detachControl(element: Nullable<HTMLElement>): void;
  100879. /**
  100880. * Gets the class name of the current intput.
  100881. * @returns the class name
  100882. */
  100883. getClassName(): string;
  100884. /**
  100885. * Get the friendly name associated with the input class.
  100886. * @returns the input friendly name
  100887. */
  100888. getSimpleName(): string;
  100889. }
  100890. }
  100891. declare module BABYLON {
  100892. /**
  100893. * Default Inputs manager for the ArcRotateCamera.
  100894. * It groups all the default supported inputs for ease of use.
  100895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100896. */
  100897. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100898. /**
  100899. * Instantiates a new ArcRotateCameraInputsManager.
  100900. * @param camera Defines the camera the inputs belong to
  100901. */
  100902. constructor(camera: ArcRotateCamera);
  100903. /**
  100904. * Add mouse wheel input support to the input manager.
  100905. * @returns the current input manager
  100906. */
  100907. addMouseWheel(): ArcRotateCameraInputsManager;
  100908. /**
  100909. * Add pointers input support to the input manager.
  100910. * @returns the current input manager
  100911. */
  100912. addPointers(): ArcRotateCameraInputsManager;
  100913. /**
  100914. * Add keyboard input support to the input manager.
  100915. * @returns the current input manager
  100916. */
  100917. addKeyboard(): ArcRotateCameraInputsManager;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /**
  100922. * This represents an orbital type of camera.
  100923. *
  100924. * 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.
  100925. * 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.
  100926. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100927. */
  100928. export class ArcRotateCamera extends TargetCamera {
  100929. /**
  100930. * Defines the rotation angle of the camera along the longitudinal axis.
  100931. */
  100932. alpha: number;
  100933. /**
  100934. * Defines the rotation angle of the camera along the latitudinal axis.
  100935. */
  100936. beta: number;
  100937. /**
  100938. * Defines the radius of the camera from it s target point.
  100939. */
  100940. radius: number;
  100941. protected _target: Vector3;
  100942. protected _targetHost: Nullable<AbstractMesh>;
  100943. /**
  100944. * Defines the target point of the camera.
  100945. * The camera looks towards it form the radius distance.
  100946. */
  100947. target: Vector3;
  100948. /**
  100949. * Define the current local position of the camera in the scene
  100950. */
  100951. position: Vector3;
  100952. protected _upVector: Vector3;
  100953. protected _upToYMatrix: Matrix;
  100954. protected _YToUpMatrix: Matrix;
  100955. /**
  100956. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100957. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100958. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100959. */
  100960. upVector: Vector3;
  100961. /**
  100962. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100963. */
  100964. setMatUp(): void;
  100965. /**
  100966. * Current inertia value on the longitudinal axis.
  100967. * The bigger this number the longer it will take for the camera to stop.
  100968. */
  100969. inertialAlphaOffset: number;
  100970. /**
  100971. * Current inertia value on the latitudinal axis.
  100972. * The bigger this number the longer it will take for the camera to stop.
  100973. */
  100974. inertialBetaOffset: number;
  100975. /**
  100976. * Current inertia value on the radius axis.
  100977. * The bigger this number the longer it will take for the camera to stop.
  100978. */
  100979. inertialRadiusOffset: number;
  100980. /**
  100981. * Minimum allowed angle on the longitudinal axis.
  100982. * This can help limiting how the Camera is able to move in the scene.
  100983. */
  100984. lowerAlphaLimit: Nullable<number>;
  100985. /**
  100986. * Maximum allowed angle on the longitudinal axis.
  100987. * This can help limiting how the Camera is able to move in the scene.
  100988. */
  100989. upperAlphaLimit: Nullable<number>;
  100990. /**
  100991. * Minimum allowed angle on the latitudinal axis.
  100992. * This can help limiting how the Camera is able to move in the scene.
  100993. */
  100994. lowerBetaLimit: number;
  100995. /**
  100996. * Maximum allowed angle on the latitudinal axis.
  100997. * This can help limiting how the Camera is able to move in the scene.
  100998. */
  100999. upperBetaLimit: number;
  101000. /**
  101001. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101002. * This can help limiting how the Camera is able to move in the scene.
  101003. */
  101004. lowerRadiusLimit: Nullable<number>;
  101005. /**
  101006. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101007. * This can help limiting how the Camera is able to move in the scene.
  101008. */
  101009. upperRadiusLimit: Nullable<number>;
  101010. /**
  101011. * Defines the current inertia value used during panning of the camera along the X axis.
  101012. */
  101013. inertialPanningX: number;
  101014. /**
  101015. * Defines the current inertia value used during panning of the camera along the Y axis.
  101016. */
  101017. inertialPanningY: number;
  101018. /**
  101019. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101020. * Basically if your fingers moves away from more than this distance you will be considered
  101021. * in pinch mode.
  101022. */
  101023. pinchToPanMaxDistance: number;
  101024. /**
  101025. * Defines the maximum distance the camera can pan.
  101026. * This could help keeping the cammera always in your scene.
  101027. */
  101028. panningDistanceLimit: Nullable<number>;
  101029. /**
  101030. * Defines the target of the camera before paning.
  101031. */
  101032. panningOriginTarget: Vector3;
  101033. /**
  101034. * Defines the value of the inertia used during panning.
  101035. * 0 would mean stop inertia and one would mean no decelleration at all.
  101036. */
  101037. panningInertia: number;
  101038. /**
  101039. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101040. */
  101041. angularSensibilityX: number;
  101042. /**
  101043. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101044. */
  101045. angularSensibilityY: number;
  101046. /**
  101047. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101048. */
  101049. pinchPrecision: number;
  101050. /**
  101051. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101052. * It will be used instead of pinchDeltaPrecision if different from 0.
  101053. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101054. */
  101055. pinchDeltaPercentage: number;
  101056. /**
  101057. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101058. */
  101059. panningSensibility: number;
  101060. /**
  101061. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101062. */
  101063. keysUp: number[];
  101064. /**
  101065. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101066. */
  101067. keysDown: number[];
  101068. /**
  101069. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101070. */
  101071. keysLeft: number[];
  101072. /**
  101073. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101074. */
  101075. keysRight: number[];
  101076. /**
  101077. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101078. */
  101079. wheelPrecision: number;
  101080. /**
  101081. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101082. * It will be used instead of pinchDeltaPrecision if different from 0.
  101083. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101084. */
  101085. wheelDeltaPercentage: number;
  101086. /**
  101087. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101088. */
  101089. zoomOnFactor: number;
  101090. /**
  101091. * Defines a screen offset for the camera position.
  101092. */
  101093. targetScreenOffset: Vector2;
  101094. /**
  101095. * Allows the camera to be completely reversed.
  101096. * If false the camera can not arrive upside down.
  101097. */
  101098. allowUpsideDown: boolean;
  101099. /**
  101100. * Define if double tap/click is used to restore the previously saved state of the camera.
  101101. */
  101102. useInputToRestoreState: boolean;
  101103. /** @hidden */
  101104. _viewMatrix: Matrix;
  101105. /** @hidden */
  101106. _useCtrlForPanning: boolean;
  101107. /** @hidden */
  101108. _panningMouseButton: number;
  101109. /**
  101110. * Defines the input associated to the camera.
  101111. */
  101112. inputs: ArcRotateCameraInputsManager;
  101113. /** @hidden */
  101114. _reset: () => void;
  101115. /**
  101116. * Defines the allowed panning axis.
  101117. */
  101118. panningAxis: Vector3;
  101119. protected _localDirection: Vector3;
  101120. protected _transformedDirection: Vector3;
  101121. private _bouncingBehavior;
  101122. /**
  101123. * Gets the bouncing behavior of the camera if it has been enabled.
  101124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101125. */
  101126. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101127. /**
  101128. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101130. */
  101131. useBouncingBehavior: boolean;
  101132. private _framingBehavior;
  101133. /**
  101134. * Gets the framing behavior of the camera if it has been enabled.
  101135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101136. */
  101137. readonly framingBehavior: Nullable<FramingBehavior>;
  101138. /**
  101139. * Defines if the framing behavior of the camera is enabled on the camera.
  101140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101141. */
  101142. useFramingBehavior: boolean;
  101143. private _autoRotationBehavior;
  101144. /**
  101145. * Gets the auto rotation behavior of the camera if it has been enabled.
  101146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101147. */
  101148. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101149. /**
  101150. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101151. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101152. */
  101153. useAutoRotationBehavior: boolean;
  101154. /**
  101155. * Observable triggered when the mesh target has been changed on the camera.
  101156. */
  101157. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101158. /**
  101159. * Event raised when the camera is colliding with a mesh.
  101160. */
  101161. onCollide: (collidedMesh: AbstractMesh) => void;
  101162. /**
  101163. * Defines whether the camera should check collision with the objects oh the scene.
  101164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101165. */
  101166. checkCollisions: boolean;
  101167. /**
  101168. * Defines the collision radius of the camera.
  101169. * This simulates a sphere around the camera.
  101170. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101171. */
  101172. collisionRadius: Vector3;
  101173. protected _collider: Collider;
  101174. protected _previousPosition: Vector3;
  101175. protected _collisionVelocity: Vector3;
  101176. protected _newPosition: Vector3;
  101177. protected _previousAlpha: number;
  101178. protected _previousBeta: number;
  101179. protected _previousRadius: number;
  101180. protected _collisionTriggered: boolean;
  101181. protected _targetBoundingCenter: Nullable<Vector3>;
  101182. private _computationVector;
  101183. /**
  101184. * Instantiates a new ArcRotateCamera in a given scene
  101185. * @param name Defines the name of the camera
  101186. * @param alpha Defines the camera rotation along the logitudinal axis
  101187. * @param beta Defines the camera rotation along the latitudinal axis
  101188. * @param radius Defines the camera distance from its target
  101189. * @param target Defines the camera target
  101190. * @param scene Defines the scene the camera belongs to
  101191. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101192. */
  101193. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101194. /** @hidden */
  101195. _initCache(): void;
  101196. /** @hidden */
  101197. _updateCache(ignoreParentClass?: boolean): void;
  101198. protected _getTargetPosition(): Vector3;
  101199. private _storedAlpha;
  101200. private _storedBeta;
  101201. private _storedRadius;
  101202. private _storedTarget;
  101203. /**
  101204. * Stores the current state of the camera (alpha, beta, radius and target)
  101205. * @returns the camera itself
  101206. */
  101207. storeState(): Camera;
  101208. /**
  101209. * @hidden
  101210. * Restored camera state. You must call storeState() first
  101211. */
  101212. _restoreStateValues(): boolean;
  101213. /** @hidden */
  101214. _isSynchronizedViewMatrix(): boolean;
  101215. /**
  101216. * Attached controls to the current camera.
  101217. * @param element Defines the element the controls should be listened from
  101218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101219. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101220. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101221. */
  101222. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101223. /**
  101224. * Detach the current controls from the camera.
  101225. * The camera will stop reacting to inputs.
  101226. * @param element Defines the element to stop listening the inputs from
  101227. */
  101228. detachControl(element: HTMLElement): void;
  101229. /** @hidden */
  101230. _checkInputs(): void;
  101231. protected _checkLimits(): void;
  101232. /**
  101233. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101234. */
  101235. rebuildAnglesAndRadius(): void;
  101236. /**
  101237. * Use a position to define the current camera related information like aplha, beta and radius
  101238. * @param position Defines the position to set the camera at
  101239. */
  101240. setPosition(position: Vector3): void;
  101241. /**
  101242. * Defines the target the camera should look at.
  101243. * This will automatically adapt alpha beta and radius to fit within the new target.
  101244. * @param target Defines the new target as a Vector or a mesh
  101245. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101246. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101247. */
  101248. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101249. /** @hidden */
  101250. _getViewMatrix(): Matrix;
  101251. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101252. /**
  101253. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101254. * @param meshes Defines the mesh to zoom on
  101255. * @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)
  101256. */
  101257. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101258. /**
  101259. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101260. * The target will be changed but the radius
  101261. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101262. * @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)
  101263. */
  101264. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101265. min: Vector3;
  101266. max: Vector3;
  101267. distance: number;
  101268. }, doNotUpdateMaxZ?: boolean): void;
  101269. /**
  101270. * @override
  101271. * Override Camera.createRigCamera
  101272. */
  101273. createRigCamera(name: string, cameraIndex: number): Camera;
  101274. /**
  101275. * @hidden
  101276. * @override
  101277. * Override Camera._updateRigCameras
  101278. */
  101279. _updateRigCameras(): void;
  101280. /**
  101281. * Destroy the camera and release the current resources hold by it.
  101282. */
  101283. dispose(): void;
  101284. /**
  101285. * Gets the current object class name.
  101286. * @return the class name
  101287. */
  101288. getClassName(): string;
  101289. }
  101290. }
  101291. declare module BABYLON {
  101292. /**
  101293. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101295. */
  101296. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101297. /**
  101298. * Gets the name of the behavior.
  101299. */
  101300. readonly name: string;
  101301. private _zoomStopsAnimation;
  101302. private _idleRotationSpeed;
  101303. private _idleRotationWaitTime;
  101304. private _idleRotationSpinupTime;
  101305. /**
  101306. * Sets the flag that indicates if user zooming should stop animation.
  101307. */
  101308. /**
  101309. * Gets the flag that indicates if user zooming should stop animation.
  101310. */
  101311. zoomStopsAnimation: boolean;
  101312. /**
  101313. * Sets the default speed at which the camera rotates around the model.
  101314. */
  101315. /**
  101316. * Gets the default speed at which the camera rotates around the model.
  101317. */
  101318. idleRotationSpeed: number;
  101319. /**
  101320. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101321. */
  101322. /**
  101323. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101324. */
  101325. idleRotationWaitTime: number;
  101326. /**
  101327. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101328. */
  101329. /**
  101330. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101331. */
  101332. idleRotationSpinupTime: number;
  101333. /**
  101334. * Gets a value indicating if the camera is currently rotating because of this behavior
  101335. */
  101336. readonly rotationInProgress: boolean;
  101337. private _onPrePointerObservableObserver;
  101338. private _onAfterCheckInputsObserver;
  101339. private _attachedCamera;
  101340. private _isPointerDown;
  101341. private _lastFrameTime;
  101342. private _lastInteractionTime;
  101343. private _cameraRotationSpeed;
  101344. /**
  101345. * Initializes the behavior.
  101346. */
  101347. init(): void;
  101348. /**
  101349. * Attaches the behavior to its arc rotate camera.
  101350. * @param camera Defines the camera to attach the behavior to
  101351. */
  101352. attach(camera: ArcRotateCamera): void;
  101353. /**
  101354. * Detaches the behavior from its current arc rotate camera.
  101355. */
  101356. detach(): void;
  101357. /**
  101358. * Returns true if user is scrolling.
  101359. * @return true if user is scrolling.
  101360. */
  101361. private _userIsZooming;
  101362. private _lastFrameRadius;
  101363. private _shouldAnimationStopForInteraction;
  101364. /**
  101365. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101366. */
  101367. private _applyUserInteraction;
  101368. private _userIsMoving;
  101369. }
  101370. }
  101371. declare module BABYLON {
  101372. /**
  101373. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101374. */
  101375. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101376. private ui;
  101377. /**
  101378. * The name of the behavior
  101379. */
  101380. name: string;
  101381. /**
  101382. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101383. */
  101384. distanceAwayFromFace: number;
  101385. /**
  101386. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101387. */
  101388. distanceAwayFromBottomOfFace: number;
  101389. private _faceVectors;
  101390. private _target;
  101391. private _scene;
  101392. private _onRenderObserver;
  101393. private _tmpMatrix;
  101394. private _tmpVector;
  101395. /**
  101396. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  101397. * @param ui The transform node that should be attched to the mesh
  101398. */
  101399. constructor(ui: TransformNode);
  101400. /**
  101401. * Initializes the behavior
  101402. */
  101403. init(): void;
  101404. private _closestFace;
  101405. private _zeroVector;
  101406. private _lookAtTmpMatrix;
  101407. private _lookAtToRef;
  101408. /**
  101409. * Attaches the AttachToBoxBehavior to the passed in mesh
  101410. * @param target The mesh that the specified node will be attached to
  101411. */
  101412. attach(target: Mesh): void;
  101413. /**
  101414. * Detaches the behavior from the mesh
  101415. */
  101416. detach(): void;
  101417. }
  101418. }
  101419. declare module BABYLON {
  101420. /**
  101421. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  101422. */
  101423. export class FadeInOutBehavior implements Behavior<Mesh> {
  101424. /**
  101425. * Time in milliseconds to delay before fading in (Default: 0)
  101426. */
  101427. delay: number;
  101428. /**
  101429. * Time in milliseconds for the mesh to fade in (Default: 300)
  101430. */
  101431. fadeInTime: number;
  101432. private _millisecondsPerFrame;
  101433. private _hovered;
  101434. private _hoverValue;
  101435. private _ownerNode;
  101436. /**
  101437. * Instatiates the FadeInOutBehavior
  101438. */
  101439. constructor();
  101440. /**
  101441. * The name of the behavior
  101442. */
  101443. readonly name: string;
  101444. /**
  101445. * Initializes the behavior
  101446. */
  101447. init(): void;
  101448. /**
  101449. * Attaches the fade behavior on the passed in mesh
  101450. * @param ownerNode The mesh that will be faded in/out once attached
  101451. */
  101452. attach(ownerNode: Mesh): void;
  101453. /**
  101454. * Detaches the behavior from the mesh
  101455. */
  101456. detach(): void;
  101457. /**
  101458. * Triggers the mesh to begin fading in or out
  101459. * @param value if the object should fade in or out (true to fade in)
  101460. */
  101461. fadeIn(value: boolean): void;
  101462. private _update;
  101463. private _setAllVisibility;
  101464. }
  101465. }
  101466. declare module BABYLON {
  101467. /**
  101468. * Class containing a set of static utilities functions for managing Pivots
  101469. * @hidden
  101470. */
  101471. export class PivotTools {
  101472. private static _PivotCached;
  101473. private static _OldPivotPoint;
  101474. private static _PivotTranslation;
  101475. private static _PivotTmpVector;
  101476. /** @hidden */
  101477. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101478. /** @hidden */
  101479. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101480. }
  101481. }
  101482. declare module BABYLON {
  101483. /**
  101484. * Class containing static functions to help procedurally build meshes
  101485. */
  101486. export class PlaneBuilder {
  101487. /**
  101488. * Creates a plane mesh
  101489. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101490. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101491. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101495. * @param name defines the name of the mesh
  101496. * @param options defines the options used to create the mesh
  101497. * @param scene defines the hosting scene
  101498. * @returns the plane mesh
  101499. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101500. */
  101501. static CreatePlane(name: string, options: {
  101502. size?: number;
  101503. width?: number;
  101504. height?: number;
  101505. sideOrientation?: number;
  101506. frontUVs?: Vector4;
  101507. backUVs?: Vector4;
  101508. updatable?: boolean;
  101509. sourcePlane?: Plane;
  101510. }, scene?: Nullable<Scene>): Mesh;
  101511. }
  101512. }
  101513. declare module BABYLON {
  101514. /**
  101515. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101516. */
  101517. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101518. private static _AnyMouseID;
  101519. /**
  101520. * Abstract mesh the behavior is set on
  101521. */
  101522. attachedNode: AbstractMesh;
  101523. private _dragPlane;
  101524. private _scene;
  101525. private _pointerObserver;
  101526. private _beforeRenderObserver;
  101527. private static _planeScene;
  101528. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101529. /**
  101530. * 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)
  101531. */
  101532. maxDragAngle: number;
  101533. /**
  101534. * @hidden
  101535. */
  101536. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101537. /**
  101538. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101539. */
  101540. currentDraggingPointerID: number;
  101541. /**
  101542. * The last position where the pointer hit the drag plane in world space
  101543. */
  101544. lastDragPosition: Vector3;
  101545. /**
  101546. * If the behavior is currently in a dragging state
  101547. */
  101548. dragging: boolean;
  101549. /**
  101550. * 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)
  101551. */
  101552. dragDeltaRatio: number;
  101553. /**
  101554. * If the drag plane orientation should be updated during the dragging (Default: true)
  101555. */
  101556. updateDragPlane: boolean;
  101557. private _debugMode;
  101558. private _moving;
  101559. /**
  101560. * Fires each time the attached mesh is dragged with the pointer
  101561. * * delta between last drag position and current drag position in world space
  101562. * * dragDistance along the drag axis
  101563. * * dragPlaneNormal normal of the current drag plane used during the drag
  101564. * * dragPlanePoint in world space where the drag intersects the drag plane
  101565. */
  101566. onDragObservable: Observable<{
  101567. delta: Vector3;
  101568. dragPlanePoint: Vector3;
  101569. dragPlaneNormal: Vector3;
  101570. dragDistance: number;
  101571. pointerId: number;
  101572. }>;
  101573. /**
  101574. * Fires each time a drag begins (eg. mouse down on mesh)
  101575. */
  101576. onDragStartObservable: Observable<{
  101577. dragPlanePoint: Vector3;
  101578. pointerId: number;
  101579. }>;
  101580. /**
  101581. * Fires each time a drag ends (eg. mouse release after drag)
  101582. */
  101583. onDragEndObservable: Observable<{
  101584. dragPlanePoint: Vector3;
  101585. pointerId: number;
  101586. }>;
  101587. /**
  101588. * If the attached mesh should be moved when dragged
  101589. */
  101590. moveAttached: boolean;
  101591. /**
  101592. * If the drag behavior will react to drag events (Default: true)
  101593. */
  101594. enabled: boolean;
  101595. /**
  101596. * If pointer events should start and release the drag (Default: true)
  101597. */
  101598. startAndReleaseDragOnPointerEvents: boolean;
  101599. /**
  101600. * If camera controls should be detached during the drag
  101601. */
  101602. detachCameraControls: boolean;
  101603. /**
  101604. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101605. */
  101606. useObjectOrienationForDragging: boolean;
  101607. private _options;
  101608. /**
  101609. * Creates a pointer drag behavior that can be attached to a mesh
  101610. * @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)
  101611. */
  101612. constructor(options?: {
  101613. dragAxis?: Vector3;
  101614. dragPlaneNormal?: Vector3;
  101615. });
  101616. /**
  101617. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101618. */
  101619. validateDrag: (targetPosition: Vector3) => boolean;
  101620. /**
  101621. * The name of the behavior
  101622. */
  101623. readonly name: string;
  101624. /**
  101625. * Initializes the behavior
  101626. */
  101627. init(): void;
  101628. private _tmpVector;
  101629. private _alternatePickedPoint;
  101630. private _worldDragAxis;
  101631. private _targetPosition;
  101632. private _attachedElement;
  101633. /**
  101634. * Attaches the drag behavior the passed in mesh
  101635. * @param ownerNode The mesh that will be dragged around once attached
  101636. */
  101637. attach(ownerNode: AbstractMesh): void;
  101638. /**
  101639. * Force relase the drag action by code.
  101640. */
  101641. releaseDrag(): void;
  101642. private _startDragRay;
  101643. private _lastPointerRay;
  101644. /**
  101645. * Simulates the start of a pointer drag event on the behavior
  101646. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101647. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101648. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101649. */
  101650. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101651. private _startDrag;
  101652. private _dragDelta;
  101653. private _moveDrag;
  101654. private _pickWithRayOnDragPlane;
  101655. private _pointA;
  101656. private _pointB;
  101657. private _pointC;
  101658. private _lineA;
  101659. private _lineB;
  101660. private _localAxis;
  101661. private _lookAt;
  101662. private _updateDragPlanePosition;
  101663. /**
  101664. * Detaches the behavior from the mesh
  101665. */
  101666. detach(): void;
  101667. }
  101668. }
  101669. declare module BABYLON {
  101670. /**
  101671. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101672. */
  101673. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101674. private _dragBehaviorA;
  101675. private _dragBehaviorB;
  101676. private _startDistance;
  101677. private _initialScale;
  101678. private _targetScale;
  101679. private _ownerNode;
  101680. private _sceneRenderObserver;
  101681. /**
  101682. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101683. */
  101684. constructor();
  101685. /**
  101686. * The name of the behavior
  101687. */
  101688. readonly name: string;
  101689. /**
  101690. * Initializes the behavior
  101691. */
  101692. init(): void;
  101693. private _getCurrentDistance;
  101694. /**
  101695. * Attaches the scale behavior the passed in mesh
  101696. * @param ownerNode The mesh that will be scaled around once attached
  101697. */
  101698. attach(ownerNode: Mesh): void;
  101699. /**
  101700. * Detaches the behavior from the mesh
  101701. */
  101702. detach(): void;
  101703. }
  101704. }
  101705. declare module BABYLON {
  101706. /**
  101707. * 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
  101708. */
  101709. export class SixDofDragBehavior implements Behavior<Mesh> {
  101710. private static _virtualScene;
  101711. private _ownerNode;
  101712. private _sceneRenderObserver;
  101713. private _scene;
  101714. private _targetPosition;
  101715. private _virtualOriginMesh;
  101716. private _virtualDragMesh;
  101717. private _pointerObserver;
  101718. private _moving;
  101719. private _startingOrientation;
  101720. /**
  101721. * 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)
  101722. */
  101723. private zDragFactor;
  101724. /**
  101725. * If the object should rotate to face the drag origin
  101726. */
  101727. rotateDraggedObject: boolean;
  101728. /**
  101729. * If the behavior is currently in a dragging state
  101730. */
  101731. dragging: boolean;
  101732. /**
  101733. * 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)
  101734. */
  101735. dragDeltaRatio: number;
  101736. /**
  101737. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101738. */
  101739. currentDraggingPointerID: number;
  101740. /**
  101741. * If camera controls should be detached during the drag
  101742. */
  101743. detachCameraControls: boolean;
  101744. /**
  101745. * Fires each time a drag starts
  101746. */
  101747. onDragStartObservable: Observable<{}>;
  101748. /**
  101749. * Fires each time a drag ends (eg. mouse release after drag)
  101750. */
  101751. onDragEndObservable: Observable<{}>;
  101752. /**
  101753. * 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
  101754. */
  101755. constructor();
  101756. /**
  101757. * The name of the behavior
  101758. */
  101759. readonly name: string;
  101760. /**
  101761. * Initializes the behavior
  101762. */
  101763. init(): void;
  101764. /**
  101765. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101766. */
  101767. private readonly _pointerCamera;
  101768. /**
  101769. * Attaches the scale behavior the passed in mesh
  101770. * @param ownerNode The mesh that will be scaled around once attached
  101771. */
  101772. attach(ownerNode: Mesh): void;
  101773. /**
  101774. * Detaches the behavior from the mesh
  101775. */
  101776. detach(): void;
  101777. }
  101778. }
  101779. declare module BABYLON {
  101780. /**
  101781. * Class used to apply inverse kinematics to bones
  101782. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101783. */
  101784. export class BoneIKController {
  101785. private static _tmpVecs;
  101786. private static _tmpQuat;
  101787. private static _tmpMats;
  101788. /**
  101789. * Gets or sets the target mesh
  101790. */
  101791. targetMesh: AbstractMesh;
  101792. /** Gets or sets the mesh used as pole */
  101793. poleTargetMesh: AbstractMesh;
  101794. /**
  101795. * Gets or sets the bone used as pole
  101796. */
  101797. poleTargetBone: Nullable<Bone>;
  101798. /**
  101799. * Gets or sets the target position
  101800. */
  101801. targetPosition: Vector3;
  101802. /**
  101803. * Gets or sets the pole target position
  101804. */
  101805. poleTargetPosition: Vector3;
  101806. /**
  101807. * Gets or sets the pole target local offset
  101808. */
  101809. poleTargetLocalOffset: Vector3;
  101810. /**
  101811. * Gets or sets the pole angle
  101812. */
  101813. poleAngle: number;
  101814. /**
  101815. * Gets or sets the mesh associated with the controller
  101816. */
  101817. mesh: AbstractMesh;
  101818. /**
  101819. * 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)
  101820. */
  101821. slerpAmount: number;
  101822. private _bone1Quat;
  101823. private _bone1Mat;
  101824. private _bone2Ang;
  101825. private _bone1;
  101826. private _bone2;
  101827. private _bone1Length;
  101828. private _bone2Length;
  101829. private _maxAngle;
  101830. private _maxReach;
  101831. private _rightHandedSystem;
  101832. private _bendAxis;
  101833. private _slerping;
  101834. private _adjustRoll;
  101835. /**
  101836. * Gets or sets maximum allowed angle
  101837. */
  101838. maxAngle: number;
  101839. /**
  101840. * Creates a new BoneIKController
  101841. * @param mesh defines the mesh to control
  101842. * @param bone defines the bone to control
  101843. * @param options defines options to set up the controller
  101844. */
  101845. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101846. targetMesh?: AbstractMesh;
  101847. poleTargetMesh?: AbstractMesh;
  101848. poleTargetBone?: Bone;
  101849. poleTargetLocalOffset?: Vector3;
  101850. poleAngle?: number;
  101851. bendAxis?: Vector3;
  101852. maxAngle?: number;
  101853. slerpAmount?: number;
  101854. });
  101855. private _setMaxAngle;
  101856. /**
  101857. * Force the controller to update the bones
  101858. */
  101859. update(): void;
  101860. }
  101861. }
  101862. declare module BABYLON {
  101863. /**
  101864. * Class used to make a bone look toward a point in space
  101865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101866. */
  101867. export class BoneLookController {
  101868. private static _tmpVecs;
  101869. private static _tmpQuat;
  101870. private static _tmpMats;
  101871. /**
  101872. * The target Vector3 that the bone will look at
  101873. */
  101874. target: Vector3;
  101875. /**
  101876. * The mesh that the bone is attached to
  101877. */
  101878. mesh: AbstractMesh;
  101879. /**
  101880. * The bone that will be looking to the target
  101881. */
  101882. bone: Bone;
  101883. /**
  101884. * The up axis of the coordinate system that is used when the bone is rotated
  101885. */
  101886. upAxis: Vector3;
  101887. /**
  101888. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101889. */
  101890. upAxisSpace: Space;
  101891. /**
  101892. * Used to make an adjustment to the yaw of the bone
  101893. */
  101894. adjustYaw: number;
  101895. /**
  101896. * Used to make an adjustment to the pitch of the bone
  101897. */
  101898. adjustPitch: number;
  101899. /**
  101900. * Used to make an adjustment to the roll of the bone
  101901. */
  101902. adjustRoll: number;
  101903. /**
  101904. * 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)
  101905. */
  101906. slerpAmount: number;
  101907. private _minYaw;
  101908. private _maxYaw;
  101909. private _minPitch;
  101910. private _maxPitch;
  101911. private _minYawSin;
  101912. private _minYawCos;
  101913. private _maxYawSin;
  101914. private _maxYawCos;
  101915. private _midYawConstraint;
  101916. private _minPitchTan;
  101917. private _maxPitchTan;
  101918. private _boneQuat;
  101919. private _slerping;
  101920. private _transformYawPitch;
  101921. private _transformYawPitchInv;
  101922. private _firstFrameSkipped;
  101923. private _yawRange;
  101924. private _fowardAxis;
  101925. /**
  101926. * Gets or sets the minimum yaw angle that the bone can look to
  101927. */
  101928. minYaw: number;
  101929. /**
  101930. * Gets or sets the maximum yaw angle that the bone can look to
  101931. */
  101932. maxYaw: number;
  101933. /**
  101934. * Gets or sets the minimum pitch angle that the bone can look to
  101935. */
  101936. minPitch: number;
  101937. /**
  101938. * Gets or sets the maximum pitch angle that the bone can look to
  101939. */
  101940. maxPitch: number;
  101941. /**
  101942. * Create a BoneLookController
  101943. * @param mesh the mesh that the bone belongs to
  101944. * @param bone the bone that will be looking to the target
  101945. * @param target the target Vector3 to look at
  101946. * @param options optional settings:
  101947. * * maxYaw: the maximum angle the bone will yaw to
  101948. * * minYaw: the minimum angle the bone will yaw to
  101949. * * maxPitch: the maximum angle the bone will pitch to
  101950. * * minPitch: the minimum angle the bone will yaw to
  101951. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101952. * * upAxis: the up axis of the coordinate system
  101953. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101954. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101955. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101956. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101957. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101958. * * adjustRoll: used to make an adjustment to the roll of the bone
  101959. **/
  101960. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101961. maxYaw?: number;
  101962. minYaw?: number;
  101963. maxPitch?: number;
  101964. minPitch?: number;
  101965. slerpAmount?: number;
  101966. upAxis?: Vector3;
  101967. upAxisSpace?: Space;
  101968. yawAxis?: Vector3;
  101969. pitchAxis?: Vector3;
  101970. adjustYaw?: number;
  101971. adjustPitch?: number;
  101972. adjustRoll?: number;
  101973. });
  101974. /**
  101975. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101976. */
  101977. update(): void;
  101978. private _getAngleDiff;
  101979. private _getAngleBetween;
  101980. private _isAngleBetween;
  101981. }
  101982. }
  101983. declare module BABYLON {
  101984. /**
  101985. * Manage the gamepad inputs to control an arc rotate camera.
  101986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101987. */
  101988. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101989. /**
  101990. * Defines the camera the input is attached to.
  101991. */
  101992. camera: ArcRotateCamera;
  101993. /**
  101994. * Defines the gamepad the input is gathering event from.
  101995. */
  101996. gamepad: Nullable<Gamepad>;
  101997. /**
  101998. * Defines the gamepad rotation sensiblity.
  101999. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102000. */
  102001. gamepadRotationSensibility: number;
  102002. /**
  102003. * Defines the gamepad move sensiblity.
  102004. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102005. */
  102006. gamepadMoveSensibility: number;
  102007. private _onGamepadConnectedObserver;
  102008. private _onGamepadDisconnectedObserver;
  102009. /**
  102010. * Attach the input controls to a specific dom element to get the input from.
  102011. * @param element Defines the element the controls should be listened from
  102012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102013. */
  102014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102015. /**
  102016. * Detach the current controls from the specified dom element.
  102017. * @param element Defines the element to stop listening the inputs from
  102018. */
  102019. detachControl(element: Nullable<HTMLElement>): void;
  102020. /**
  102021. * Update the current camera state depending on the inputs that have been used this frame.
  102022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102023. */
  102024. checkInputs(): void;
  102025. /**
  102026. * Gets the class name of the current intput.
  102027. * @returns the class name
  102028. */
  102029. getClassName(): string;
  102030. /**
  102031. * Get the friendly name associated with the input class.
  102032. * @returns the input friendly name
  102033. */
  102034. getSimpleName(): string;
  102035. }
  102036. }
  102037. declare module BABYLON {
  102038. interface ArcRotateCameraInputsManager {
  102039. /**
  102040. * Add orientation input support to the input manager.
  102041. * @returns the current input manager
  102042. */
  102043. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102044. }
  102045. /**
  102046. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102048. */
  102049. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102050. /**
  102051. * Defines the camera the input is attached to.
  102052. */
  102053. camera: ArcRotateCamera;
  102054. /**
  102055. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102056. */
  102057. alphaCorrection: number;
  102058. /**
  102059. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102060. */
  102061. gammaCorrection: number;
  102062. private _alpha;
  102063. private _gamma;
  102064. private _dirty;
  102065. private _deviceOrientationHandler;
  102066. /**
  102067. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102068. */
  102069. constructor();
  102070. /**
  102071. * Attach the input controls to a specific dom element to get the input from.
  102072. * @param element Defines the element the controls should be listened from
  102073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102074. */
  102075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102076. /** @hidden */
  102077. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102078. /**
  102079. * Update the current camera state depending on the inputs that have been used this frame.
  102080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102081. */
  102082. checkInputs(): void;
  102083. /**
  102084. * Detach the current controls from the specified dom element.
  102085. * @param element Defines the element to stop listening the inputs from
  102086. */
  102087. detachControl(element: Nullable<HTMLElement>): void;
  102088. /**
  102089. * Gets the class name of the current intput.
  102090. * @returns the class name
  102091. */
  102092. getClassName(): string;
  102093. /**
  102094. * Get the friendly name associated with the input class.
  102095. * @returns the input friendly name
  102096. */
  102097. getSimpleName(): string;
  102098. }
  102099. }
  102100. declare module BABYLON {
  102101. /**
  102102. * Listen to mouse events to control the camera.
  102103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102104. */
  102105. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102106. /**
  102107. * Defines the camera the input is attached to.
  102108. */
  102109. camera: FlyCamera;
  102110. /**
  102111. * Defines if touch is enabled. (Default is true.)
  102112. */
  102113. touchEnabled: boolean;
  102114. /**
  102115. * Defines the buttons associated with the input to handle camera rotation.
  102116. */
  102117. buttons: number[];
  102118. /**
  102119. * Assign buttons for Yaw control.
  102120. */
  102121. buttonsYaw: number[];
  102122. /**
  102123. * Assign buttons for Pitch control.
  102124. */
  102125. buttonsPitch: number[];
  102126. /**
  102127. * Assign buttons for Roll control.
  102128. */
  102129. buttonsRoll: number[];
  102130. /**
  102131. * Detect if any button is being pressed while mouse is moved.
  102132. * -1 = Mouse locked.
  102133. * 0 = Left button.
  102134. * 1 = Middle Button.
  102135. * 2 = Right Button.
  102136. */
  102137. activeButton: number;
  102138. /**
  102139. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102140. * Higher values reduce its sensitivity.
  102141. */
  102142. angularSensibility: number;
  102143. private _mousemoveCallback;
  102144. private _observer;
  102145. private _rollObserver;
  102146. private previousPosition;
  102147. private noPreventDefault;
  102148. private element;
  102149. /**
  102150. * Listen to mouse events to control the camera.
  102151. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102153. */
  102154. constructor(touchEnabled?: boolean);
  102155. /**
  102156. * Attach the mouse control to the HTML DOM element.
  102157. * @param element Defines the element that listens to the input events.
  102158. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102159. */
  102160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102161. /**
  102162. * Detach the current controls from the specified dom element.
  102163. * @param element Defines the element to stop listening the inputs from
  102164. */
  102165. detachControl(element: Nullable<HTMLElement>): void;
  102166. /**
  102167. * Gets the class name of the current input.
  102168. * @returns the class name.
  102169. */
  102170. getClassName(): string;
  102171. /**
  102172. * Get the friendly name associated with the input class.
  102173. * @returns the input's friendly name.
  102174. */
  102175. getSimpleName(): string;
  102176. private _pointerInput;
  102177. private _onMouseMove;
  102178. /**
  102179. * Rotate camera by mouse offset.
  102180. */
  102181. private rotateCamera;
  102182. }
  102183. }
  102184. declare module BABYLON {
  102185. /**
  102186. * Default Inputs manager for the FlyCamera.
  102187. * It groups all the default supported inputs for ease of use.
  102188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102189. */
  102190. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102191. /**
  102192. * Instantiates a new FlyCameraInputsManager.
  102193. * @param camera Defines the camera the inputs belong to.
  102194. */
  102195. constructor(camera: FlyCamera);
  102196. /**
  102197. * Add keyboard input support to the input manager.
  102198. * @returns the new FlyCameraKeyboardMoveInput().
  102199. */
  102200. addKeyboard(): FlyCameraInputsManager;
  102201. /**
  102202. * Add mouse input support to the input manager.
  102203. * @param touchEnabled Enable touch screen support.
  102204. * @returns the new FlyCameraMouseInput().
  102205. */
  102206. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102207. }
  102208. }
  102209. declare module BABYLON {
  102210. /**
  102211. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102212. * such as in a 3D Space Shooter or a Flight Simulator.
  102213. */
  102214. export class FlyCamera extends TargetCamera {
  102215. /**
  102216. * Define the collision ellipsoid of the camera.
  102217. * This is helpful for simulating a camera body, like a player's body.
  102218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102219. */
  102220. ellipsoid: Vector3;
  102221. /**
  102222. * Define an offset for the position of the ellipsoid around the camera.
  102223. * This can be helpful if the camera is attached away from the player's body center,
  102224. * such as at its head.
  102225. */
  102226. ellipsoidOffset: Vector3;
  102227. /**
  102228. * Enable or disable collisions of the camera with the rest of the scene objects.
  102229. */
  102230. checkCollisions: boolean;
  102231. /**
  102232. * Enable or disable gravity on the camera.
  102233. */
  102234. applyGravity: boolean;
  102235. /**
  102236. * Define the current direction the camera is moving to.
  102237. */
  102238. cameraDirection: Vector3;
  102239. /**
  102240. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102241. * This overrides and empties cameraRotation.
  102242. */
  102243. rotationQuaternion: Quaternion;
  102244. /**
  102245. * Track Roll to maintain the wanted Rolling when looking around.
  102246. */
  102247. _trackRoll: number;
  102248. /**
  102249. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102250. */
  102251. rollCorrect: number;
  102252. /**
  102253. * Mimic a banked turn, Rolling the camera when Yawing.
  102254. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102255. */
  102256. bankedTurn: boolean;
  102257. /**
  102258. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102259. */
  102260. bankedTurnLimit: number;
  102261. /**
  102262. * Value of 0 disables the banked Roll.
  102263. * Value of 1 is equal to the Yaw angle in radians.
  102264. */
  102265. bankedTurnMultiplier: number;
  102266. /**
  102267. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102268. */
  102269. inputs: FlyCameraInputsManager;
  102270. /**
  102271. * Gets the input sensibility for mouse input.
  102272. * Higher values reduce sensitivity.
  102273. */
  102274. /**
  102275. * Sets the input sensibility for a mouse input.
  102276. * Higher values reduce sensitivity.
  102277. */
  102278. angularSensibility: number;
  102279. /**
  102280. * Get the keys for camera movement forward.
  102281. */
  102282. /**
  102283. * Set the keys for camera movement forward.
  102284. */
  102285. keysForward: number[];
  102286. /**
  102287. * Get the keys for camera movement backward.
  102288. */
  102289. keysBackward: number[];
  102290. /**
  102291. * Get the keys for camera movement up.
  102292. */
  102293. /**
  102294. * Set the keys for camera movement up.
  102295. */
  102296. keysUp: number[];
  102297. /**
  102298. * Get the keys for camera movement down.
  102299. */
  102300. /**
  102301. * Set the keys for camera movement down.
  102302. */
  102303. keysDown: number[];
  102304. /**
  102305. * Get the keys for camera movement left.
  102306. */
  102307. /**
  102308. * Set the keys for camera movement left.
  102309. */
  102310. keysLeft: number[];
  102311. /**
  102312. * Set the keys for camera movement right.
  102313. */
  102314. /**
  102315. * Set the keys for camera movement right.
  102316. */
  102317. keysRight: number[];
  102318. /**
  102319. * Event raised when the camera collides with a mesh in the scene.
  102320. */
  102321. onCollide: (collidedMesh: AbstractMesh) => void;
  102322. private _collider;
  102323. private _needMoveForGravity;
  102324. private _oldPosition;
  102325. private _diffPosition;
  102326. private _newPosition;
  102327. /** @hidden */
  102328. _localDirection: Vector3;
  102329. /** @hidden */
  102330. _transformedDirection: Vector3;
  102331. /**
  102332. * Instantiates a FlyCamera.
  102333. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102334. * such as in a 3D Space Shooter or a Flight Simulator.
  102335. * @param name Define the name of the camera in the scene.
  102336. * @param position Define the starting position of the camera in the scene.
  102337. * @param scene Define the scene the camera belongs to.
  102338. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102339. */
  102340. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102341. /**
  102342. * Attach a control to the HTML DOM element.
  102343. * @param element Defines the element that listens to the input events.
  102344. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102345. */
  102346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102347. /**
  102348. * Detach a control from the HTML DOM element.
  102349. * The camera will stop reacting to that input.
  102350. * @param element Defines the element that listens to the input events.
  102351. */
  102352. detachControl(element: HTMLElement): void;
  102353. private _collisionMask;
  102354. /**
  102355. * Get the mask that the camera ignores in collision events.
  102356. */
  102357. /**
  102358. * Set the mask that the camera ignores in collision events.
  102359. */
  102360. collisionMask: number;
  102361. /** @hidden */
  102362. _collideWithWorld(displacement: Vector3): void;
  102363. /** @hidden */
  102364. private _onCollisionPositionChange;
  102365. /** @hidden */
  102366. _checkInputs(): void;
  102367. /** @hidden */
  102368. _decideIfNeedsToMove(): boolean;
  102369. /** @hidden */
  102370. _updatePosition(): void;
  102371. /**
  102372. * Restore the Roll to its target value at the rate specified.
  102373. * @param rate - Higher means slower restoring.
  102374. * @hidden
  102375. */
  102376. restoreRoll(rate: number): void;
  102377. /**
  102378. * Destroy the camera and release the current resources held by it.
  102379. */
  102380. dispose(): void;
  102381. /**
  102382. * Get the current object class name.
  102383. * @returns the class name.
  102384. */
  102385. getClassName(): string;
  102386. }
  102387. }
  102388. declare module BABYLON {
  102389. /**
  102390. * Listen to keyboard events to control the camera.
  102391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102392. */
  102393. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  102394. /**
  102395. * Defines the camera the input is attached to.
  102396. */
  102397. camera: FlyCamera;
  102398. /**
  102399. * The list of keyboard keys used to control the forward move of the camera.
  102400. */
  102401. keysForward: number[];
  102402. /**
  102403. * The list of keyboard keys used to control the backward move of the camera.
  102404. */
  102405. keysBackward: number[];
  102406. /**
  102407. * The list of keyboard keys used to control the forward move of the camera.
  102408. */
  102409. keysUp: number[];
  102410. /**
  102411. * The list of keyboard keys used to control the backward move of the camera.
  102412. */
  102413. keysDown: number[];
  102414. /**
  102415. * The list of keyboard keys used to control the right strafe move of the camera.
  102416. */
  102417. keysRight: number[];
  102418. /**
  102419. * The list of keyboard keys used to control the left strafe move of the camera.
  102420. */
  102421. keysLeft: number[];
  102422. private _keys;
  102423. private _onCanvasBlurObserver;
  102424. private _onKeyboardObserver;
  102425. private _engine;
  102426. private _scene;
  102427. /**
  102428. * Attach the input controls to a specific dom element to get the input from.
  102429. * @param element Defines the element the controls should be listened from
  102430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102431. */
  102432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102433. /**
  102434. * Detach the current controls from the specified dom element.
  102435. * @param element Defines the element to stop listening the inputs from
  102436. */
  102437. detachControl(element: Nullable<HTMLElement>): void;
  102438. /**
  102439. * Gets the class name of the current intput.
  102440. * @returns the class name
  102441. */
  102442. getClassName(): string;
  102443. /** @hidden */
  102444. _onLostFocus(e: FocusEvent): void;
  102445. /**
  102446. * Get the friendly name associated with the input class.
  102447. * @returns the input friendly name
  102448. */
  102449. getSimpleName(): string;
  102450. /**
  102451. * Update the current camera state depending on the inputs that have been used this frame.
  102452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102453. */
  102454. checkInputs(): void;
  102455. }
  102456. }
  102457. declare module BABYLON {
  102458. /**
  102459. * Manage the mouse wheel inputs to control a follow camera.
  102460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102461. */
  102462. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102463. /**
  102464. * Defines the camera the input is attached to.
  102465. */
  102466. camera: FollowCamera;
  102467. /**
  102468. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102469. */
  102470. axisControlRadius: boolean;
  102471. /**
  102472. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102473. */
  102474. axisControlHeight: boolean;
  102475. /**
  102476. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102477. */
  102478. axisControlRotation: boolean;
  102479. /**
  102480. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102481. * relation to mouseWheel events.
  102482. */
  102483. wheelPrecision: number;
  102484. /**
  102485. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102486. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102487. */
  102488. wheelDeltaPercentage: number;
  102489. private _wheel;
  102490. private _observer;
  102491. /**
  102492. * Attach the input controls to a specific dom element to get the input from.
  102493. * @param element Defines the element the controls should be listened from
  102494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102495. */
  102496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102497. /**
  102498. * Detach the current controls from the specified dom element.
  102499. * @param element Defines the element to stop listening the inputs from
  102500. */
  102501. detachControl(element: Nullable<HTMLElement>): void;
  102502. /**
  102503. * Gets the class name of the current intput.
  102504. * @returns the class name
  102505. */
  102506. getClassName(): string;
  102507. /**
  102508. * Get the friendly name associated with the input class.
  102509. * @returns the input friendly name
  102510. */
  102511. getSimpleName(): string;
  102512. }
  102513. }
  102514. declare module BABYLON {
  102515. /**
  102516. * Manage the pointers inputs to control an follow camera.
  102517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102518. */
  102519. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102520. /**
  102521. * Defines the camera the input is attached to.
  102522. */
  102523. camera: FollowCamera;
  102524. /**
  102525. * Gets the class name of the current input.
  102526. * @returns the class name
  102527. */
  102528. getClassName(): string;
  102529. /**
  102530. * Defines the pointer angular sensibility along the X axis or how fast is
  102531. * the camera rotating.
  102532. * A negative number will reverse the axis direction.
  102533. */
  102534. angularSensibilityX: number;
  102535. /**
  102536. * Defines the pointer angular sensibility along the Y axis or how fast is
  102537. * the camera rotating.
  102538. * A negative number will reverse the axis direction.
  102539. */
  102540. angularSensibilityY: number;
  102541. /**
  102542. * Defines the pointer pinch precision or how fast is the camera zooming.
  102543. * A negative number will reverse the axis direction.
  102544. */
  102545. pinchPrecision: number;
  102546. /**
  102547. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102548. * from 0.
  102549. * It defines the percentage of current camera.radius to use as delta when
  102550. * pinch zoom is used.
  102551. */
  102552. pinchDeltaPercentage: number;
  102553. /**
  102554. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102555. */
  102556. axisXControlRadius: boolean;
  102557. /**
  102558. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102559. */
  102560. axisXControlHeight: boolean;
  102561. /**
  102562. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102563. */
  102564. axisXControlRotation: boolean;
  102565. /**
  102566. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102567. */
  102568. axisYControlRadius: boolean;
  102569. /**
  102570. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102571. */
  102572. axisYControlHeight: boolean;
  102573. /**
  102574. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102575. */
  102576. axisYControlRotation: boolean;
  102577. /**
  102578. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102579. */
  102580. axisPinchControlRadius: boolean;
  102581. /**
  102582. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102583. */
  102584. axisPinchControlHeight: boolean;
  102585. /**
  102586. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102587. */
  102588. axisPinchControlRotation: boolean;
  102589. /**
  102590. * Log error messages if basic misconfiguration has occurred.
  102591. */
  102592. warningEnable: boolean;
  102593. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102594. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102595. private _warningCounter;
  102596. private _warning;
  102597. }
  102598. }
  102599. declare module BABYLON {
  102600. /**
  102601. * Default Inputs manager for the FollowCamera.
  102602. * It groups all the default supported inputs for ease of use.
  102603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102604. */
  102605. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102606. /**
  102607. * Instantiates a new FollowCameraInputsManager.
  102608. * @param camera Defines the camera the inputs belong to
  102609. */
  102610. constructor(camera: FollowCamera);
  102611. /**
  102612. * Add keyboard input support to the input manager.
  102613. * @returns the current input manager
  102614. */
  102615. addKeyboard(): FollowCameraInputsManager;
  102616. /**
  102617. * Add mouse wheel input support to the input manager.
  102618. * @returns the current input manager
  102619. */
  102620. addMouseWheel(): FollowCameraInputsManager;
  102621. /**
  102622. * Add pointers input support to the input manager.
  102623. * @returns the current input manager
  102624. */
  102625. addPointers(): FollowCameraInputsManager;
  102626. /**
  102627. * Add orientation input support to the input manager.
  102628. * @returns the current input manager
  102629. */
  102630. addVRDeviceOrientation(): FollowCameraInputsManager;
  102631. }
  102632. }
  102633. declare module BABYLON {
  102634. /**
  102635. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102636. * an arc rotate version arcFollowCamera are available.
  102637. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102638. */
  102639. export class FollowCamera extends TargetCamera {
  102640. /**
  102641. * Distance the follow camera should follow an object at
  102642. */
  102643. radius: number;
  102644. /**
  102645. * Minimum allowed distance of the camera to the axis of rotation
  102646. * (The camera can not get closer).
  102647. * This can help limiting how the Camera is able to move in the scene.
  102648. */
  102649. lowerRadiusLimit: Nullable<number>;
  102650. /**
  102651. * Maximum allowed distance of the camera to the axis of rotation
  102652. * (The camera can not get further).
  102653. * This can help limiting how the Camera is able to move in the scene.
  102654. */
  102655. upperRadiusLimit: Nullable<number>;
  102656. /**
  102657. * Define a rotation offset between the camera and the object it follows
  102658. */
  102659. rotationOffset: number;
  102660. /**
  102661. * Minimum allowed angle to camera position relative to target object.
  102662. * This can help limiting how the Camera is able to move in the scene.
  102663. */
  102664. lowerRotationOffsetLimit: Nullable<number>;
  102665. /**
  102666. * Maximum allowed angle to camera position relative to target object.
  102667. * This can help limiting how the Camera is able to move in the scene.
  102668. */
  102669. upperRotationOffsetLimit: Nullable<number>;
  102670. /**
  102671. * Define a height offset between the camera and the object it follows.
  102672. * It can help following an object from the top (like a car chaing a plane)
  102673. */
  102674. heightOffset: number;
  102675. /**
  102676. * Minimum allowed height of camera position relative to target object.
  102677. * This can help limiting how the Camera is able to move in the scene.
  102678. */
  102679. lowerHeightOffsetLimit: Nullable<number>;
  102680. /**
  102681. * Maximum allowed height of camera position relative to target object.
  102682. * This can help limiting how the Camera is able to move in the scene.
  102683. */
  102684. upperHeightOffsetLimit: Nullable<number>;
  102685. /**
  102686. * Define how fast the camera can accelerate to follow it s target.
  102687. */
  102688. cameraAcceleration: number;
  102689. /**
  102690. * Define the speed limit of the camera following an object.
  102691. */
  102692. maxCameraSpeed: number;
  102693. /**
  102694. * Define the target of the camera.
  102695. */
  102696. lockedTarget: Nullable<AbstractMesh>;
  102697. /**
  102698. * Defines the input associated with the camera.
  102699. */
  102700. inputs: FollowCameraInputsManager;
  102701. /**
  102702. * Instantiates the follow camera.
  102703. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102704. * @param name Define the name of the camera in the scene
  102705. * @param position Define the position of the camera
  102706. * @param scene Define the scene the camera belong to
  102707. * @param lockedTarget Define the target of the camera
  102708. */
  102709. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102710. private _follow;
  102711. /**
  102712. * Attached controls to the current camera.
  102713. * @param element Defines the element the controls should be listened from
  102714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102715. */
  102716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102717. /**
  102718. * Detach the current controls from the camera.
  102719. * The camera will stop reacting to inputs.
  102720. * @param element Defines the element to stop listening the inputs from
  102721. */
  102722. detachControl(element: HTMLElement): void;
  102723. /** @hidden */
  102724. _checkInputs(): void;
  102725. private _checkLimits;
  102726. /**
  102727. * Gets the camera class name.
  102728. * @returns the class name
  102729. */
  102730. getClassName(): string;
  102731. }
  102732. /**
  102733. * Arc Rotate version of the follow camera.
  102734. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102735. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102736. */
  102737. export class ArcFollowCamera extends TargetCamera {
  102738. /** The longitudinal angle of the camera */
  102739. alpha: number;
  102740. /** The latitudinal angle of the camera */
  102741. beta: number;
  102742. /** The radius of the camera from its target */
  102743. radius: number;
  102744. /** Define the camera target (the messh it should follow) */
  102745. target: Nullable<AbstractMesh>;
  102746. private _cartesianCoordinates;
  102747. /**
  102748. * Instantiates a new ArcFollowCamera
  102749. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102750. * @param name Define the name of the camera
  102751. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102752. * @param beta Define the rotation angle of the camera around the elevation axis
  102753. * @param radius Define the radius of the camera from its target point
  102754. * @param target Define the target of the camera
  102755. * @param scene Define the scene the camera belongs to
  102756. */
  102757. constructor(name: string,
  102758. /** The longitudinal angle of the camera */
  102759. alpha: number,
  102760. /** The latitudinal angle of the camera */
  102761. beta: number,
  102762. /** The radius of the camera from its target */
  102763. radius: number,
  102764. /** Define the camera target (the messh it should follow) */
  102765. target: Nullable<AbstractMesh>, scene: Scene);
  102766. private _follow;
  102767. /** @hidden */
  102768. _checkInputs(): void;
  102769. /**
  102770. * Returns the class name of the object.
  102771. * It is mostly used internally for serialization purposes.
  102772. */
  102773. getClassName(): string;
  102774. }
  102775. }
  102776. declare module BABYLON {
  102777. /**
  102778. * Manage the keyboard inputs to control the movement of a follow camera.
  102779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102780. */
  102781. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102782. /**
  102783. * Defines the camera the input is attached to.
  102784. */
  102785. camera: FollowCamera;
  102786. /**
  102787. * Defines the list of key codes associated with the up action (increase heightOffset)
  102788. */
  102789. keysHeightOffsetIncr: number[];
  102790. /**
  102791. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102792. */
  102793. keysHeightOffsetDecr: number[];
  102794. /**
  102795. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102796. */
  102797. keysHeightOffsetModifierAlt: boolean;
  102798. /**
  102799. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102800. */
  102801. keysHeightOffsetModifierCtrl: boolean;
  102802. /**
  102803. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102804. */
  102805. keysHeightOffsetModifierShift: boolean;
  102806. /**
  102807. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102808. */
  102809. keysRotationOffsetIncr: number[];
  102810. /**
  102811. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102812. */
  102813. keysRotationOffsetDecr: number[];
  102814. /**
  102815. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102816. */
  102817. keysRotationOffsetModifierAlt: boolean;
  102818. /**
  102819. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102820. */
  102821. keysRotationOffsetModifierCtrl: boolean;
  102822. /**
  102823. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102824. */
  102825. keysRotationOffsetModifierShift: boolean;
  102826. /**
  102827. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102828. */
  102829. keysRadiusIncr: number[];
  102830. /**
  102831. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102832. */
  102833. keysRadiusDecr: number[];
  102834. /**
  102835. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102836. */
  102837. keysRadiusModifierAlt: boolean;
  102838. /**
  102839. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102840. */
  102841. keysRadiusModifierCtrl: boolean;
  102842. /**
  102843. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102844. */
  102845. keysRadiusModifierShift: boolean;
  102846. /**
  102847. * Defines the rate of change of heightOffset.
  102848. */
  102849. heightSensibility: number;
  102850. /**
  102851. * Defines the rate of change of rotationOffset.
  102852. */
  102853. rotationSensibility: number;
  102854. /**
  102855. * Defines the rate of change of radius.
  102856. */
  102857. radiusSensibility: number;
  102858. private _keys;
  102859. private _ctrlPressed;
  102860. private _altPressed;
  102861. private _shiftPressed;
  102862. private _onCanvasBlurObserver;
  102863. private _onKeyboardObserver;
  102864. private _engine;
  102865. private _scene;
  102866. /**
  102867. * Attach the input controls to a specific dom element to get the input from.
  102868. * @param element Defines the element the controls should be listened from
  102869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102870. */
  102871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102872. /**
  102873. * Detach the current controls from the specified dom element.
  102874. * @param element Defines the element to stop listening the inputs from
  102875. */
  102876. detachControl(element: Nullable<HTMLElement>): void;
  102877. /**
  102878. * Update the current camera state depending on the inputs that have been used this frame.
  102879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102880. */
  102881. checkInputs(): void;
  102882. /**
  102883. * Gets the class name of the current input.
  102884. * @returns the class name
  102885. */
  102886. getClassName(): string;
  102887. /**
  102888. * Get the friendly name associated with the input class.
  102889. * @returns the input friendly name
  102890. */
  102891. getSimpleName(): string;
  102892. /**
  102893. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102894. * allow modification of the heightOffset value.
  102895. */
  102896. private _modifierHeightOffset;
  102897. /**
  102898. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102899. * allow modification of the rotationOffset value.
  102900. */
  102901. private _modifierRotationOffset;
  102902. /**
  102903. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102904. * allow modification of the radius value.
  102905. */
  102906. private _modifierRadius;
  102907. }
  102908. }
  102909. declare module BABYLON {
  102910. interface FreeCameraInputsManager {
  102911. /**
  102912. * @hidden
  102913. */
  102914. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102915. /**
  102916. * Add orientation input support to the input manager.
  102917. * @returns the current input manager
  102918. */
  102919. addDeviceOrientation(): FreeCameraInputsManager;
  102920. }
  102921. /**
  102922. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102923. * Screen rotation is taken into account.
  102924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102925. */
  102926. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102927. private _camera;
  102928. private _screenOrientationAngle;
  102929. private _constantTranform;
  102930. private _screenQuaternion;
  102931. private _alpha;
  102932. private _beta;
  102933. private _gamma;
  102934. /**
  102935. * Can be used to detect if a device orientation sensor is availible on a device
  102936. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102937. * @returns a promise that will resolve on orientation change
  102938. */
  102939. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102940. /**
  102941. * @hidden
  102942. */
  102943. _onDeviceOrientationChangedObservable: Observable<void>;
  102944. /**
  102945. * Instantiates a new input
  102946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102947. */
  102948. constructor();
  102949. /**
  102950. * Define the camera controlled by the input.
  102951. */
  102952. camera: FreeCamera;
  102953. /**
  102954. * Attach the input controls to a specific dom element to get the input from.
  102955. * @param element Defines the element the controls should be listened from
  102956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102957. */
  102958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102959. private _orientationChanged;
  102960. private _deviceOrientation;
  102961. /**
  102962. * Detach the current controls from the specified dom element.
  102963. * @param element Defines the element to stop listening the inputs from
  102964. */
  102965. detachControl(element: Nullable<HTMLElement>): void;
  102966. /**
  102967. * Update the current camera state depending on the inputs that have been used this frame.
  102968. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102969. */
  102970. checkInputs(): void;
  102971. /**
  102972. * Gets the class name of the current intput.
  102973. * @returns the class name
  102974. */
  102975. getClassName(): string;
  102976. /**
  102977. * Get the friendly name associated with the input class.
  102978. * @returns the input friendly name
  102979. */
  102980. getSimpleName(): string;
  102981. }
  102982. }
  102983. declare module BABYLON {
  102984. /**
  102985. * Manage the gamepad inputs to control a free camera.
  102986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102987. */
  102988. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102989. /**
  102990. * Define the camera the input is attached to.
  102991. */
  102992. camera: FreeCamera;
  102993. /**
  102994. * Define the Gamepad controlling the input
  102995. */
  102996. gamepad: Nullable<Gamepad>;
  102997. /**
  102998. * Defines the gamepad rotation sensiblity.
  102999. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103000. */
  103001. gamepadAngularSensibility: number;
  103002. /**
  103003. * Defines the gamepad move sensiblity.
  103004. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103005. */
  103006. gamepadMoveSensibility: number;
  103007. private _onGamepadConnectedObserver;
  103008. private _onGamepadDisconnectedObserver;
  103009. private _cameraTransform;
  103010. private _deltaTransform;
  103011. private _vector3;
  103012. private _vector2;
  103013. /**
  103014. * Attach the input controls to a specific dom element to get the input from.
  103015. * @param element Defines the element the controls should be listened from
  103016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103017. */
  103018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103019. /**
  103020. * Detach the current controls from the specified dom element.
  103021. * @param element Defines the element to stop listening the inputs from
  103022. */
  103023. detachControl(element: Nullable<HTMLElement>): void;
  103024. /**
  103025. * Update the current camera state depending on the inputs that have been used this frame.
  103026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103027. */
  103028. checkInputs(): void;
  103029. /**
  103030. * Gets the class name of the current intput.
  103031. * @returns the class name
  103032. */
  103033. getClassName(): string;
  103034. /**
  103035. * Get the friendly name associated with the input class.
  103036. * @returns the input friendly name
  103037. */
  103038. getSimpleName(): string;
  103039. }
  103040. }
  103041. declare module BABYLON {
  103042. /**
  103043. * Defines the potential axis of a Joystick
  103044. */
  103045. export enum JoystickAxis {
  103046. /** X axis */
  103047. X = 0,
  103048. /** Y axis */
  103049. Y = 1,
  103050. /** Z axis */
  103051. Z = 2
  103052. }
  103053. /**
  103054. * Class used to define virtual joystick (used in touch mode)
  103055. */
  103056. export class VirtualJoystick {
  103057. /**
  103058. * Gets or sets a boolean indicating that left and right values must be inverted
  103059. */
  103060. reverseLeftRight: boolean;
  103061. /**
  103062. * Gets or sets a boolean indicating that up and down values must be inverted
  103063. */
  103064. reverseUpDown: boolean;
  103065. /**
  103066. * Gets the offset value for the position (ie. the change of the position value)
  103067. */
  103068. deltaPosition: Vector3;
  103069. /**
  103070. * Gets a boolean indicating if the virtual joystick was pressed
  103071. */
  103072. pressed: boolean;
  103073. /**
  103074. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103075. */
  103076. static Canvas: Nullable<HTMLCanvasElement>;
  103077. private static _globalJoystickIndex;
  103078. private static vjCanvasContext;
  103079. private static vjCanvasWidth;
  103080. private static vjCanvasHeight;
  103081. private static halfWidth;
  103082. private _action;
  103083. private _axisTargetedByLeftAndRight;
  103084. private _axisTargetedByUpAndDown;
  103085. private _joystickSensibility;
  103086. private _inversedSensibility;
  103087. private _joystickPointerID;
  103088. private _joystickColor;
  103089. private _joystickPointerPos;
  103090. private _joystickPreviousPointerPos;
  103091. private _joystickPointerStartPos;
  103092. private _deltaJoystickVector;
  103093. private _leftJoystick;
  103094. private _touches;
  103095. private _onPointerDownHandlerRef;
  103096. private _onPointerMoveHandlerRef;
  103097. private _onPointerUpHandlerRef;
  103098. private _onResize;
  103099. /**
  103100. * Creates a new virtual joystick
  103101. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103102. */
  103103. constructor(leftJoystick?: boolean);
  103104. /**
  103105. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103106. * @param newJoystickSensibility defines the new sensibility
  103107. */
  103108. setJoystickSensibility(newJoystickSensibility: number): void;
  103109. private _onPointerDown;
  103110. private _onPointerMove;
  103111. private _onPointerUp;
  103112. /**
  103113. * Change the color of the virtual joystick
  103114. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103115. */
  103116. setJoystickColor(newColor: string): void;
  103117. /**
  103118. * Defines a callback to call when the joystick is touched
  103119. * @param action defines the callback
  103120. */
  103121. setActionOnTouch(action: () => any): void;
  103122. /**
  103123. * Defines which axis you'd like to control for left & right
  103124. * @param axis defines the axis to use
  103125. */
  103126. setAxisForLeftRight(axis: JoystickAxis): void;
  103127. /**
  103128. * Defines which axis you'd like to control for up & down
  103129. * @param axis defines the axis to use
  103130. */
  103131. setAxisForUpDown(axis: JoystickAxis): void;
  103132. private _drawVirtualJoystick;
  103133. /**
  103134. * Release internal HTML canvas
  103135. */
  103136. releaseCanvas(): void;
  103137. }
  103138. }
  103139. declare module BABYLON {
  103140. interface FreeCameraInputsManager {
  103141. /**
  103142. * Add virtual joystick input support to the input manager.
  103143. * @returns the current input manager
  103144. */
  103145. addVirtualJoystick(): FreeCameraInputsManager;
  103146. }
  103147. /**
  103148. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103150. */
  103151. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103152. /**
  103153. * Defines the camera the input is attached to.
  103154. */
  103155. camera: FreeCamera;
  103156. private _leftjoystick;
  103157. private _rightjoystick;
  103158. /**
  103159. * Gets the left stick of the virtual joystick.
  103160. * @returns The virtual Joystick
  103161. */
  103162. getLeftJoystick(): VirtualJoystick;
  103163. /**
  103164. * Gets the right stick of the virtual joystick.
  103165. * @returns The virtual Joystick
  103166. */
  103167. getRightJoystick(): VirtualJoystick;
  103168. /**
  103169. * Update the current camera state depending on the inputs that have been used this frame.
  103170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103171. */
  103172. checkInputs(): void;
  103173. /**
  103174. * Attach the input controls to a specific dom element to get the input from.
  103175. * @param element Defines the element the controls should be listened from
  103176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103177. */
  103178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103179. /**
  103180. * Detach the current controls from the specified dom element.
  103181. * @param element Defines the element to stop listening the inputs from
  103182. */
  103183. detachControl(element: Nullable<HTMLElement>): void;
  103184. /**
  103185. * Gets the class name of the current intput.
  103186. * @returns the class name
  103187. */
  103188. getClassName(): string;
  103189. /**
  103190. * Get the friendly name associated with the input class.
  103191. * @returns the input friendly name
  103192. */
  103193. getSimpleName(): string;
  103194. }
  103195. }
  103196. declare module BABYLON {
  103197. /**
  103198. * This represents a FPS type of camera controlled by touch.
  103199. * This is like a universal camera minus the Gamepad controls.
  103200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103201. */
  103202. export class TouchCamera extends FreeCamera {
  103203. /**
  103204. * Defines the touch sensibility for rotation.
  103205. * The higher the faster.
  103206. */
  103207. touchAngularSensibility: number;
  103208. /**
  103209. * Defines the touch sensibility for move.
  103210. * The higher the faster.
  103211. */
  103212. touchMoveSensibility: number;
  103213. /**
  103214. * Instantiates a new touch camera.
  103215. * This represents a FPS type of camera controlled by touch.
  103216. * This is like a universal camera minus the Gamepad controls.
  103217. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103218. * @param name Define the name of the camera in the scene
  103219. * @param position Define the start position of the camera in the scene
  103220. * @param scene Define the scene the camera belongs to
  103221. */
  103222. constructor(name: string, position: Vector3, scene: Scene);
  103223. /**
  103224. * Gets the current object class name.
  103225. * @return the class name
  103226. */
  103227. getClassName(): string;
  103228. /** @hidden */
  103229. _setupInputs(): void;
  103230. }
  103231. }
  103232. declare module BABYLON {
  103233. /**
  103234. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103235. * being tilted forward or back and left or right.
  103236. */
  103237. export class DeviceOrientationCamera extends FreeCamera {
  103238. private _initialQuaternion;
  103239. private _quaternionCache;
  103240. private _tmpDragQuaternion;
  103241. private _disablePointerInputWhenUsingDeviceOrientation;
  103242. /**
  103243. * Creates a new device orientation camera
  103244. * @param name The name of the camera
  103245. * @param position The start position camera
  103246. * @param scene The scene the camera belongs to
  103247. */
  103248. constructor(name: string, position: Vector3, scene: Scene);
  103249. /**
  103250. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103251. */
  103252. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103253. private _dragFactor;
  103254. /**
  103255. * Enabled turning on the y axis when the orientation sensor is active
  103256. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103257. */
  103258. enableHorizontalDragging(dragFactor?: number): void;
  103259. /**
  103260. * Gets the current instance class name ("DeviceOrientationCamera").
  103261. * This helps avoiding instanceof at run time.
  103262. * @returns the class name
  103263. */
  103264. getClassName(): string;
  103265. /**
  103266. * @hidden
  103267. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103268. */
  103269. _checkInputs(): void;
  103270. /**
  103271. * Reset the camera to its default orientation on the specified axis only.
  103272. * @param axis The axis to reset
  103273. */
  103274. resetToCurrentRotation(axis?: Axis): void;
  103275. }
  103276. }
  103277. declare module BABYLON {
  103278. /**
  103279. * Defines supported buttons for XBox360 compatible gamepads
  103280. */
  103281. export enum Xbox360Button {
  103282. /** A */
  103283. A = 0,
  103284. /** B */
  103285. B = 1,
  103286. /** X */
  103287. X = 2,
  103288. /** Y */
  103289. Y = 3,
  103290. /** Start */
  103291. Start = 4,
  103292. /** Back */
  103293. Back = 5,
  103294. /** Left button */
  103295. LB = 6,
  103296. /** Right button */
  103297. RB = 7,
  103298. /** Left stick */
  103299. LeftStick = 8,
  103300. /** Right stick */
  103301. RightStick = 9
  103302. }
  103303. /** Defines values for XBox360 DPad */
  103304. export enum Xbox360Dpad {
  103305. /** Up */
  103306. Up = 0,
  103307. /** Down */
  103308. Down = 1,
  103309. /** Left */
  103310. Left = 2,
  103311. /** Right */
  103312. Right = 3
  103313. }
  103314. /**
  103315. * Defines a XBox360 gamepad
  103316. */
  103317. export class Xbox360Pad extends Gamepad {
  103318. private _leftTrigger;
  103319. private _rightTrigger;
  103320. private _onlefttriggerchanged;
  103321. private _onrighttriggerchanged;
  103322. private _onbuttondown;
  103323. private _onbuttonup;
  103324. private _ondpaddown;
  103325. private _ondpadup;
  103326. /** Observable raised when a button is pressed */
  103327. onButtonDownObservable: Observable<Xbox360Button>;
  103328. /** Observable raised when a button is released */
  103329. onButtonUpObservable: Observable<Xbox360Button>;
  103330. /** Observable raised when a pad is pressed */
  103331. onPadDownObservable: Observable<Xbox360Dpad>;
  103332. /** Observable raised when a pad is released */
  103333. onPadUpObservable: Observable<Xbox360Dpad>;
  103334. private _buttonA;
  103335. private _buttonB;
  103336. private _buttonX;
  103337. private _buttonY;
  103338. private _buttonBack;
  103339. private _buttonStart;
  103340. private _buttonLB;
  103341. private _buttonRB;
  103342. private _buttonLeftStick;
  103343. private _buttonRightStick;
  103344. private _dPadUp;
  103345. private _dPadDown;
  103346. private _dPadLeft;
  103347. private _dPadRight;
  103348. private _isXboxOnePad;
  103349. /**
  103350. * Creates a new XBox360 gamepad object
  103351. * @param id defines the id of this gamepad
  103352. * @param index defines its index
  103353. * @param gamepad defines the internal HTML gamepad object
  103354. * @param xboxOne defines if it is a XBox One gamepad
  103355. */
  103356. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103357. /**
  103358. * Defines the callback to call when left trigger is pressed
  103359. * @param callback defines the callback to use
  103360. */
  103361. onlefttriggerchanged(callback: (value: number) => void): void;
  103362. /**
  103363. * Defines the callback to call when right trigger is pressed
  103364. * @param callback defines the callback to use
  103365. */
  103366. onrighttriggerchanged(callback: (value: number) => void): void;
  103367. /**
  103368. * Gets the left trigger value
  103369. */
  103370. /**
  103371. * Sets the left trigger value
  103372. */
  103373. leftTrigger: number;
  103374. /**
  103375. * Gets the right trigger value
  103376. */
  103377. /**
  103378. * Sets the right trigger value
  103379. */
  103380. rightTrigger: number;
  103381. /**
  103382. * Defines the callback to call when a button is pressed
  103383. * @param callback defines the callback to use
  103384. */
  103385. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103386. /**
  103387. * Defines the callback to call when a button is released
  103388. * @param callback defines the callback to use
  103389. */
  103390. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103391. /**
  103392. * Defines the callback to call when a pad is pressed
  103393. * @param callback defines the callback to use
  103394. */
  103395. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  103396. /**
  103397. * Defines the callback to call when a pad is released
  103398. * @param callback defines the callback to use
  103399. */
  103400. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  103401. private _setButtonValue;
  103402. private _setDPadValue;
  103403. /**
  103404. * Gets the value of the `A` button
  103405. */
  103406. /**
  103407. * Sets the value of the `A` button
  103408. */
  103409. buttonA: number;
  103410. /**
  103411. * Gets the value of the `B` button
  103412. */
  103413. /**
  103414. * Sets the value of the `B` button
  103415. */
  103416. buttonB: number;
  103417. /**
  103418. * Gets the value of the `X` button
  103419. */
  103420. /**
  103421. * Sets the value of the `X` button
  103422. */
  103423. buttonX: number;
  103424. /**
  103425. * Gets the value of the `Y` button
  103426. */
  103427. /**
  103428. * Sets the value of the `Y` button
  103429. */
  103430. buttonY: number;
  103431. /**
  103432. * Gets the value of the `Start` button
  103433. */
  103434. /**
  103435. * Sets the value of the `Start` button
  103436. */
  103437. buttonStart: number;
  103438. /**
  103439. * Gets the value of the `Back` button
  103440. */
  103441. /**
  103442. * Sets the value of the `Back` button
  103443. */
  103444. buttonBack: number;
  103445. /**
  103446. * Gets the value of the `Left` button
  103447. */
  103448. /**
  103449. * Sets the value of the `Left` button
  103450. */
  103451. buttonLB: number;
  103452. /**
  103453. * Gets the value of the `Right` button
  103454. */
  103455. /**
  103456. * Sets the value of the `Right` button
  103457. */
  103458. buttonRB: number;
  103459. /**
  103460. * Gets the value of the Left joystick
  103461. */
  103462. /**
  103463. * Sets the value of the Left joystick
  103464. */
  103465. buttonLeftStick: number;
  103466. /**
  103467. * Gets the value of the Right joystick
  103468. */
  103469. /**
  103470. * Sets the value of the Right joystick
  103471. */
  103472. buttonRightStick: number;
  103473. /**
  103474. * Gets the value of D-pad up
  103475. */
  103476. /**
  103477. * Sets the value of D-pad up
  103478. */
  103479. dPadUp: number;
  103480. /**
  103481. * Gets the value of D-pad down
  103482. */
  103483. /**
  103484. * Sets the value of D-pad down
  103485. */
  103486. dPadDown: number;
  103487. /**
  103488. * Gets the value of D-pad left
  103489. */
  103490. /**
  103491. * Sets the value of D-pad left
  103492. */
  103493. dPadLeft: number;
  103494. /**
  103495. * Gets the value of D-pad right
  103496. */
  103497. /**
  103498. * Sets the value of D-pad right
  103499. */
  103500. dPadRight: number;
  103501. /**
  103502. * Force the gamepad to synchronize with device values
  103503. */
  103504. update(): void;
  103505. /**
  103506. * Disposes the gamepad
  103507. */
  103508. dispose(): void;
  103509. }
  103510. }
  103511. declare module BABYLON {
  103512. /**
  103513. * Defines supported buttons for DualShock compatible gamepads
  103514. */
  103515. export enum DualShockButton {
  103516. /** Cross */
  103517. Cross = 0,
  103518. /** Circle */
  103519. Circle = 1,
  103520. /** Square */
  103521. Square = 2,
  103522. /** Triangle */
  103523. Triangle = 3,
  103524. /** Options */
  103525. Options = 4,
  103526. /** Share */
  103527. Share = 5,
  103528. /** L1 */
  103529. L1 = 6,
  103530. /** R1 */
  103531. R1 = 7,
  103532. /** Left stick */
  103533. LeftStick = 8,
  103534. /** Right stick */
  103535. RightStick = 9
  103536. }
  103537. /** Defines values for DualShock DPad */
  103538. export enum DualShockDpad {
  103539. /** Up */
  103540. Up = 0,
  103541. /** Down */
  103542. Down = 1,
  103543. /** Left */
  103544. Left = 2,
  103545. /** Right */
  103546. Right = 3
  103547. }
  103548. /**
  103549. * Defines a DualShock gamepad
  103550. */
  103551. export class DualShockPad extends Gamepad {
  103552. private _leftTrigger;
  103553. private _rightTrigger;
  103554. private _onlefttriggerchanged;
  103555. private _onrighttriggerchanged;
  103556. private _onbuttondown;
  103557. private _onbuttonup;
  103558. private _ondpaddown;
  103559. private _ondpadup;
  103560. /** Observable raised when a button is pressed */
  103561. onButtonDownObservable: Observable<DualShockButton>;
  103562. /** Observable raised when a button is released */
  103563. onButtonUpObservable: Observable<DualShockButton>;
  103564. /** Observable raised when a pad is pressed */
  103565. onPadDownObservable: Observable<DualShockDpad>;
  103566. /** Observable raised when a pad is released */
  103567. onPadUpObservable: Observable<DualShockDpad>;
  103568. private _buttonCross;
  103569. private _buttonCircle;
  103570. private _buttonSquare;
  103571. private _buttonTriangle;
  103572. private _buttonShare;
  103573. private _buttonOptions;
  103574. private _buttonL1;
  103575. private _buttonR1;
  103576. private _buttonLeftStick;
  103577. private _buttonRightStick;
  103578. private _dPadUp;
  103579. private _dPadDown;
  103580. private _dPadLeft;
  103581. private _dPadRight;
  103582. /**
  103583. * Creates a new DualShock gamepad object
  103584. * @param id defines the id of this gamepad
  103585. * @param index defines its index
  103586. * @param gamepad defines the internal HTML gamepad object
  103587. */
  103588. constructor(id: string, index: number, gamepad: any);
  103589. /**
  103590. * Defines the callback to call when left trigger is pressed
  103591. * @param callback defines the callback to use
  103592. */
  103593. onlefttriggerchanged(callback: (value: number) => void): void;
  103594. /**
  103595. * Defines the callback to call when right trigger is pressed
  103596. * @param callback defines the callback to use
  103597. */
  103598. onrighttriggerchanged(callback: (value: number) => void): void;
  103599. /**
  103600. * Gets the left trigger value
  103601. */
  103602. /**
  103603. * Sets the left trigger value
  103604. */
  103605. leftTrigger: number;
  103606. /**
  103607. * Gets the right trigger value
  103608. */
  103609. /**
  103610. * Sets the right trigger value
  103611. */
  103612. rightTrigger: number;
  103613. /**
  103614. * Defines the callback to call when a button is pressed
  103615. * @param callback defines the callback to use
  103616. */
  103617. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103618. /**
  103619. * Defines the callback to call when a button is released
  103620. * @param callback defines the callback to use
  103621. */
  103622. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103623. /**
  103624. * Defines the callback to call when a pad is pressed
  103625. * @param callback defines the callback to use
  103626. */
  103627. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103628. /**
  103629. * Defines the callback to call when a pad is released
  103630. * @param callback defines the callback to use
  103631. */
  103632. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103633. private _setButtonValue;
  103634. private _setDPadValue;
  103635. /**
  103636. * Gets the value of the `Cross` button
  103637. */
  103638. /**
  103639. * Sets the value of the `Cross` button
  103640. */
  103641. buttonCross: number;
  103642. /**
  103643. * Gets the value of the `Circle` button
  103644. */
  103645. /**
  103646. * Sets the value of the `Circle` button
  103647. */
  103648. buttonCircle: number;
  103649. /**
  103650. * Gets the value of the `Square` button
  103651. */
  103652. /**
  103653. * Sets the value of the `Square` button
  103654. */
  103655. buttonSquare: number;
  103656. /**
  103657. * Gets the value of the `Triangle` button
  103658. */
  103659. /**
  103660. * Sets the value of the `Triangle` button
  103661. */
  103662. buttonTriangle: number;
  103663. /**
  103664. * Gets the value of the `Options` button
  103665. */
  103666. /**
  103667. * Sets the value of the `Options` button
  103668. */
  103669. buttonOptions: number;
  103670. /**
  103671. * Gets the value of the `Share` button
  103672. */
  103673. /**
  103674. * Sets the value of the `Share` button
  103675. */
  103676. buttonShare: number;
  103677. /**
  103678. * Gets the value of the `L1` button
  103679. */
  103680. /**
  103681. * Sets the value of the `L1` button
  103682. */
  103683. buttonL1: number;
  103684. /**
  103685. * Gets the value of the `R1` button
  103686. */
  103687. /**
  103688. * Sets the value of the `R1` button
  103689. */
  103690. buttonR1: number;
  103691. /**
  103692. * Gets the value of the Left joystick
  103693. */
  103694. /**
  103695. * Sets the value of the Left joystick
  103696. */
  103697. buttonLeftStick: number;
  103698. /**
  103699. * Gets the value of the Right joystick
  103700. */
  103701. /**
  103702. * Sets the value of the Right joystick
  103703. */
  103704. buttonRightStick: number;
  103705. /**
  103706. * Gets the value of D-pad up
  103707. */
  103708. /**
  103709. * Sets the value of D-pad up
  103710. */
  103711. dPadUp: number;
  103712. /**
  103713. * Gets the value of D-pad down
  103714. */
  103715. /**
  103716. * Sets the value of D-pad down
  103717. */
  103718. dPadDown: number;
  103719. /**
  103720. * Gets the value of D-pad left
  103721. */
  103722. /**
  103723. * Sets the value of D-pad left
  103724. */
  103725. dPadLeft: number;
  103726. /**
  103727. * Gets the value of D-pad right
  103728. */
  103729. /**
  103730. * Sets the value of D-pad right
  103731. */
  103732. dPadRight: number;
  103733. /**
  103734. * Force the gamepad to synchronize with device values
  103735. */
  103736. update(): void;
  103737. /**
  103738. * Disposes the gamepad
  103739. */
  103740. dispose(): void;
  103741. }
  103742. }
  103743. declare module BABYLON {
  103744. /**
  103745. * Manager for handling gamepads
  103746. */
  103747. export class GamepadManager {
  103748. private _scene?;
  103749. private _babylonGamepads;
  103750. private _oneGamepadConnected;
  103751. /** @hidden */
  103752. _isMonitoring: boolean;
  103753. private _gamepadEventSupported;
  103754. private _gamepadSupport;
  103755. /**
  103756. * observable to be triggered when the gamepad controller has been connected
  103757. */
  103758. onGamepadConnectedObservable: Observable<Gamepad>;
  103759. /**
  103760. * observable to be triggered when the gamepad controller has been disconnected
  103761. */
  103762. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103763. private _onGamepadConnectedEvent;
  103764. private _onGamepadDisconnectedEvent;
  103765. /**
  103766. * Initializes the gamepad manager
  103767. * @param _scene BabylonJS scene
  103768. */
  103769. constructor(_scene?: Scene | undefined);
  103770. /**
  103771. * The gamepads in the game pad manager
  103772. */
  103773. readonly gamepads: Gamepad[];
  103774. /**
  103775. * Get the gamepad controllers based on type
  103776. * @param type The type of gamepad controller
  103777. * @returns Nullable gamepad
  103778. */
  103779. getGamepadByType(type?: number): Nullable<Gamepad>;
  103780. /**
  103781. * Disposes the gamepad manager
  103782. */
  103783. dispose(): void;
  103784. private _addNewGamepad;
  103785. private _startMonitoringGamepads;
  103786. private _stopMonitoringGamepads;
  103787. /** @hidden */
  103788. _checkGamepadsStatus(): void;
  103789. private _updateGamepadObjects;
  103790. }
  103791. }
  103792. declare module BABYLON {
  103793. interface Scene {
  103794. /** @hidden */
  103795. _gamepadManager: Nullable<GamepadManager>;
  103796. /**
  103797. * Gets the gamepad manager associated with the scene
  103798. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103799. */
  103800. gamepadManager: GamepadManager;
  103801. }
  103802. /**
  103803. * Interface representing a free camera inputs manager
  103804. */
  103805. interface FreeCameraInputsManager {
  103806. /**
  103807. * Adds gamepad input support to the FreeCameraInputsManager.
  103808. * @returns the FreeCameraInputsManager
  103809. */
  103810. addGamepad(): FreeCameraInputsManager;
  103811. }
  103812. /**
  103813. * Interface representing an arc rotate camera inputs manager
  103814. */
  103815. interface ArcRotateCameraInputsManager {
  103816. /**
  103817. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103818. * @returns the camera inputs manager
  103819. */
  103820. addGamepad(): ArcRotateCameraInputsManager;
  103821. }
  103822. /**
  103823. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103824. */
  103825. export class GamepadSystemSceneComponent implements ISceneComponent {
  103826. /**
  103827. * The component name helpfull to identify the component in the list of scene components.
  103828. */
  103829. readonly name: string;
  103830. /**
  103831. * The scene the component belongs to.
  103832. */
  103833. scene: Scene;
  103834. /**
  103835. * Creates a new instance of the component for the given scene
  103836. * @param scene Defines the scene to register the component in
  103837. */
  103838. constructor(scene: Scene);
  103839. /**
  103840. * Registers the component in a given scene
  103841. */
  103842. register(): void;
  103843. /**
  103844. * Rebuilds the elements related to this component in case of
  103845. * context lost for instance.
  103846. */
  103847. rebuild(): void;
  103848. /**
  103849. * Disposes the component and the associated ressources
  103850. */
  103851. dispose(): void;
  103852. private _beforeCameraUpdate;
  103853. }
  103854. }
  103855. declare module BABYLON {
  103856. /**
  103857. * 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,
  103858. * which still works and will still be found in many Playgrounds.
  103859. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103860. */
  103861. export class UniversalCamera extends TouchCamera {
  103862. /**
  103863. * Defines the gamepad rotation sensiblity.
  103864. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103865. */
  103866. gamepadAngularSensibility: number;
  103867. /**
  103868. * Defines the gamepad move sensiblity.
  103869. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103870. */
  103871. gamepadMoveSensibility: number;
  103872. /**
  103873. * 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,
  103874. * which still works and will still be found in many Playgrounds.
  103875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103876. * @param name Define the name of the camera in the scene
  103877. * @param position Define the start position of the camera in the scene
  103878. * @param scene Define the scene the camera belongs to
  103879. */
  103880. constructor(name: string, position: Vector3, scene: Scene);
  103881. /**
  103882. * Gets the current object class name.
  103883. * @return the class name
  103884. */
  103885. getClassName(): string;
  103886. }
  103887. }
  103888. declare module BABYLON {
  103889. /**
  103890. * This represents a FPS type of camera. This is only here for back compat purpose.
  103891. * Please use the UniversalCamera instead as both are identical.
  103892. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103893. */
  103894. export class GamepadCamera extends UniversalCamera {
  103895. /**
  103896. * Instantiates a new Gamepad Camera
  103897. * This represents a FPS type of camera. This is only here for back compat purpose.
  103898. * Please use the UniversalCamera instead as both are identical.
  103899. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103900. * @param name Define the name of the camera in the scene
  103901. * @param position Define the start position of the camera in the scene
  103902. * @param scene Define the scene the camera belongs to
  103903. */
  103904. constructor(name: string, position: Vector3, scene: Scene);
  103905. /**
  103906. * Gets the current object class name.
  103907. * @return the class name
  103908. */
  103909. getClassName(): string;
  103910. }
  103911. }
  103912. declare module BABYLON {
  103913. /** @hidden */
  103914. export var passPixelShader: {
  103915. name: string;
  103916. shader: string;
  103917. };
  103918. }
  103919. declare module BABYLON {
  103920. /** @hidden */
  103921. export var passCubePixelShader: {
  103922. name: string;
  103923. shader: string;
  103924. };
  103925. }
  103926. declare module BABYLON {
  103927. /**
  103928. * PassPostProcess which produces an output the same as it's input
  103929. */
  103930. export class PassPostProcess extends PostProcess {
  103931. /**
  103932. * Creates the PassPostProcess
  103933. * @param name The name of the effect.
  103934. * @param options The required width/height ratio to downsize to before computing the render pass.
  103935. * @param camera The camera to apply the render pass to.
  103936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103937. * @param engine The engine which the post process will be applied. (default: current engine)
  103938. * @param reusable If the post process can be reused on the same frame. (default: false)
  103939. * @param textureType The type of texture to be used when performing the post processing.
  103940. * @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)
  103941. */
  103942. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103943. }
  103944. /**
  103945. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103946. */
  103947. export class PassCubePostProcess extends PostProcess {
  103948. private _face;
  103949. /**
  103950. * Gets or sets the cube face to display.
  103951. * * 0 is +X
  103952. * * 1 is -X
  103953. * * 2 is +Y
  103954. * * 3 is -Y
  103955. * * 4 is +Z
  103956. * * 5 is -Z
  103957. */
  103958. face: number;
  103959. /**
  103960. * Creates the PassCubePostProcess
  103961. * @param name The name of the effect.
  103962. * @param options The required width/height ratio to downsize to before computing the render pass.
  103963. * @param camera The camera to apply the render pass to.
  103964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103965. * @param engine The engine which the post process will be applied. (default: current engine)
  103966. * @param reusable If the post process can be reused on the same frame. (default: false)
  103967. * @param textureType The type of texture to be used when performing the post processing.
  103968. * @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)
  103969. */
  103970. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103971. }
  103972. }
  103973. declare module BABYLON {
  103974. /** @hidden */
  103975. export var anaglyphPixelShader: {
  103976. name: string;
  103977. shader: string;
  103978. };
  103979. }
  103980. declare module BABYLON {
  103981. /**
  103982. * Postprocess used to generate anaglyphic rendering
  103983. */
  103984. export class AnaglyphPostProcess extends PostProcess {
  103985. private _passedProcess;
  103986. /**
  103987. * Creates a new AnaglyphPostProcess
  103988. * @param name defines postprocess name
  103989. * @param options defines creation options or target ratio scale
  103990. * @param rigCameras defines cameras using this postprocess
  103991. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103992. * @param engine defines hosting engine
  103993. * @param reusable defines if the postprocess will be reused multiple times per frame
  103994. */
  103995. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103996. }
  103997. }
  103998. declare module BABYLON {
  103999. /**
  104000. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104001. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104002. */
  104003. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104004. /**
  104005. * Creates a new AnaglyphArcRotateCamera
  104006. * @param name defines camera name
  104007. * @param alpha defines alpha angle (in radians)
  104008. * @param beta defines beta angle (in radians)
  104009. * @param radius defines radius
  104010. * @param target defines camera target
  104011. * @param interaxialDistance defines distance between each color axis
  104012. * @param scene defines the hosting scene
  104013. */
  104014. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104015. /**
  104016. * Gets camera class name
  104017. * @returns AnaglyphArcRotateCamera
  104018. */
  104019. getClassName(): string;
  104020. }
  104021. }
  104022. declare module BABYLON {
  104023. /**
  104024. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104025. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104026. */
  104027. export class AnaglyphFreeCamera extends FreeCamera {
  104028. /**
  104029. * Creates a new AnaglyphFreeCamera
  104030. * @param name defines camera name
  104031. * @param position defines initial position
  104032. * @param interaxialDistance defines distance between each color axis
  104033. * @param scene defines the hosting scene
  104034. */
  104035. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104036. /**
  104037. * Gets camera class name
  104038. * @returns AnaglyphFreeCamera
  104039. */
  104040. getClassName(): string;
  104041. }
  104042. }
  104043. declare module BABYLON {
  104044. /**
  104045. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104046. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104047. */
  104048. export class AnaglyphGamepadCamera extends GamepadCamera {
  104049. /**
  104050. * Creates a new AnaglyphGamepadCamera
  104051. * @param name defines camera name
  104052. * @param position defines initial position
  104053. * @param interaxialDistance defines distance between each color axis
  104054. * @param scene defines the hosting scene
  104055. */
  104056. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104057. /**
  104058. * Gets camera class name
  104059. * @returns AnaglyphGamepadCamera
  104060. */
  104061. getClassName(): string;
  104062. }
  104063. }
  104064. declare module BABYLON {
  104065. /**
  104066. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104067. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104068. */
  104069. export class AnaglyphUniversalCamera extends UniversalCamera {
  104070. /**
  104071. * Creates a new AnaglyphUniversalCamera
  104072. * @param name defines camera name
  104073. * @param position defines initial position
  104074. * @param interaxialDistance defines distance between each color axis
  104075. * @param scene defines the hosting scene
  104076. */
  104077. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104078. /**
  104079. * Gets camera class name
  104080. * @returns AnaglyphUniversalCamera
  104081. */
  104082. getClassName(): string;
  104083. }
  104084. }
  104085. declare module BABYLON {
  104086. /** @hidden */
  104087. export var stereoscopicInterlacePixelShader: {
  104088. name: string;
  104089. shader: string;
  104090. };
  104091. }
  104092. declare module BABYLON {
  104093. /**
  104094. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104095. */
  104096. export class StereoscopicInterlacePostProcess extends PostProcess {
  104097. private _stepSize;
  104098. private _passedProcess;
  104099. /**
  104100. * Initializes a StereoscopicInterlacePostProcess
  104101. * @param name The name of the effect.
  104102. * @param rigCameras The rig cameras to be appled to the post process
  104103. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104105. * @param engine The engine which the post process will be applied. (default: current engine)
  104106. * @param reusable If the post process can be reused on the same frame. (default: false)
  104107. */
  104108. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104109. }
  104110. }
  104111. declare module BABYLON {
  104112. /**
  104113. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104114. * @see http://doc.babylonjs.com/features/cameras
  104115. */
  104116. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104117. /**
  104118. * Creates a new StereoscopicArcRotateCamera
  104119. * @param name defines camera name
  104120. * @param alpha defines alpha angle (in radians)
  104121. * @param beta defines beta angle (in radians)
  104122. * @param radius defines radius
  104123. * @param target defines camera target
  104124. * @param interaxialDistance defines distance between each color axis
  104125. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104126. * @param scene defines the hosting scene
  104127. */
  104128. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104129. /**
  104130. * Gets camera class name
  104131. * @returns StereoscopicArcRotateCamera
  104132. */
  104133. getClassName(): string;
  104134. }
  104135. }
  104136. declare module BABYLON {
  104137. /**
  104138. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104139. * @see http://doc.babylonjs.com/features/cameras
  104140. */
  104141. export class StereoscopicFreeCamera extends FreeCamera {
  104142. /**
  104143. * Creates a new StereoscopicFreeCamera
  104144. * @param name defines camera name
  104145. * @param position defines initial position
  104146. * @param interaxialDistance defines distance between each color axis
  104147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104148. * @param scene defines the hosting scene
  104149. */
  104150. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104151. /**
  104152. * Gets camera class name
  104153. * @returns StereoscopicFreeCamera
  104154. */
  104155. getClassName(): string;
  104156. }
  104157. }
  104158. declare module BABYLON {
  104159. /**
  104160. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104161. * @see http://doc.babylonjs.com/features/cameras
  104162. */
  104163. export class StereoscopicGamepadCamera extends GamepadCamera {
  104164. /**
  104165. * Creates a new StereoscopicGamepadCamera
  104166. * @param name defines camera name
  104167. * @param position defines initial position
  104168. * @param interaxialDistance defines distance between each color axis
  104169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104170. * @param scene defines the hosting scene
  104171. */
  104172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104173. /**
  104174. * Gets camera class name
  104175. * @returns StereoscopicGamepadCamera
  104176. */
  104177. getClassName(): string;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104183. * @see http://doc.babylonjs.com/features/cameras
  104184. */
  104185. export class StereoscopicUniversalCamera extends UniversalCamera {
  104186. /**
  104187. * Creates a new StereoscopicUniversalCamera
  104188. * @param name defines camera name
  104189. * @param position defines initial position
  104190. * @param interaxialDistance defines distance between each color axis
  104191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104192. * @param scene defines the hosting scene
  104193. */
  104194. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104195. /**
  104196. * Gets camera class name
  104197. * @returns StereoscopicUniversalCamera
  104198. */
  104199. getClassName(): string;
  104200. }
  104201. }
  104202. declare module BABYLON {
  104203. /**
  104204. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104205. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104206. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104207. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104208. */
  104209. export class VirtualJoysticksCamera extends FreeCamera {
  104210. /**
  104211. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104212. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104213. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104214. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104215. * @param name Define the name of the camera in the scene
  104216. * @param position Define the start position of the camera in the scene
  104217. * @param scene Define the scene the camera belongs to
  104218. */
  104219. constructor(name: string, position: Vector3, scene: Scene);
  104220. /**
  104221. * Gets the current object class name.
  104222. * @return the class name
  104223. */
  104224. getClassName(): string;
  104225. }
  104226. }
  104227. declare module BABYLON {
  104228. /**
  104229. * This represents all the required metrics to create a VR camera.
  104230. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104231. */
  104232. export class VRCameraMetrics {
  104233. /**
  104234. * Define the horizontal resolution off the screen.
  104235. */
  104236. hResolution: number;
  104237. /**
  104238. * Define the vertical resolution off the screen.
  104239. */
  104240. vResolution: number;
  104241. /**
  104242. * Define the horizontal screen size.
  104243. */
  104244. hScreenSize: number;
  104245. /**
  104246. * Define the vertical screen size.
  104247. */
  104248. vScreenSize: number;
  104249. /**
  104250. * Define the vertical screen center position.
  104251. */
  104252. vScreenCenter: number;
  104253. /**
  104254. * Define the distance of the eyes to the screen.
  104255. */
  104256. eyeToScreenDistance: number;
  104257. /**
  104258. * Define the distance between both lenses
  104259. */
  104260. lensSeparationDistance: number;
  104261. /**
  104262. * Define the distance between both viewer's eyes.
  104263. */
  104264. interpupillaryDistance: number;
  104265. /**
  104266. * Define the distortion factor of the VR postprocess.
  104267. * Please, touch with care.
  104268. */
  104269. distortionK: number[];
  104270. /**
  104271. * Define the chromatic aberration correction factors for the VR post process.
  104272. */
  104273. chromaAbCorrection: number[];
  104274. /**
  104275. * Define the scale factor of the post process.
  104276. * The smaller the better but the slower.
  104277. */
  104278. postProcessScaleFactor: number;
  104279. /**
  104280. * Define an offset for the lens center.
  104281. */
  104282. lensCenterOffset: number;
  104283. /**
  104284. * Define if the current vr camera should compensate the distortion of the lense or not.
  104285. */
  104286. compensateDistortion: boolean;
  104287. /**
  104288. * Defines if multiview should be enabled when rendering (Default: false)
  104289. */
  104290. multiviewEnabled: boolean;
  104291. /**
  104292. * Gets the rendering aspect ratio based on the provided resolutions.
  104293. */
  104294. readonly aspectRatio: number;
  104295. /**
  104296. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104297. */
  104298. readonly aspectRatioFov: number;
  104299. /**
  104300. * @hidden
  104301. */
  104302. readonly leftHMatrix: Matrix;
  104303. /**
  104304. * @hidden
  104305. */
  104306. readonly rightHMatrix: Matrix;
  104307. /**
  104308. * @hidden
  104309. */
  104310. readonly leftPreViewMatrix: Matrix;
  104311. /**
  104312. * @hidden
  104313. */
  104314. readonly rightPreViewMatrix: Matrix;
  104315. /**
  104316. * Get the default VRMetrics based on the most generic setup.
  104317. * @returns the default vr metrics
  104318. */
  104319. static GetDefault(): VRCameraMetrics;
  104320. }
  104321. }
  104322. declare module BABYLON {
  104323. /** @hidden */
  104324. export var vrDistortionCorrectionPixelShader: {
  104325. name: string;
  104326. shader: string;
  104327. };
  104328. }
  104329. declare module BABYLON {
  104330. /**
  104331. * VRDistortionCorrectionPostProcess used for mobile VR
  104332. */
  104333. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104334. private _isRightEye;
  104335. private _distortionFactors;
  104336. private _postProcessScaleFactor;
  104337. private _lensCenterOffset;
  104338. private _scaleIn;
  104339. private _scaleFactor;
  104340. private _lensCenter;
  104341. /**
  104342. * Initializes the VRDistortionCorrectionPostProcess
  104343. * @param name The name of the effect.
  104344. * @param camera The camera to apply the render pass to.
  104345. * @param isRightEye If this is for the right eye distortion
  104346. * @param vrMetrics All the required metrics for the VR camera
  104347. */
  104348. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104349. }
  104350. }
  104351. declare module BABYLON {
  104352. /**
  104353. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104354. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104355. */
  104356. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104357. /**
  104358. * Creates a new VRDeviceOrientationArcRotateCamera
  104359. * @param name defines camera name
  104360. * @param alpha defines the camera rotation along the logitudinal axis
  104361. * @param beta defines the camera rotation along the latitudinal axis
  104362. * @param radius defines the camera distance from its target
  104363. * @param target defines the camera target
  104364. * @param scene defines the scene the camera belongs to
  104365. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104366. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104367. */
  104368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104369. /**
  104370. * Gets camera class name
  104371. * @returns VRDeviceOrientationArcRotateCamera
  104372. */
  104373. getClassName(): string;
  104374. }
  104375. }
  104376. declare module BABYLON {
  104377. /**
  104378. * Camera used to simulate VR rendering (based on FreeCamera)
  104379. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104380. */
  104381. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104382. /**
  104383. * Creates a new VRDeviceOrientationFreeCamera
  104384. * @param name defines camera name
  104385. * @param position defines the start position of the camera
  104386. * @param scene defines the scene the camera belongs to
  104387. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104388. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104389. */
  104390. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104391. /**
  104392. * Gets camera class name
  104393. * @returns VRDeviceOrientationFreeCamera
  104394. */
  104395. getClassName(): string;
  104396. }
  104397. }
  104398. declare module BABYLON {
  104399. /**
  104400. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  104401. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104402. */
  104403. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  104404. /**
  104405. * Creates a new VRDeviceOrientationGamepadCamera
  104406. * @param name defines camera name
  104407. * @param position defines the start position of the camera
  104408. * @param scene defines the scene the camera belongs to
  104409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104411. */
  104412. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104413. /**
  104414. * Gets camera class name
  104415. * @returns VRDeviceOrientationGamepadCamera
  104416. */
  104417. getClassName(): string;
  104418. }
  104419. }
  104420. declare module BABYLON {
  104421. /**
  104422. * Base class of materials working in push mode in babylon JS
  104423. * @hidden
  104424. */
  104425. export class PushMaterial extends Material {
  104426. protected _activeEffect: Effect;
  104427. protected _normalMatrix: Matrix;
  104428. /**
  104429. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  104430. * This means that the material can keep using a previous shader while a new one is being compiled.
  104431. * This is mostly used when shader parallel compilation is supported (true by default)
  104432. */
  104433. allowShaderHotSwapping: boolean;
  104434. constructor(name: string, scene: Scene);
  104435. getEffect(): Effect;
  104436. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104437. /**
  104438. * Binds the given world matrix to the active effect
  104439. *
  104440. * @param world the matrix to bind
  104441. */
  104442. bindOnlyWorldMatrix(world: Matrix): void;
  104443. /**
  104444. * Binds the given normal matrix to the active effect
  104445. *
  104446. * @param normalMatrix the matrix to bind
  104447. */
  104448. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104449. bind(world: Matrix, mesh?: Mesh): void;
  104450. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104451. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104452. }
  104453. }
  104454. declare module BABYLON {
  104455. /**
  104456. * This groups all the flags used to control the materials channel.
  104457. */
  104458. export class MaterialFlags {
  104459. private static _DiffuseTextureEnabled;
  104460. /**
  104461. * Are diffuse textures enabled in the application.
  104462. */
  104463. static DiffuseTextureEnabled: boolean;
  104464. private static _AmbientTextureEnabled;
  104465. /**
  104466. * Are ambient textures enabled in the application.
  104467. */
  104468. static AmbientTextureEnabled: boolean;
  104469. private static _OpacityTextureEnabled;
  104470. /**
  104471. * Are opacity textures enabled in the application.
  104472. */
  104473. static OpacityTextureEnabled: boolean;
  104474. private static _ReflectionTextureEnabled;
  104475. /**
  104476. * Are reflection textures enabled in the application.
  104477. */
  104478. static ReflectionTextureEnabled: boolean;
  104479. private static _EmissiveTextureEnabled;
  104480. /**
  104481. * Are emissive textures enabled in the application.
  104482. */
  104483. static EmissiveTextureEnabled: boolean;
  104484. private static _SpecularTextureEnabled;
  104485. /**
  104486. * Are specular textures enabled in the application.
  104487. */
  104488. static SpecularTextureEnabled: boolean;
  104489. private static _BumpTextureEnabled;
  104490. /**
  104491. * Are bump textures enabled in the application.
  104492. */
  104493. static BumpTextureEnabled: boolean;
  104494. private static _LightmapTextureEnabled;
  104495. /**
  104496. * Are lightmap textures enabled in the application.
  104497. */
  104498. static LightmapTextureEnabled: boolean;
  104499. private static _RefractionTextureEnabled;
  104500. /**
  104501. * Are refraction textures enabled in the application.
  104502. */
  104503. static RefractionTextureEnabled: boolean;
  104504. private static _ColorGradingTextureEnabled;
  104505. /**
  104506. * Are color grading textures enabled in the application.
  104507. */
  104508. static ColorGradingTextureEnabled: boolean;
  104509. private static _FresnelEnabled;
  104510. /**
  104511. * Are fresnels enabled in the application.
  104512. */
  104513. static FresnelEnabled: boolean;
  104514. private static _ClearCoatTextureEnabled;
  104515. /**
  104516. * Are clear coat textures enabled in the application.
  104517. */
  104518. static ClearCoatTextureEnabled: boolean;
  104519. private static _ClearCoatBumpTextureEnabled;
  104520. /**
  104521. * Are clear coat bump textures enabled in the application.
  104522. */
  104523. static ClearCoatBumpTextureEnabled: boolean;
  104524. private static _ClearCoatTintTextureEnabled;
  104525. /**
  104526. * Are clear coat tint textures enabled in the application.
  104527. */
  104528. static ClearCoatTintTextureEnabled: boolean;
  104529. private static _SheenTextureEnabled;
  104530. /**
  104531. * Are sheen textures enabled in the application.
  104532. */
  104533. static SheenTextureEnabled: boolean;
  104534. private static _AnisotropicTextureEnabled;
  104535. /**
  104536. * Are anisotropic textures enabled in the application.
  104537. */
  104538. static AnisotropicTextureEnabled: boolean;
  104539. private static _ThicknessTextureEnabled;
  104540. /**
  104541. * Are thickness textures enabled in the application.
  104542. */
  104543. static ThicknessTextureEnabled: boolean;
  104544. }
  104545. }
  104546. declare module BABYLON {
  104547. /** @hidden */
  104548. export var defaultFragmentDeclaration: {
  104549. name: string;
  104550. shader: string;
  104551. };
  104552. }
  104553. declare module BABYLON {
  104554. /** @hidden */
  104555. export var defaultUboDeclaration: {
  104556. name: string;
  104557. shader: string;
  104558. };
  104559. }
  104560. declare module BABYLON {
  104561. /** @hidden */
  104562. export var lightFragmentDeclaration: {
  104563. name: string;
  104564. shader: string;
  104565. };
  104566. }
  104567. declare module BABYLON {
  104568. /** @hidden */
  104569. export var lightUboDeclaration: {
  104570. name: string;
  104571. shader: string;
  104572. };
  104573. }
  104574. declare module BABYLON {
  104575. /** @hidden */
  104576. export var lightsFragmentFunctions: {
  104577. name: string;
  104578. shader: string;
  104579. };
  104580. }
  104581. declare module BABYLON {
  104582. /** @hidden */
  104583. export var shadowsFragmentFunctions: {
  104584. name: string;
  104585. shader: string;
  104586. };
  104587. }
  104588. declare module BABYLON {
  104589. /** @hidden */
  104590. export var fresnelFunction: {
  104591. name: string;
  104592. shader: string;
  104593. };
  104594. }
  104595. declare module BABYLON {
  104596. /** @hidden */
  104597. export var reflectionFunction: {
  104598. name: string;
  104599. shader: string;
  104600. };
  104601. }
  104602. declare module BABYLON {
  104603. /** @hidden */
  104604. export var bumpFragmentFunctions: {
  104605. name: string;
  104606. shader: string;
  104607. };
  104608. }
  104609. declare module BABYLON {
  104610. /** @hidden */
  104611. export var logDepthDeclaration: {
  104612. name: string;
  104613. shader: string;
  104614. };
  104615. }
  104616. declare module BABYLON {
  104617. /** @hidden */
  104618. export var bumpFragment: {
  104619. name: string;
  104620. shader: string;
  104621. };
  104622. }
  104623. declare module BABYLON {
  104624. /** @hidden */
  104625. export var depthPrePass: {
  104626. name: string;
  104627. shader: string;
  104628. };
  104629. }
  104630. declare module BABYLON {
  104631. /** @hidden */
  104632. export var lightFragment: {
  104633. name: string;
  104634. shader: string;
  104635. };
  104636. }
  104637. declare module BABYLON {
  104638. /** @hidden */
  104639. export var logDepthFragment: {
  104640. name: string;
  104641. shader: string;
  104642. };
  104643. }
  104644. declare module BABYLON {
  104645. /** @hidden */
  104646. export var defaultPixelShader: {
  104647. name: string;
  104648. shader: string;
  104649. };
  104650. }
  104651. declare module BABYLON {
  104652. /** @hidden */
  104653. export var defaultVertexDeclaration: {
  104654. name: string;
  104655. shader: string;
  104656. };
  104657. }
  104658. declare module BABYLON {
  104659. /** @hidden */
  104660. export var bumpVertexDeclaration: {
  104661. name: string;
  104662. shader: string;
  104663. };
  104664. }
  104665. declare module BABYLON {
  104666. /** @hidden */
  104667. export var bumpVertex: {
  104668. name: string;
  104669. shader: string;
  104670. };
  104671. }
  104672. declare module BABYLON {
  104673. /** @hidden */
  104674. export var fogVertex: {
  104675. name: string;
  104676. shader: string;
  104677. };
  104678. }
  104679. declare module BABYLON {
  104680. /** @hidden */
  104681. export var shadowsVertex: {
  104682. name: string;
  104683. shader: string;
  104684. };
  104685. }
  104686. declare module BABYLON {
  104687. /** @hidden */
  104688. export var pointCloudVertex: {
  104689. name: string;
  104690. shader: string;
  104691. };
  104692. }
  104693. declare module BABYLON {
  104694. /** @hidden */
  104695. export var logDepthVertex: {
  104696. name: string;
  104697. shader: string;
  104698. };
  104699. }
  104700. declare module BABYLON {
  104701. /** @hidden */
  104702. export var defaultVertexShader: {
  104703. name: string;
  104704. shader: string;
  104705. };
  104706. }
  104707. declare module BABYLON {
  104708. /** @hidden */
  104709. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104710. MAINUV1: boolean;
  104711. MAINUV2: boolean;
  104712. DIFFUSE: boolean;
  104713. DIFFUSEDIRECTUV: number;
  104714. AMBIENT: boolean;
  104715. AMBIENTDIRECTUV: number;
  104716. OPACITY: boolean;
  104717. OPACITYDIRECTUV: number;
  104718. OPACITYRGB: boolean;
  104719. REFLECTION: boolean;
  104720. EMISSIVE: boolean;
  104721. EMISSIVEDIRECTUV: number;
  104722. SPECULAR: boolean;
  104723. SPECULARDIRECTUV: number;
  104724. BUMP: boolean;
  104725. BUMPDIRECTUV: number;
  104726. PARALLAX: boolean;
  104727. PARALLAXOCCLUSION: boolean;
  104728. SPECULAROVERALPHA: boolean;
  104729. CLIPPLANE: boolean;
  104730. CLIPPLANE2: boolean;
  104731. CLIPPLANE3: boolean;
  104732. CLIPPLANE4: boolean;
  104733. ALPHATEST: boolean;
  104734. DEPTHPREPASS: boolean;
  104735. ALPHAFROMDIFFUSE: boolean;
  104736. POINTSIZE: boolean;
  104737. FOG: boolean;
  104738. SPECULARTERM: boolean;
  104739. DIFFUSEFRESNEL: boolean;
  104740. OPACITYFRESNEL: boolean;
  104741. REFLECTIONFRESNEL: boolean;
  104742. REFRACTIONFRESNEL: boolean;
  104743. EMISSIVEFRESNEL: boolean;
  104744. FRESNEL: boolean;
  104745. NORMAL: boolean;
  104746. UV1: boolean;
  104747. UV2: boolean;
  104748. VERTEXCOLOR: boolean;
  104749. VERTEXALPHA: boolean;
  104750. NUM_BONE_INFLUENCERS: number;
  104751. BonesPerMesh: number;
  104752. BONETEXTURE: boolean;
  104753. INSTANCES: boolean;
  104754. GLOSSINESS: boolean;
  104755. ROUGHNESS: boolean;
  104756. EMISSIVEASILLUMINATION: boolean;
  104757. LINKEMISSIVEWITHDIFFUSE: boolean;
  104758. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104759. LIGHTMAP: boolean;
  104760. LIGHTMAPDIRECTUV: number;
  104761. OBJECTSPACE_NORMALMAP: boolean;
  104762. USELIGHTMAPASSHADOWMAP: boolean;
  104763. REFLECTIONMAP_3D: boolean;
  104764. REFLECTIONMAP_SPHERICAL: boolean;
  104765. REFLECTIONMAP_PLANAR: boolean;
  104766. REFLECTIONMAP_CUBIC: boolean;
  104767. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104768. REFLECTIONMAP_PROJECTION: boolean;
  104769. REFLECTIONMAP_SKYBOX: boolean;
  104770. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104771. REFLECTIONMAP_EXPLICIT: boolean;
  104772. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104773. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104774. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104775. INVERTCUBICMAP: boolean;
  104776. LOGARITHMICDEPTH: boolean;
  104777. REFRACTION: boolean;
  104778. REFRACTIONMAP_3D: boolean;
  104779. REFLECTIONOVERALPHA: boolean;
  104780. TWOSIDEDLIGHTING: boolean;
  104781. SHADOWFLOAT: boolean;
  104782. MORPHTARGETS: boolean;
  104783. MORPHTARGETS_NORMAL: boolean;
  104784. MORPHTARGETS_TANGENT: boolean;
  104785. MORPHTARGETS_UV: boolean;
  104786. NUM_MORPH_INFLUENCERS: number;
  104787. NONUNIFORMSCALING: boolean;
  104788. PREMULTIPLYALPHA: boolean;
  104789. IMAGEPROCESSING: boolean;
  104790. VIGNETTE: boolean;
  104791. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104792. VIGNETTEBLENDMODEOPAQUE: boolean;
  104793. TONEMAPPING: boolean;
  104794. TONEMAPPING_ACES: boolean;
  104795. CONTRAST: boolean;
  104796. COLORCURVES: boolean;
  104797. COLORGRADING: boolean;
  104798. COLORGRADING3D: boolean;
  104799. SAMPLER3DGREENDEPTH: boolean;
  104800. SAMPLER3DBGRMAP: boolean;
  104801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104802. MULTIVIEW: boolean;
  104803. /**
  104804. * If the reflection texture on this material is in linear color space
  104805. * @hidden
  104806. */
  104807. IS_REFLECTION_LINEAR: boolean;
  104808. /**
  104809. * If the refraction texture on this material is in linear color space
  104810. * @hidden
  104811. */
  104812. IS_REFRACTION_LINEAR: boolean;
  104813. EXPOSURE: boolean;
  104814. constructor();
  104815. setReflectionMode(modeToEnable: string): void;
  104816. }
  104817. /**
  104818. * This is the default material used in Babylon. It is the best trade off between quality
  104819. * and performances.
  104820. * @see http://doc.babylonjs.com/babylon101/materials
  104821. */
  104822. export class StandardMaterial extends PushMaterial {
  104823. private _diffuseTexture;
  104824. /**
  104825. * The basic texture of the material as viewed under a light.
  104826. */
  104827. diffuseTexture: Nullable<BaseTexture>;
  104828. private _ambientTexture;
  104829. /**
  104830. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104831. */
  104832. ambientTexture: Nullable<BaseTexture>;
  104833. private _opacityTexture;
  104834. /**
  104835. * Define the transparency of the material from a texture.
  104836. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104837. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104838. */
  104839. opacityTexture: Nullable<BaseTexture>;
  104840. private _reflectionTexture;
  104841. /**
  104842. * Define the texture used to display the reflection.
  104843. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104844. */
  104845. reflectionTexture: Nullable<BaseTexture>;
  104846. private _emissiveTexture;
  104847. /**
  104848. * Define texture of the material as if self lit.
  104849. * This will be mixed in the final result even in the absence of light.
  104850. */
  104851. emissiveTexture: Nullable<BaseTexture>;
  104852. private _specularTexture;
  104853. /**
  104854. * Define how the color and intensity of the highlight given by the light in the material.
  104855. */
  104856. specularTexture: Nullable<BaseTexture>;
  104857. private _bumpTexture;
  104858. /**
  104859. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104860. * 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.
  104861. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104862. */
  104863. bumpTexture: Nullable<BaseTexture>;
  104864. private _lightmapTexture;
  104865. /**
  104866. * Complex lighting can be computationally expensive to compute at runtime.
  104867. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104868. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104869. */
  104870. lightmapTexture: Nullable<BaseTexture>;
  104871. private _refractionTexture;
  104872. /**
  104873. * Define the texture used to display the refraction.
  104874. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104875. */
  104876. refractionTexture: Nullable<BaseTexture>;
  104877. /**
  104878. * The color of the material lit by the environmental background lighting.
  104879. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104880. */
  104881. ambientColor: Color3;
  104882. /**
  104883. * The basic color of the material as viewed under a light.
  104884. */
  104885. diffuseColor: Color3;
  104886. /**
  104887. * Define how the color and intensity of the highlight given by the light in the material.
  104888. */
  104889. specularColor: Color3;
  104890. /**
  104891. * Define the color of the material as if self lit.
  104892. * This will be mixed in the final result even in the absence of light.
  104893. */
  104894. emissiveColor: Color3;
  104895. /**
  104896. * Defines how sharp are the highlights in the material.
  104897. * The bigger the value the sharper giving a more glossy feeling to the result.
  104898. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104899. */
  104900. specularPower: number;
  104901. private _useAlphaFromDiffuseTexture;
  104902. /**
  104903. * Does the transparency come from the diffuse texture alpha channel.
  104904. */
  104905. useAlphaFromDiffuseTexture: boolean;
  104906. private _useEmissiveAsIllumination;
  104907. /**
  104908. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104909. */
  104910. useEmissiveAsIllumination: boolean;
  104911. private _linkEmissiveWithDiffuse;
  104912. /**
  104913. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104914. * the emissive level when the final color is close to one.
  104915. */
  104916. linkEmissiveWithDiffuse: boolean;
  104917. private _useSpecularOverAlpha;
  104918. /**
  104919. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104920. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104921. */
  104922. useSpecularOverAlpha: boolean;
  104923. private _useReflectionOverAlpha;
  104924. /**
  104925. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104926. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104927. */
  104928. useReflectionOverAlpha: boolean;
  104929. private _disableLighting;
  104930. /**
  104931. * Does lights from the scene impacts this material.
  104932. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104933. */
  104934. disableLighting: boolean;
  104935. private _useObjectSpaceNormalMap;
  104936. /**
  104937. * Allows using an object space normal map (instead of tangent space).
  104938. */
  104939. useObjectSpaceNormalMap: boolean;
  104940. private _useParallax;
  104941. /**
  104942. * Is parallax enabled or not.
  104943. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104944. */
  104945. useParallax: boolean;
  104946. private _useParallaxOcclusion;
  104947. /**
  104948. * Is parallax occlusion enabled or not.
  104949. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104950. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104951. */
  104952. useParallaxOcclusion: boolean;
  104953. /**
  104954. * 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.
  104955. */
  104956. parallaxScaleBias: number;
  104957. private _roughness;
  104958. /**
  104959. * Helps to define how blurry the reflections should appears in the material.
  104960. */
  104961. roughness: number;
  104962. /**
  104963. * In case of refraction, define the value of the index of refraction.
  104964. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104965. */
  104966. indexOfRefraction: number;
  104967. /**
  104968. * Invert the refraction texture alongside the y axis.
  104969. * It can be useful with procedural textures or probe for instance.
  104970. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104971. */
  104972. invertRefractionY: boolean;
  104973. /**
  104974. * Defines the alpha limits in alpha test mode.
  104975. */
  104976. alphaCutOff: number;
  104977. private _useLightmapAsShadowmap;
  104978. /**
  104979. * In case of light mapping, define whether the map contains light or shadow informations.
  104980. */
  104981. useLightmapAsShadowmap: boolean;
  104982. private _diffuseFresnelParameters;
  104983. /**
  104984. * Define the diffuse fresnel parameters of the material.
  104985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104986. */
  104987. diffuseFresnelParameters: FresnelParameters;
  104988. private _opacityFresnelParameters;
  104989. /**
  104990. * Define the opacity fresnel parameters of the material.
  104991. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104992. */
  104993. opacityFresnelParameters: FresnelParameters;
  104994. private _reflectionFresnelParameters;
  104995. /**
  104996. * Define the reflection fresnel parameters of the material.
  104997. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104998. */
  104999. reflectionFresnelParameters: FresnelParameters;
  105000. private _refractionFresnelParameters;
  105001. /**
  105002. * Define the refraction fresnel parameters of the material.
  105003. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105004. */
  105005. refractionFresnelParameters: FresnelParameters;
  105006. private _emissiveFresnelParameters;
  105007. /**
  105008. * Define the emissive fresnel parameters of the material.
  105009. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105010. */
  105011. emissiveFresnelParameters: FresnelParameters;
  105012. private _useReflectionFresnelFromSpecular;
  105013. /**
  105014. * If true automatically deducts the fresnels values from the material specularity.
  105015. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105016. */
  105017. useReflectionFresnelFromSpecular: boolean;
  105018. private _useGlossinessFromSpecularMapAlpha;
  105019. /**
  105020. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105021. */
  105022. useGlossinessFromSpecularMapAlpha: boolean;
  105023. private _maxSimultaneousLights;
  105024. /**
  105025. * Defines the maximum number of lights that can be used in the material
  105026. */
  105027. maxSimultaneousLights: number;
  105028. private _invertNormalMapX;
  105029. /**
  105030. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105031. */
  105032. invertNormalMapX: boolean;
  105033. private _invertNormalMapY;
  105034. /**
  105035. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105036. */
  105037. invertNormalMapY: boolean;
  105038. private _twoSidedLighting;
  105039. /**
  105040. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105041. */
  105042. twoSidedLighting: boolean;
  105043. /**
  105044. * Default configuration related to image processing available in the standard Material.
  105045. */
  105046. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105047. /**
  105048. * Gets the image processing configuration used either in this material.
  105049. */
  105050. /**
  105051. * Sets the Default image processing configuration used either in the this material.
  105052. *
  105053. * If sets to null, the scene one is in use.
  105054. */
  105055. imageProcessingConfiguration: ImageProcessingConfiguration;
  105056. /**
  105057. * Keep track of the image processing observer to allow dispose and replace.
  105058. */
  105059. private _imageProcessingObserver;
  105060. /**
  105061. * Attaches a new image processing configuration to the Standard Material.
  105062. * @param configuration
  105063. */
  105064. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105065. /**
  105066. * Gets wether the color curves effect is enabled.
  105067. */
  105068. /**
  105069. * Sets wether the color curves effect is enabled.
  105070. */
  105071. cameraColorCurvesEnabled: boolean;
  105072. /**
  105073. * Gets wether the color grading effect is enabled.
  105074. */
  105075. /**
  105076. * Gets wether the color grading effect is enabled.
  105077. */
  105078. cameraColorGradingEnabled: boolean;
  105079. /**
  105080. * Gets wether tonemapping is enabled or not.
  105081. */
  105082. /**
  105083. * Sets wether tonemapping is enabled or not
  105084. */
  105085. cameraToneMappingEnabled: boolean;
  105086. /**
  105087. * The camera exposure used on this material.
  105088. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105089. * This corresponds to a photographic exposure.
  105090. */
  105091. /**
  105092. * The camera exposure used on this material.
  105093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105094. * This corresponds to a photographic exposure.
  105095. */
  105096. cameraExposure: number;
  105097. /**
  105098. * Gets The camera contrast used on this material.
  105099. */
  105100. /**
  105101. * Sets The camera contrast used on this material.
  105102. */
  105103. cameraContrast: number;
  105104. /**
  105105. * Gets the Color Grading 2D Lookup Texture.
  105106. */
  105107. /**
  105108. * Sets the Color Grading 2D Lookup Texture.
  105109. */
  105110. cameraColorGradingTexture: Nullable<BaseTexture>;
  105111. /**
  105112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105114. * 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;
  105115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105116. */
  105117. /**
  105118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105120. * 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;
  105121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105122. */
  105123. cameraColorCurves: Nullable<ColorCurves>;
  105124. /**
  105125. * Custom callback helping to override the default shader used in the material.
  105126. */
  105127. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105128. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105129. protected _worldViewProjectionMatrix: Matrix;
  105130. protected _globalAmbientColor: Color3;
  105131. protected _useLogarithmicDepth: boolean;
  105132. /**
  105133. * Instantiates a new standard material.
  105134. * This is the default material used in Babylon. It is the best trade off between quality
  105135. * and performances.
  105136. * @see http://doc.babylonjs.com/babylon101/materials
  105137. * @param name Define the name of the material in the scene
  105138. * @param scene Define the scene the material belong to
  105139. */
  105140. constructor(name: string, scene: Scene);
  105141. /**
  105142. * Gets a boolean indicating that current material needs to register RTT
  105143. */
  105144. readonly hasRenderTargetTextures: boolean;
  105145. /**
  105146. * Gets the current class name of the material e.g. "StandardMaterial"
  105147. * Mainly use in serialization.
  105148. * @returns the class name
  105149. */
  105150. getClassName(): string;
  105151. /**
  105152. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105153. * You can try switching to logarithmic depth.
  105154. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105155. */
  105156. useLogarithmicDepth: boolean;
  105157. /**
  105158. * Specifies if the material will require alpha blending
  105159. * @returns a boolean specifying if alpha blending is needed
  105160. */
  105161. needAlphaBlending(): boolean;
  105162. /**
  105163. * Specifies if this material should be rendered in alpha test mode
  105164. * @returns a boolean specifying if an alpha test is needed.
  105165. */
  105166. needAlphaTesting(): boolean;
  105167. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105168. /**
  105169. * Get the texture used for alpha test purpose.
  105170. * @returns the diffuse texture in case of the standard material.
  105171. */
  105172. getAlphaTestTexture(): Nullable<BaseTexture>;
  105173. /**
  105174. * Get if the submesh is ready to be used and all its information available.
  105175. * Child classes can use it to update shaders
  105176. * @param mesh defines the mesh to check
  105177. * @param subMesh defines which submesh to check
  105178. * @param useInstances specifies that instances should be used
  105179. * @returns a boolean indicating that the submesh is ready or not
  105180. */
  105181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105182. /**
  105183. * Builds the material UBO layouts.
  105184. * Used internally during the effect preparation.
  105185. */
  105186. buildUniformLayout(): void;
  105187. /**
  105188. * Unbinds the material from the mesh
  105189. */
  105190. unbind(): void;
  105191. /**
  105192. * Binds the submesh to this material by preparing the effect and shader to draw
  105193. * @param world defines the world transformation matrix
  105194. * @param mesh defines the mesh containing the submesh
  105195. * @param subMesh defines the submesh to bind the material to
  105196. */
  105197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105198. /**
  105199. * Get the list of animatables in the material.
  105200. * @returns the list of animatables object used in the material
  105201. */
  105202. getAnimatables(): IAnimatable[];
  105203. /**
  105204. * Gets the active textures from the material
  105205. * @returns an array of textures
  105206. */
  105207. getActiveTextures(): BaseTexture[];
  105208. /**
  105209. * Specifies if the material uses a texture
  105210. * @param texture defines the texture to check against the material
  105211. * @returns a boolean specifying if the material uses the texture
  105212. */
  105213. hasTexture(texture: BaseTexture): boolean;
  105214. /**
  105215. * Disposes the material
  105216. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105217. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105218. */
  105219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105220. /**
  105221. * Makes a duplicate of the material, and gives it a new name
  105222. * @param name defines the new name for the duplicated material
  105223. * @returns the cloned material
  105224. */
  105225. clone(name: string): StandardMaterial;
  105226. /**
  105227. * Serializes this material in a JSON representation
  105228. * @returns the serialized material object
  105229. */
  105230. serialize(): any;
  105231. /**
  105232. * Creates a standard material from parsed material data
  105233. * @param source defines the JSON representation of the material
  105234. * @param scene defines the hosting scene
  105235. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105236. * @returns a new standard material
  105237. */
  105238. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105239. /**
  105240. * Are diffuse textures enabled in the application.
  105241. */
  105242. static DiffuseTextureEnabled: boolean;
  105243. /**
  105244. * Are ambient textures enabled in the application.
  105245. */
  105246. static AmbientTextureEnabled: boolean;
  105247. /**
  105248. * Are opacity textures enabled in the application.
  105249. */
  105250. static OpacityTextureEnabled: boolean;
  105251. /**
  105252. * Are reflection textures enabled in the application.
  105253. */
  105254. static ReflectionTextureEnabled: boolean;
  105255. /**
  105256. * Are emissive textures enabled in the application.
  105257. */
  105258. static EmissiveTextureEnabled: boolean;
  105259. /**
  105260. * Are specular textures enabled in the application.
  105261. */
  105262. static SpecularTextureEnabled: boolean;
  105263. /**
  105264. * Are bump textures enabled in the application.
  105265. */
  105266. static BumpTextureEnabled: boolean;
  105267. /**
  105268. * Are lightmap textures enabled in the application.
  105269. */
  105270. static LightmapTextureEnabled: boolean;
  105271. /**
  105272. * Are refraction textures enabled in the application.
  105273. */
  105274. static RefractionTextureEnabled: boolean;
  105275. /**
  105276. * Are color grading textures enabled in the application.
  105277. */
  105278. static ColorGradingTextureEnabled: boolean;
  105279. /**
  105280. * Are fresnels enabled in the application.
  105281. */
  105282. static FresnelEnabled: boolean;
  105283. }
  105284. }
  105285. declare module BABYLON {
  105286. /**
  105287. * A class extending Texture allowing drawing on a texture
  105288. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105289. */
  105290. export class DynamicTexture extends Texture {
  105291. private _generateMipMaps;
  105292. private _canvas;
  105293. private _context;
  105294. private _engine;
  105295. /**
  105296. * Creates a DynamicTexture
  105297. * @param name defines the name of the texture
  105298. * @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
  105299. * @param scene defines the scene where you want the texture
  105300. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105301. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105302. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105303. */
  105304. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105305. /**
  105306. * Get the current class name of the texture useful for serialization or dynamic coding.
  105307. * @returns "DynamicTexture"
  105308. */
  105309. getClassName(): string;
  105310. /**
  105311. * Gets the current state of canRescale
  105312. */
  105313. readonly canRescale: boolean;
  105314. private _recreate;
  105315. /**
  105316. * Scales the texture
  105317. * @param ratio the scale factor to apply to both width and height
  105318. */
  105319. scale(ratio: number): void;
  105320. /**
  105321. * Resizes the texture
  105322. * @param width the new width
  105323. * @param height the new height
  105324. */
  105325. scaleTo(width: number, height: number): void;
  105326. /**
  105327. * Gets the context of the canvas used by the texture
  105328. * @returns the canvas context of the dynamic texture
  105329. */
  105330. getContext(): CanvasRenderingContext2D;
  105331. /**
  105332. * Clears the texture
  105333. */
  105334. clear(): void;
  105335. /**
  105336. * Updates the texture
  105337. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105338. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105339. */
  105340. update(invertY?: boolean, premulAlpha?: boolean): void;
  105341. /**
  105342. * Draws text onto the texture
  105343. * @param text defines the text to be drawn
  105344. * @param x defines the placement of the text from the left
  105345. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105346. * @param font defines the font to be used with font-style, font-size, font-name
  105347. * @param color defines the color used for the text
  105348. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105349. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105350. * @param update defines whether texture is immediately update (default is true)
  105351. */
  105352. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105353. /**
  105354. * Clones the texture
  105355. * @returns the clone of the texture.
  105356. */
  105357. clone(): DynamicTexture;
  105358. /**
  105359. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105360. * @returns a serialized dynamic texture object
  105361. */
  105362. serialize(): any;
  105363. /** @hidden */
  105364. _rebuild(): void;
  105365. }
  105366. }
  105367. declare module BABYLON {
  105368. /** @hidden */
  105369. export var imageProcessingPixelShader: {
  105370. name: string;
  105371. shader: string;
  105372. };
  105373. }
  105374. declare module BABYLON {
  105375. /**
  105376. * ImageProcessingPostProcess
  105377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105378. */
  105379. export class ImageProcessingPostProcess extends PostProcess {
  105380. /**
  105381. * Default configuration related to image processing available in the PBR Material.
  105382. */
  105383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105384. /**
  105385. * Gets the image processing configuration used either in this material.
  105386. */
  105387. /**
  105388. * Sets the Default image processing configuration used either in the this material.
  105389. *
  105390. * If sets to null, the scene one is in use.
  105391. */
  105392. imageProcessingConfiguration: ImageProcessingConfiguration;
  105393. /**
  105394. * Keep track of the image processing observer to allow dispose and replace.
  105395. */
  105396. private _imageProcessingObserver;
  105397. /**
  105398. * Attaches a new image processing configuration to the PBR Material.
  105399. * @param configuration
  105400. */
  105401. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  105402. /**
  105403. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105404. */
  105405. /**
  105406. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105407. */
  105408. colorCurves: Nullable<ColorCurves>;
  105409. /**
  105410. * Gets wether the color curves effect is enabled.
  105411. */
  105412. /**
  105413. * Sets wether the color curves effect is enabled.
  105414. */
  105415. colorCurvesEnabled: boolean;
  105416. /**
  105417. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105418. */
  105419. /**
  105420. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105421. */
  105422. colorGradingTexture: Nullable<BaseTexture>;
  105423. /**
  105424. * Gets wether the color grading effect is enabled.
  105425. */
  105426. /**
  105427. * Gets wether the color grading effect is enabled.
  105428. */
  105429. colorGradingEnabled: boolean;
  105430. /**
  105431. * Gets exposure used in the effect.
  105432. */
  105433. /**
  105434. * Sets exposure used in the effect.
  105435. */
  105436. exposure: number;
  105437. /**
  105438. * Gets wether tonemapping is enabled or not.
  105439. */
  105440. /**
  105441. * Sets wether tonemapping is enabled or not
  105442. */
  105443. toneMappingEnabled: boolean;
  105444. /**
  105445. * Gets the type of tone mapping effect.
  105446. */
  105447. /**
  105448. * Sets the type of tone mapping effect.
  105449. */
  105450. toneMappingType: number;
  105451. /**
  105452. * Gets contrast used in the effect.
  105453. */
  105454. /**
  105455. * Sets contrast used in the effect.
  105456. */
  105457. contrast: number;
  105458. /**
  105459. * Gets Vignette stretch size.
  105460. */
  105461. /**
  105462. * Sets Vignette stretch size.
  105463. */
  105464. vignetteStretch: number;
  105465. /**
  105466. * Gets Vignette centre X Offset.
  105467. */
  105468. /**
  105469. * Sets Vignette centre X Offset.
  105470. */
  105471. vignetteCentreX: number;
  105472. /**
  105473. * Gets Vignette centre Y Offset.
  105474. */
  105475. /**
  105476. * Sets Vignette centre Y Offset.
  105477. */
  105478. vignetteCentreY: number;
  105479. /**
  105480. * Gets Vignette weight or intensity of the vignette effect.
  105481. */
  105482. /**
  105483. * Sets Vignette weight or intensity of the vignette effect.
  105484. */
  105485. vignetteWeight: number;
  105486. /**
  105487. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105488. * if vignetteEnabled is set to true.
  105489. */
  105490. /**
  105491. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105492. * if vignetteEnabled is set to true.
  105493. */
  105494. vignetteColor: Color4;
  105495. /**
  105496. * Gets Camera field of view used by the Vignette effect.
  105497. */
  105498. /**
  105499. * Sets Camera field of view used by the Vignette effect.
  105500. */
  105501. vignetteCameraFov: number;
  105502. /**
  105503. * Gets the vignette blend mode allowing different kind of effect.
  105504. */
  105505. /**
  105506. * Sets the vignette blend mode allowing different kind of effect.
  105507. */
  105508. vignetteBlendMode: number;
  105509. /**
  105510. * Gets wether the vignette effect is enabled.
  105511. */
  105512. /**
  105513. * Sets wether the vignette effect is enabled.
  105514. */
  105515. vignetteEnabled: boolean;
  105516. private _fromLinearSpace;
  105517. /**
  105518. * Gets wether the input of the processing is in Gamma or Linear Space.
  105519. */
  105520. /**
  105521. * Sets wether the input of the processing is in Gamma or Linear Space.
  105522. */
  105523. fromLinearSpace: boolean;
  105524. /**
  105525. * Defines cache preventing GC.
  105526. */
  105527. private _defines;
  105528. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105529. /**
  105530. * "ImageProcessingPostProcess"
  105531. * @returns "ImageProcessingPostProcess"
  105532. */
  105533. getClassName(): string;
  105534. protected _updateParameters(): void;
  105535. dispose(camera?: Camera): void;
  105536. }
  105537. }
  105538. declare module BABYLON {
  105539. /**
  105540. * Class containing static functions to help procedurally build meshes
  105541. */
  105542. export class GroundBuilder {
  105543. /**
  105544. * Creates a ground mesh
  105545. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105546. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105548. * @param name defines the name of the mesh
  105549. * @param options defines the options used to create the mesh
  105550. * @param scene defines the hosting scene
  105551. * @returns the ground mesh
  105552. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105553. */
  105554. static CreateGround(name: string, options: {
  105555. width?: number;
  105556. height?: number;
  105557. subdivisions?: number;
  105558. subdivisionsX?: number;
  105559. subdivisionsY?: number;
  105560. updatable?: boolean;
  105561. }, scene: any): Mesh;
  105562. /**
  105563. * Creates a tiled ground mesh
  105564. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105565. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105566. * * 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
  105567. * * 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
  105568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105569. * @param name defines the name of the mesh
  105570. * @param options defines the options used to create the mesh
  105571. * @param scene defines the hosting scene
  105572. * @returns the tiled ground mesh
  105573. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105574. */
  105575. static CreateTiledGround(name: string, options: {
  105576. xmin: number;
  105577. zmin: number;
  105578. xmax: number;
  105579. zmax: number;
  105580. subdivisions?: {
  105581. w: number;
  105582. h: number;
  105583. };
  105584. precision?: {
  105585. w: number;
  105586. h: number;
  105587. };
  105588. updatable?: boolean;
  105589. }, scene?: Nullable<Scene>): Mesh;
  105590. /**
  105591. * Creates a ground mesh from a height map
  105592. * * The parameter `url` sets the URL of the height map image resource.
  105593. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105594. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105595. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105596. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105597. * * 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.
  105598. * * 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).
  105599. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105601. * @param name defines the name of the mesh
  105602. * @param url defines the url to the height map
  105603. * @param options defines the options used to create the mesh
  105604. * @param scene defines the hosting scene
  105605. * @returns the ground mesh
  105606. * @see https://doc.babylonjs.com/babylon101/height_map
  105607. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105608. */
  105609. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105610. width?: number;
  105611. height?: number;
  105612. subdivisions?: number;
  105613. minHeight?: number;
  105614. maxHeight?: number;
  105615. colorFilter?: Color3;
  105616. alphaFilter?: number;
  105617. updatable?: boolean;
  105618. onReady?: (mesh: GroundMesh) => void;
  105619. }, scene?: Nullable<Scene>): GroundMesh;
  105620. }
  105621. }
  105622. declare module BABYLON {
  105623. /**
  105624. * Class containing static functions to help procedurally build meshes
  105625. */
  105626. export class TorusBuilder {
  105627. /**
  105628. * Creates a torus mesh
  105629. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105630. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105631. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105635. * @param name defines the name of the mesh
  105636. * @param options defines the options used to create the mesh
  105637. * @param scene defines the hosting scene
  105638. * @returns the torus mesh
  105639. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105640. */
  105641. static CreateTorus(name: string, options: {
  105642. diameter?: number;
  105643. thickness?: number;
  105644. tessellation?: number;
  105645. updatable?: boolean;
  105646. sideOrientation?: number;
  105647. frontUVs?: Vector4;
  105648. backUVs?: Vector4;
  105649. }, scene: any): Mesh;
  105650. }
  105651. }
  105652. declare module BABYLON {
  105653. /**
  105654. * Class containing static functions to help procedurally build meshes
  105655. */
  105656. export class CylinderBuilder {
  105657. /**
  105658. * Creates a cylinder or a cone mesh
  105659. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105660. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105661. * * 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.
  105662. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105663. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105664. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105665. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105666. * * 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).
  105667. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105668. * * 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).
  105669. * * 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
  105670. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105671. * * 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
  105672. * * 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.
  105673. * * If `enclose` is false, a ring surface is one element.
  105674. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105675. * * 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
  105676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105679. * @param name defines the name of the mesh
  105680. * @param options defines the options used to create the mesh
  105681. * @param scene defines the hosting scene
  105682. * @returns the cylinder mesh
  105683. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105684. */
  105685. static CreateCylinder(name: string, options: {
  105686. height?: number;
  105687. diameterTop?: number;
  105688. diameterBottom?: number;
  105689. diameter?: number;
  105690. tessellation?: number;
  105691. subdivisions?: number;
  105692. arc?: number;
  105693. faceColors?: Color4[];
  105694. faceUV?: Vector4[];
  105695. updatable?: boolean;
  105696. hasRings?: boolean;
  105697. enclose?: boolean;
  105698. cap?: number;
  105699. sideOrientation?: number;
  105700. frontUVs?: Vector4;
  105701. backUVs?: Vector4;
  105702. }, scene: any): Mesh;
  105703. }
  105704. }
  105705. declare module BABYLON {
  105706. /**
  105707. * Options to modify the vr teleportation behavior.
  105708. */
  105709. export interface VRTeleportationOptions {
  105710. /**
  105711. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105712. */
  105713. floorMeshName?: string;
  105714. /**
  105715. * A list of meshes to be used as the teleportation floor. (default: empty)
  105716. */
  105717. floorMeshes?: Mesh[];
  105718. }
  105719. /**
  105720. * Options to modify the vr experience helper's behavior.
  105721. */
  105722. export interface VRExperienceHelperOptions extends WebVROptions {
  105723. /**
  105724. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105725. */
  105726. createDeviceOrientationCamera?: boolean;
  105727. /**
  105728. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105729. */
  105730. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105731. /**
  105732. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105733. */
  105734. laserToggle?: boolean;
  105735. /**
  105736. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105737. */
  105738. floorMeshes?: Mesh[];
  105739. /**
  105740. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105741. */
  105742. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105743. }
  105744. /**
  105745. * Event containing information after VR has been entered
  105746. */
  105747. export class OnAfterEnteringVRObservableEvent {
  105748. /**
  105749. * If entering vr was successful
  105750. */
  105751. success: boolean;
  105752. }
  105753. /**
  105754. * Helps to quickly add VR support to an existing scene.
  105755. * See http://doc.babylonjs.com/how_to/webvr_helper
  105756. */
  105757. export class VRExperienceHelper {
  105758. /** Options to modify the vr experience helper's behavior. */
  105759. webVROptions: VRExperienceHelperOptions;
  105760. private _scene;
  105761. private _position;
  105762. private _btnVR;
  105763. private _btnVRDisplayed;
  105764. private _webVRsupported;
  105765. private _webVRready;
  105766. private _webVRrequesting;
  105767. private _webVRpresenting;
  105768. private _hasEnteredVR;
  105769. private _fullscreenVRpresenting;
  105770. private _canvas;
  105771. private _webVRCamera;
  105772. private _vrDeviceOrientationCamera;
  105773. private _deviceOrientationCamera;
  105774. private _existingCamera;
  105775. private _onKeyDown;
  105776. private _onVrDisplayPresentChange;
  105777. private _onVRDisplayChanged;
  105778. private _onVRRequestPresentStart;
  105779. private _onVRRequestPresentComplete;
  105780. /**
  105781. * 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)
  105782. */
  105783. enableGazeEvenWhenNoPointerLock: boolean;
  105784. /**
  105785. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105786. */
  105787. exitVROnDoubleTap: boolean;
  105788. /**
  105789. * Observable raised right before entering VR.
  105790. */
  105791. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105792. /**
  105793. * Observable raised when entering VR has completed.
  105794. */
  105795. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105796. /**
  105797. * Observable raised when exiting VR.
  105798. */
  105799. onExitingVRObservable: Observable<VRExperienceHelper>;
  105800. /**
  105801. * Observable raised when controller mesh is loaded.
  105802. */
  105803. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105804. /** Return this.onEnteringVRObservable
  105805. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105806. */
  105807. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105808. /** Return this.onExitingVRObservable
  105809. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105810. */
  105811. readonly onExitingVR: Observable<VRExperienceHelper>;
  105812. /** Return this.onControllerMeshLoadedObservable
  105813. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105814. */
  105815. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105816. private _rayLength;
  105817. private _useCustomVRButton;
  105818. private _teleportationRequested;
  105819. private _teleportActive;
  105820. private _floorMeshName;
  105821. private _floorMeshesCollection;
  105822. private _rotationAllowed;
  105823. private _teleportBackwardsVector;
  105824. private _teleportationTarget;
  105825. private _isDefaultTeleportationTarget;
  105826. private _postProcessMove;
  105827. private _teleportationFillColor;
  105828. private _teleportationBorderColor;
  105829. private _rotationAngle;
  105830. private _haloCenter;
  105831. private _cameraGazer;
  105832. private _padSensibilityUp;
  105833. private _padSensibilityDown;
  105834. private _leftController;
  105835. private _rightController;
  105836. /**
  105837. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105838. */
  105839. onNewMeshSelected: Observable<AbstractMesh>;
  105840. /**
  105841. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  105842. * This observable will provide the mesh and the controller used to select the mesh
  105843. */
  105844. onMeshSelectedWithController: Observable<{
  105845. mesh: AbstractMesh;
  105846. controller: WebVRController;
  105847. }>;
  105848. /**
  105849. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105850. */
  105851. onNewMeshPicked: Observable<PickingInfo>;
  105852. private _circleEase;
  105853. /**
  105854. * Observable raised before camera teleportation
  105855. */
  105856. onBeforeCameraTeleport: Observable<Vector3>;
  105857. /**
  105858. * Observable raised after camera teleportation
  105859. */
  105860. onAfterCameraTeleport: Observable<Vector3>;
  105861. /**
  105862. * Observable raised when current selected mesh gets unselected
  105863. */
  105864. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105865. private _raySelectionPredicate;
  105866. /**
  105867. * To be optionaly changed by user to define custom ray selection
  105868. */
  105869. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105870. /**
  105871. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105872. */
  105873. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105874. /**
  105875. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105876. */
  105877. teleportationEnabled: boolean;
  105878. private _defaultHeight;
  105879. private _teleportationInitialized;
  105880. private _interactionsEnabled;
  105881. private _interactionsRequested;
  105882. private _displayGaze;
  105883. private _displayLaserPointer;
  105884. /**
  105885. * The mesh used to display where the user is going to teleport.
  105886. */
  105887. /**
  105888. * Sets the mesh to be used to display where the user is going to teleport.
  105889. */
  105890. teleportationTarget: Mesh;
  105891. /**
  105892. * 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
  105893. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105894. * See http://doc.babylonjs.com/resources/baking_transformations
  105895. */
  105896. gazeTrackerMesh: Mesh;
  105897. /**
  105898. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105899. */
  105900. updateGazeTrackerScale: boolean;
  105901. /**
  105902. * If the gaze trackers color should be updated when selecting meshes
  105903. */
  105904. updateGazeTrackerColor: boolean;
  105905. /**
  105906. * The gaze tracking mesh corresponding to the left controller
  105907. */
  105908. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105909. /**
  105910. * The gaze tracking mesh corresponding to the right controller
  105911. */
  105912. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105913. /**
  105914. * If the ray of the gaze should be displayed.
  105915. */
  105916. /**
  105917. * Sets if the ray of the gaze should be displayed.
  105918. */
  105919. displayGaze: boolean;
  105920. /**
  105921. * If the ray of the LaserPointer should be displayed.
  105922. */
  105923. /**
  105924. * Sets if the ray of the LaserPointer should be displayed.
  105925. */
  105926. displayLaserPointer: boolean;
  105927. /**
  105928. * The deviceOrientationCamera used as the camera when not in VR.
  105929. */
  105930. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105931. /**
  105932. * Based on the current WebVR support, returns the current VR camera used.
  105933. */
  105934. readonly currentVRCamera: Nullable<Camera>;
  105935. /**
  105936. * The webVRCamera which is used when in VR.
  105937. */
  105938. readonly webVRCamera: WebVRFreeCamera;
  105939. /**
  105940. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105941. */
  105942. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105943. /**
  105944. * The html button that is used to trigger entering into VR.
  105945. */
  105946. readonly vrButton: Nullable<HTMLButtonElement>;
  105947. private readonly _teleportationRequestInitiated;
  105948. /**
  105949. * Defines wether or not Pointer lock should be requested when switching to
  105950. * full screen.
  105951. */
  105952. requestPointerLockOnFullScreen: boolean;
  105953. /**
  105954. * Instantiates a VRExperienceHelper.
  105955. * Helps to quickly add VR support to an existing scene.
  105956. * @param scene The scene the VRExperienceHelper belongs to.
  105957. * @param webVROptions Options to modify the vr experience helper's behavior.
  105958. */
  105959. constructor(scene: Scene,
  105960. /** Options to modify the vr experience helper's behavior. */
  105961. webVROptions?: VRExperienceHelperOptions);
  105962. private _onDefaultMeshLoaded;
  105963. private _onResize;
  105964. private _onFullscreenChange;
  105965. /**
  105966. * Gets a value indicating if we are currently in VR mode.
  105967. */
  105968. readonly isInVRMode: boolean;
  105969. private onVrDisplayPresentChange;
  105970. private onVRDisplayChanged;
  105971. private moveButtonToBottomRight;
  105972. private displayVRButton;
  105973. private updateButtonVisibility;
  105974. private _cachedAngularSensibility;
  105975. /**
  105976. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105977. * Otherwise, will use the fullscreen API.
  105978. */
  105979. enterVR(): void;
  105980. /**
  105981. * Attempt to exit VR, or fullscreen.
  105982. */
  105983. exitVR(): void;
  105984. /**
  105985. * The position of the vr experience helper.
  105986. */
  105987. /**
  105988. * Sets the position of the vr experience helper.
  105989. */
  105990. position: Vector3;
  105991. /**
  105992. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105993. */
  105994. enableInteractions(): void;
  105995. private readonly _noControllerIsActive;
  105996. private beforeRender;
  105997. private _isTeleportationFloor;
  105998. /**
  105999. * Adds a floor mesh to be used for teleportation.
  106000. * @param floorMesh the mesh to be used for teleportation.
  106001. */
  106002. addFloorMesh(floorMesh: Mesh): void;
  106003. /**
  106004. * Removes a floor mesh from being used for teleportation.
  106005. * @param floorMesh the mesh to be removed.
  106006. */
  106007. removeFloorMesh(floorMesh: Mesh): void;
  106008. /**
  106009. * Enables interactions and teleportation using the VR controllers and gaze.
  106010. * @param vrTeleportationOptions options to modify teleportation behavior.
  106011. */
  106012. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106013. private _onNewGamepadConnected;
  106014. private _tryEnableInteractionOnController;
  106015. private _onNewGamepadDisconnected;
  106016. private _enableInteractionOnController;
  106017. private _checkTeleportWithRay;
  106018. private _checkRotate;
  106019. private _checkTeleportBackwards;
  106020. private _enableTeleportationOnController;
  106021. private _createTeleportationCircles;
  106022. private _displayTeleportationTarget;
  106023. private _hideTeleportationTarget;
  106024. private _rotateCamera;
  106025. private _moveTeleportationSelectorTo;
  106026. private _workingVector;
  106027. private _workingQuaternion;
  106028. private _workingMatrix;
  106029. /**
  106030. * Teleports the users feet to the desired location
  106031. * @param location The location where the user's feet should be placed
  106032. */
  106033. teleportCamera(location: Vector3): void;
  106034. private _convertNormalToDirectionOfRay;
  106035. private _castRayAndSelectObject;
  106036. private _notifySelectedMeshUnselected;
  106037. /**
  106038. * Sets the color of the laser ray from the vr controllers.
  106039. * @param color new color for the ray.
  106040. */
  106041. changeLaserColor(color: Color3): void;
  106042. /**
  106043. * Sets the color of the ray from the vr headsets gaze.
  106044. * @param color new color for the ray.
  106045. */
  106046. changeGazeColor(color: Color3): void;
  106047. /**
  106048. * Exits VR and disposes of the vr experience helper
  106049. */
  106050. dispose(): void;
  106051. /**
  106052. * Gets the name of the VRExperienceHelper class
  106053. * @returns "VRExperienceHelper"
  106054. */
  106055. getClassName(): string;
  106056. }
  106057. }
  106058. declare module BABYLON {
  106059. /**
  106060. * Manages an XRSession to work with Babylon's engine
  106061. * @see https://doc.babylonjs.com/how_to/webxr
  106062. */
  106063. export class WebXRSessionManager implements IDisposable {
  106064. private scene;
  106065. /**
  106066. * Fires every time a new xrFrame arrives which can be used to update the camera
  106067. */
  106068. onXRFrameObservable: Observable<any>;
  106069. /**
  106070. * Fires when the xr session is ended either by the device or manually done
  106071. */
  106072. onXRSessionEnded: Observable<any>;
  106073. /**
  106074. * Underlying xr session
  106075. */
  106076. session: XRSession;
  106077. /**
  106078. * Type of reference space used when creating the session
  106079. */
  106080. referenceSpace: XRReferenceSpace;
  106081. /** @hidden */
  106082. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106083. /**
  106084. * Current XR frame
  106085. */
  106086. currentFrame: Nullable<XRFrame>;
  106087. private _xrNavigator;
  106088. private baseLayer;
  106089. /**
  106090. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106091. * @param scene The scene which the session should be created for
  106092. */
  106093. constructor(scene: Scene);
  106094. /**
  106095. * Initializes the manager
  106096. * After initialization enterXR can be called to start an XR session
  106097. * @returns Promise which resolves after it is initialized
  106098. */
  106099. initializeAsync(): Promise<void>;
  106100. /**
  106101. * Initializes an xr session
  106102. * @param xrSessionMode mode to initialize
  106103. * @returns a promise which will resolve once the session has been initialized
  106104. */
  106105. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106106. /**
  106107. * Sets the reference space on the xr session
  106108. * @param referenceSpace space to set
  106109. * @returns a promise that will resolve once the reference space has been set
  106110. */
  106111. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106112. /**
  106113. * Updates the render state of the session
  106114. * @param state state to set
  106115. * @returns a promise that resolves once the render state has been updated
  106116. */
  106117. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106118. /**
  106119. * Starts rendering to the xr layer
  106120. * @returns a promise that will resolve once rendering has started
  106121. */
  106122. startRenderingToXRAsync(): Promise<void>;
  106123. /**
  106124. * Stops the xrSession and restores the renderloop
  106125. * @returns Promise which resolves after it exits XR
  106126. */
  106127. exitXRAsync(): Promise<unknown>;
  106128. /**
  106129. * Checks if a session would be supported for the creation options specified
  106130. * @param sessionMode session mode to check if supported eg. immersive-vr
  106131. * @returns true if supported
  106132. */
  106133. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106134. /**
  106135. * @hidden
  106136. * Converts the render layer of xrSession to a render target
  106137. * @param session session to create render target for
  106138. * @param scene scene the new render target should be created for
  106139. */
  106140. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106141. /**
  106142. * Disposes of the session manager
  106143. */
  106144. dispose(): void;
  106145. }
  106146. }
  106147. declare module BABYLON {
  106148. /**
  106149. * WebXR Camera which holds the views for the xrSession
  106150. * @see https://doc.babylonjs.com/how_to/webxr
  106151. */
  106152. export class WebXRCamera extends FreeCamera {
  106153. private static _TmpMatrix;
  106154. /**
  106155. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106156. * @param name the name of the camera
  106157. * @param scene the scene to add the camera to
  106158. */
  106159. constructor(name: string, scene: Scene);
  106160. private _updateNumberOfRigCameras;
  106161. /** @hidden */
  106162. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106163. /**
  106164. * Updates the cameras position from the current pose information of the XR session
  106165. * @param xrSessionManager the session containing pose information
  106166. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106167. */
  106168. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106169. }
  106170. }
  106171. declare module BABYLON {
  106172. /**
  106173. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106174. */
  106175. export class WebXRManagedOutputCanvas implements IDisposable {
  106176. private helper;
  106177. private _canvas;
  106178. /**
  106179. * xrpresent context of the canvas which can be used to display/mirror xr content
  106180. */
  106181. canvasContext: WebGLRenderingContext;
  106182. /**
  106183. * xr layer for the canvas
  106184. */
  106185. xrLayer: Nullable<XRWebGLLayer>;
  106186. /**
  106187. * Initializes the xr layer for the session
  106188. * @param xrSession xr session
  106189. * @returns a promise that will resolve once the XR Layer has been created
  106190. */
  106191. initializeXRLayerAsync(xrSession: any): any;
  106192. /**
  106193. * Initializes the canvas to be added/removed upon entering/exiting xr
  106194. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106195. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106196. */
  106197. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106198. /**
  106199. * Disposes of the object
  106200. */
  106201. dispose(): void;
  106202. private _setManagedOutputCanvas;
  106203. private _addCanvas;
  106204. private _removeCanvas;
  106205. }
  106206. }
  106207. declare module BABYLON {
  106208. /**
  106209. * States of the webXR experience
  106210. */
  106211. export enum WebXRState {
  106212. /**
  106213. * Transitioning to being in XR mode
  106214. */
  106215. ENTERING_XR = 0,
  106216. /**
  106217. * Transitioning to non XR mode
  106218. */
  106219. EXITING_XR = 1,
  106220. /**
  106221. * In XR mode and presenting
  106222. */
  106223. IN_XR = 2,
  106224. /**
  106225. * Not entered XR mode
  106226. */
  106227. NOT_IN_XR = 3
  106228. }
  106229. /**
  106230. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106231. * @see https://doc.babylonjs.com/how_to/webxr
  106232. */
  106233. export class WebXRExperienceHelper implements IDisposable {
  106234. private scene;
  106235. /**
  106236. * 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
  106237. */
  106238. container: AbstractMesh;
  106239. /**
  106240. * Camera used to render xr content
  106241. */
  106242. camera: WebXRCamera;
  106243. /**
  106244. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106245. */
  106246. state: WebXRState;
  106247. private _setState;
  106248. private static _TmpVector;
  106249. /**
  106250. * Fires when the state of the experience helper has changed
  106251. */
  106252. onStateChangedObservable: Observable<WebXRState>;
  106253. /** Session manager used to keep track of xr session */
  106254. sessionManager: WebXRSessionManager;
  106255. private _nonVRCamera;
  106256. private _originalSceneAutoClear;
  106257. private _supported;
  106258. /**
  106259. * Creates the experience helper
  106260. * @param scene the scene to attach the experience helper to
  106261. * @returns a promise for the experience helper
  106262. */
  106263. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106264. /**
  106265. * Creates a WebXRExperienceHelper
  106266. * @param scene The scene the helper should be created in
  106267. */
  106268. private constructor();
  106269. /**
  106270. * Exits XR mode and returns the scene to its original state
  106271. * @returns promise that resolves after xr mode has exited
  106272. */
  106273. exitXRAsync(): Promise<unknown>;
  106274. /**
  106275. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  106276. * @param sessionCreationOptions options for the XR session
  106277. * @param referenceSpaceType frame of reference of the XR session
  106278. * @param outputCanvas the output canvas that will be used to enter XR mode
  106279. * @returns promise that resolves after xr mode has entered
  106280. */
  106281. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  106282. /**
  106283. * Updates the global position of the camera by moving the camera's container
  106284. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106285. * @param position The desired global position of the camera
  106286. */
  106287. setPositionOfCameraUsingContainer(position: Vector3): void;
  106288. /**
  106289. * Rotates the xr camera by rotating the camera's container around the camera's position
  106290. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106291. * @param rotation the desired quaternion rotation to apply to the camera
  106292. */
  106293. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106294. /**
  106295. * Disposes of the experience helper
  106296. */
  106297. dispose(): void;
  106298. }
  106299. }
  106300. declare module BABYLON {
  106301. /**
  106302. * Button which can be used to enter a different mode of XR
  106303. */
  106304. export class WebXREnterExitUIButton {
  106305. /** button element */
  106306. element: HTMLElement;
  106307. /** XR initialization options for the button */
  106308. sessionMode: XRSessionMode;
  106309. /** Reference space type */
  106310. referenceSpaceType: XRReferenceSpaceType;
  106311. /**
  106312. * Creates a WebXREnterExitUIButton
  106313. * @param element button element
  106314. * @param sessionMode XR initialization session mode
  106315. * @param referenceSpaceType the type of reference space to be used
  106316. */
  106317. constructor(
  106318. /** button element */
  106319. element: HTMLElement,
  106320. /** XR initialization options for the button */
  106321. sessionMode: XRSessionMode,
  106322. /** Reference space type */
  106323. referenceSpaceType: XRReferenceSpaceType);
  106324. /**
  106325. * Overwritable function which can be used to update the button's visuals when the state changes
  106326. * @param activeButton the current active button in the UI
  106327. */
  106328. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106329. }
  106330. /**
  106331. * Options to create the webXR UI
  106332. */
  106333. export class WebXREnterExitUIOptions {
  106334. /**
  106335. * Context to enter xr with
  106336. */
  106337. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106338. /**
  106339. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106340. */
  106341. customButtons?: Array<WebXREnterExitUIButton>;
  106342. }
  106343. /**
  106344. * UI to allow the user to enter/exit XR mode
  106345. */
  106346. export class WebXREnterExitUI implements IDisposable {
  106347. private scene;
  106348. private _overlay;
  106349. private _buttons;
  106350. private _activeButton;
  106351. /**
  106352. * Fired every time the active button is changed.
  106353. *
  106354. * When xr is entered via a button that launches xr that button will be the callback parameter
  106355. *
  106356. * When exiting xr the callback parameter will be null)
  106357. */
  106358. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106359. /**
  106360. * Creates UI to allow the user to enter/exit XR mode
  106361. * @param scene the scene to add the ui to
  106362. * @param helper the xr experience helper to enter/exit xr with
  106363. * @param options options to configure the UI
  106364. * @returns the created ui
  106365. */
  106366. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106367. private constructor();
  106368. private _updateButtons;
  106369. /**
  106370. * Disposes of the object
  106371. */
  106372. dispose(): void;
  106373. }
  106374. }
  106375. declare module BABYLON {
  106376. /**
  106377. * Represents an XR input
  106378. */
  106379. export class WebXRController {
  106380. private scene;
  106381. /** The underlying input source for the controller */
  106382. inputSource: XRInputSource;
  106383. private parentContainer;
  106384. /**
  106385. * 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
  106386. */
  106387. grip?: AbstractMesh;
  106388. /**
  106389. * Pointer which can be used to select objects or attach a visible laser to
  106390. */
  106391. pointer: AbstractMesh;
  106392. /**
  106393. * Event that fires when the controller is removed/disposed
  106394. */
  106395. onDisposeObservable: Observable<{}>;
  106396. private _tmpMatrix;
  106397. private _tmpQuaternion;
  106398. private _tmpVector;
  106399. /**
  106400. * Creates the controller
  106401. * @see https://doc.babylonjs.com/how_to/webxr
  106402. * @param scene the scene which the controller should be associated to
  106403. * @param inputSource the underlying input source for the controller
  106404. * @param parentContainer parent that the controller meshes should be children of
  106405. */
  106406. constructor(scene: Scene,
  106407. /** The underlying input source for the controller */
  106408. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  106409. /**
  106410. * Updates the controller pose based on the given XRFrame
  106411. * @param xrFrame xr frame to update the pose with
  106412. * @param referenceSpace reference space to use
  106413. */
  106414. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  106415. /**
  106416. * Gets a world space ray coming from the controller
  106417. * @param result the resulting ray
  106418. */
  106419. getWorldPointerRayToRef(result: Ray): void;
  106420. /**
  106421. * Disposes of the object
  106422. */
  106423. dispose(): void;
  106424. }
  106425. }
  106426. declare module BABYLON {
  106427. /**
  106428. * XR input used to track XR inputs such as controllers/rays
  106429. */
  106430. export class WebXRInput implements IDisposable {
  106431. /**
  106432. * Base experience the input listens to
  106433. */
  106434. baseExperience: WebXRExperienceHelper;
  106435. /**
  106436. * XR controllers being tracked
  106437. */
  106438. controllers: Array<WebXRController>;
  106439. private _frameObserver;
  106440. private _stateObserver;
  106441. /**
  106442. * Event when a controller has been connected/added
  106443. */
  106444. onControllerAddedObservable: Observable<WebXRController>;
  106445. /**
  106446. * Event when a controller has been removed/disconnected
  106447. */
  106448. onControllerRemovedObservable: Observable<WebXRController>;
  106449. /**
  106450. * Initializes the WebXRInput
  106451. * @param baseExperience experience helper which the input should be created for
  106452. */
  106453. constructor(
  106454. /**
  106455. * Base experience the input listens to
  106456. */
  106457. baseExperience: WebXRExperienceHelper);
  106458. private _onInputSourcesChange;
  106459. private _addAndRemoveControllers;
  106460. /**
  106461. * Disposes of the object
  106462. */
  106463. dispose(): void;
  106464. }
  106465. }
  106466. declare module BABYLON {
  106467. /**
  106468. * Enables teleportation
  106469. */
  106470. export class WebXRControllerTeleportation {
  106471. private _teleportationFillColor;
  106472. private _teleportationBorderColor;
  106473. private _tmpRay;
  106474. private _tmpVector;
  106475. /**
  106476. * Creates a WebXRControllerTeleportation
  106477. * @param input input manager to add teleportation to
  106478. * @param floorMeshes floormeshes which can be teleported to
  106479. */
  106480. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106481. }
  106482. }
  106483. declare module BABYLON {
  106484. /**
  106485. * Handles pointer input automatically for the pointer of XR controllers
  106486. */
  106487. export class WebXRControllerPointerSelection {
  106488. private static _idCounter;
  106489. private _tmpRay;
  106490. /**
  106491. * Creates a WebXRControllerPointerSelection
  106492. * @param input input manager to setup pointer selection
  106493. */
  106494. constructor(input: WebXRInput);
  106495. private _convertNormalToDirectionOfRay;
  106496. private _updatePointerDistance;
  106497. }
  106498. }
  106499. declare module BABYLON {
  106500. /**
  106501. * Class used to represent data loading progression
  106502. */
  106503. export class SceneLoaderProgressEvent {
  106504. /** defines if data length to load can be evaluated */
  106505. readonly lengthComputable: boolean;
  106506. /** defines the loaded data length */
  106507. readonly loaded: number;
  106508. /** defines the data length to load */
  106509. readonly total: number;
  106510. /**
  106511. * Create a new progress event
  106512. * @param lengthComputable defines if data length to load can be evaluated
  106513. * @param loaded defines the loaded data length
  106514. * @param total defines the data length to load
  106515. */
  106516. constructor(
  106517. /** defines if data length to load can be evaluated */
  106518. lengthComputable: boolean,
  106519. /** defines the loaded data length */
  106520. loaded: number,
  106521. /** defines the data length to load */
  106522. total: number);
  106523. /**
  106524. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106525. * @param event defines the source event
  106526. * @returns a new SceneLoaderProgressEvent
  106527. */
  106528. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106529. }
  106530. /**
  106531. * Interface used by SceneLoader plugins to define supported file extensions
  106532. */
  106533. export interface ISceneLoaderPluginExtensions {
  106534. /**
  106535. * Defines the list of supported extensions
  106536. */
  106537. [extension: string]: {
  106538. isBinary: boolean;
  106539. };
  106540. }
  106541. /**
  106542. * Interface used by SceneLoader plugin factory
  106543. */
  106544. export interface ISceneLoaderPluginFactory {
  106545. /**
  106546. * Defines the name of the factory
  106547. */
  106548. name: string;
  106549. /**
  106550. * Function called to create a new plugin
  106551. * @return the new plugin
  106552. */
  106553. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106554. /**
  106555. * Boolean indicating if the plugin can direct load specific data
  106556. */
  106557. canDirectLoad?: (data: string) => boolean;
  106558. }
  106559. /**
  106560. * Interface used to define a SceneLoader plugin
  106561. */
  106562. export interface ISceneLoaderPlugin {
  106563. /**
  106564. * The friendly name of this plugin.
  106565. */
  106566. name: string;
  106567. /**
  106568. * The file extensions supported by this plugin.
  106569. */
  106570. extensions: string | ISceneLoaderPluginExtensions;
  106571. /**
  106572. * Import meshes into a scene.
  106573. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106574. * @param scene The scene to import into
  106575. * @param data The data to import
  106576. * @param rootUrl The root url for scene and resources
  106577. * @param meshes The meshes array to import into
  106578. * @param particleSystems The particle systems array to import into
  106579. * @param skeletons The skeletons array to import into
  106580. * @param onError The callback when import fails
  106581. * @returns True if successful or false otherwise
  106582. */
  106583. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106584. /**
  106585. * Load into a scene.
  106586. * @param scene The scene to load into
  106587. * @param data The data to import
  106588. * @param rootUrl The root url for scene and resources
  106589. * @param onError The callback when import fails
  106590. * @returns true if successful or false otherwise
  106591. */
  106592. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106593. /**
  106594. * The callback that returns true if the data can be directly loaded.
  106595. */
  106596. canDirectLoad?: (data: string) => boolean;
  106597. /**
  106598. * The callback that allows custom handling of the root url based on the response url.
  106599. */
  106600. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106601. /**
  106602. * Load into an asset container.
  106603. * @param scene The scene to load into
  106604. * @param data The data to import
  106605. * @param rootUrl The root url for scene and resources
  106606. * @param onError The callback when import fails
  106607. * @returns The loaded asset container
  106608. */
  106609. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106610. }
  106611. /**
  106612. * Interface used to define an async SceneLoader plugin
  106613. */
  106614. export interface ISceneLoaderPluginAsync {
  106615. /**
  106616. * The friendly name of this plugin.
  106617. */
  106618. name: string;
  106619. /**
  106620. * The file extensions supported by this plugin.
  106621. */
  106622. extensions: string | ISceneLoaderPluginExtensions;
  106623. /**
  106624. * Import meshes into a scene.
  106625. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106626. * @param scene The scene to import into
  106627. * @param data The data to import
  106628. * @param rootUrl The root url for scene and resources
  106629. * @param onProgress The callback when the load progresses
  106630. * @param fileName Defines the name of the file to load
  106631. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106632. */
  106633. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106634. meshes: AbstractMesh[];
  106635. particleSystems: IParticleSystem[];
  106636. skeletons: Skeleton[];
  106637. animationGroups: AnimationGroup[];
  106638. }>;
  106639. /**
  106640. * Load into a scene.
  106641. * @param scene The scene to load into
  106642. * @param data The data to import
  106643. * @param rootUrl The root url for scene and resources
  106644. * @param onProgress The callback when the load progresses
  106645. * @param fileName Defines the name of the file to load
  106646. * @returns Nothing
  106647. */
  106648. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106649. /**
  106650. * The callback that returns true if the data can be directly loaded.
  106651. */
  106652. canDirectLoad?: (data: string) => boolean;
  106653. /**
  106654. * The callback that allows custom handling of the root url based on the response url.
  106655. */
  106656. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106657. /**
  106658. * Load into an asset container.
  106659. * @param scene The scene to load into
  106660. * @param data The data to import
  106661. * @param rootUrl The root url for scene and resources
  106662. * @param onProgress The callback when the load progresses
  106663. * @param fileName Defines the name of the file to load
  106664. * @returns The loaded asset container
  106665. */
  106666. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106667. }
  106668. /**
  106669. * Class used to load scene from various file formats using registered plugins
  106670. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106671. */
  106672. export class SceneLoader {
  106673. /**
  106674. * No logging while loading
  106675. */
  106676. static readonly NO_LOGGING: number;
  106677. /**
  106678. * Minimal logging while loading
  106679. */
  106680. static readonly MINIMAL_LOGGING: number;
  106681. /**
  106682. * Summary logging while loading
  106683. */
  106684. static readonly SUMMARY_LOGGING: number;
  106685. /**
  106686. * Detailled logging while loading
  106687. */
  106688. static readonly DETAILED_LOGGING: number;
  106689. /**
  106690. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106691. */
  106692. static ForceFullSceneLoadingForIncremental: boolean;
  106693. /**
  106694. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106695. */
  106696. static ShowLoadingScreen: boolean;
  106697. /**
  106698. * Defines the current logging level (while loading the scene)
  106699. * @ignorenaming
  106700. */
  106701. static loggingLevel: number;
  106702. /**
  106703. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106704. */
  106705. static CleanBoneMatrixWeights: boolean;
  106706. /**
  106707. * Event raised when a plugin is used to load a scene
  106708. */
  106709. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106710. private static _registeredPlugins;
  106711. private static _getDefaultPlugin;
  106712. private static _getPluginForExtension;
  106713. private static _getPluginForDirectLoad;
  106714. private static _getPluginForFilename;
  106715. private static _getDirectLoad;
  106716. private static _loadData;
  106717. private static _getFileInfo;
  106718. /**
  106719. * Gets a plugin that can load the given extension
  106720. * @param extension defines the extension to load
  106721. * @returns a plugin or null if none works
  106722. */
  106723. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106724. /**
  106725. * Gets a boolean indicating that the given extension can be loaded
  106726. * @param extension defines the extension to load
  106727. * @returns true if the extension is supported
  106728. */
  106729. static IsPluginForExtensionAvailable(extension: string): boolean;
  106730. /**
  106731. * Adds a new plugin to the list of registered plugins
  106732. * @param plugin defines the plugin to add
  106733. */
  106734. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106735. /**
  106736. * Import meshes into a scene
  106737. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106738. * @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)
  106739. * @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)
  106740. * @param scene the instance of BABYLON.Scene to append to
  106741. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106742. * @param onProgress a callback with a progress event for each file being loaded
  106743. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106744. * @param pluginExtension the extension used to determine the plugin
  106745. * @returns The loaded plugin
  106746. */
  106747. 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>;
  106748. /**
  106749. * Import meshes into a scene
  106750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106751. * @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)
  106752. * @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)
  106753. * @param scene the instance of BABYLON.Scene to append to
  106754. * @param onProgress a callback with a progress event for each file being loaded
  106755. * @param pluginExtension the extension used to determine the plugin
  106756. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106757. */
  106758. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106759. meshes: AbstractMesh[];
  106760. particleSystems: IParticleSystem[];
  106761. skeletons: Skeleton[];
  106762. animationGroups: AnimationGroup[];
  106763. }>;
  106764. /**
  106765. * Load a scene
  106766. * @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)
  106767. * @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)
  106768. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106769. * @param onSuccess a callback with the scene when import succeeds
  106770. * @param onProgress a callback with a progress event for each file being loaded
  106771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106772. * @param pluginExtension the extension used to determine the plugin
  106773. * @returns The loaded plugin
  106774. */
  106775. 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>;
  106776. /**
  106777. * Load a scene
  106778. * @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)
  106779. * @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)
  106780. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106781. * @param onProgress a callback with a progress event for each file being loaded
  106782. * @param pluginExtension the extension used to determine the plugin
  106783. * @returns The loaded scene
  106784. */
  106785. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106786. /**
  106787. * Append a scene
  106788. * @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)
  106789. * @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)
  106790. * @param scene is the instance of BABYLON.Scene to append to
  106791. * @param onSuccess a callback with the scene when import succeeds
  106792. * @param onProgress a callback with a progress event for each file being loaded
  106793. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106794. * @param pluginExtension the extension used to determine the plugin
  106795. * @returns The loaded plugin
  106796. */
  106797. 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>;
  106798. /**
  106799. * Append a scene
  106800. * @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)
  106801. * @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)
  106802. * @param scene is the instance of BABYLON.Scene to append to
  106803. * @param onProgress a callback with a progress event for each file being loaded
  106804. * @param pluginExtension the extension used to determine the plugin
  106805. * @returns The given scene
  106806. */
  106807. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106808. /**
  106809. * Load a scene into an asset container
  106810. * @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)
  106811. * @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)
  106812. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106813. * @param onSuccess a callback with the scene when import succeeds
  106814. * @param onProgress a callback with a progress event for each file being loaded
  106815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106816. * @param pluginExtension the extension used to determine the plugin
  106817. * @returns The loaded plugin
  106818. */
  106819. 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>;
  106820. /**
  106821. * Load a scene into an asset container
  106822. * @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)
  106823. * @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)
  106824. * @param scene is the instance of Scene to append to
  106825. * @param onProgress a callback with a progress event for each file being loaded
  106826. * @param pluginExtension the extension used to determine the plugin
  106827. * @returns The loaded asset container
  106828. */
  106829. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106830. }
  106831. }
  106832. declare module BABYLON {
  106833. /**
  106834. * Generic Controller
  106835. */
  106836. export class GenericController extends WebVRController {
  106837. /**
  106838. * Base Url for the controller model.
  106839. */
  106840. static readonly MODEL_BASE_URL: string;
  106841. /**
  106842. * File name for the controller model.
  106843. */
  106844. static readonly MODEL_FILENAME: string;
  106845. /**
  106846. * Creates a new GenericController from a gamepad
  106847. * @param vrGamepad the gamepad that the controller should be created from
  106848. */
  106849. constructor(vrGamepad: any);
  106850. /**
  106851. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106852. * @param scene scene in which to add meshes
  106853. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106854. */
  106855. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106856. /**
  106857. * Called once for each button that changed state since the last frame
  106858. * @param buttonIdx Which button index changed
  106859. * @param state New state of the button
  106860. * @param changes Which properties on the state changed since last frame
  106861. */
  106862. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106863. }
  106864. }
  106865. declare module BABYLON {
  106866. /**
  106867. * Defines the WindowsMotionController object that the state of the windows motion controller
  106868. */
  106869. export class WindowsMotionController extends WebVRController {
  106870. /**
  106871. * The base url used to load the left and right controller models
  106872. */
  106873. static MODEL_BASE_URL: string;
  106874. /**
  106875. * The name of the left controller model file
  106876. */
  106877. static MODEL_LEFT_FILENAME: string;
  106878. /**
  106879. * The name of the right controller model file
  106880. */
  106881. static MODEL_RIGHT_FILENAME: string;
  106882. /**
  106883. * The controller name prefix for this controller type
  106884. */
  106885. static readonly GAMEPAD_ID_PREFIX: string;
  106886. /**
  106887. * The controller id pattern for this controller type
  106888. */
  106889. private static readonly GAMEPAD_ID_PATTERN;
  106890. private _loadedMeshInfo;
  106891. private readonly _mapping;
  106892. /**
  106893. * Fired when the trackpad on this controller is clicked
  106894. */
  106895. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106896. /**
  106897. * Fired when the trackpad on this controller is modified
  106898. */
  106899. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106900. /**
  106901. * The current x and y values of this controller's trackpad
  106902. */
  106903. trackpad: StickValues;
  106904. /**
  106905. * Creates a new WindowsMotionController from a gamepad
  106906. * @param vrGamepad the gamepad that the controller should be created from
  106907. */
  106908. constructor(vrGamepad: any);
  106909. /**
  106910. * Fired when the trigger on this controller is modified
  106911. */
  106912. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106913. /**
  106914. * Fired when the menu button on this controller is modified
  106915. */
  106916. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106917. /**
  106918. * Fired when the grip button on this controller is modified
  106919. */
  106920. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106921. /**
  106922. * Fired when the thumbstick button on this controller is modified
  106923. */
  106924. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106925. /**
  106926. * Fired when the touchpad button on this controller is modified
  106927. */
  106928. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106929. /**
  106930. * Fired when the touchpad values on this controller are modified
  106931. */
  106932. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106933. private _updateTrackpad;
  106934. /**
  106935. * Called once per frame by the engine.
  106936. */
  106937. update(): void;
  106938. /**
  106939. * Called once for each button that changed state since the last frame
  106940. * @param buttonIdx Which button index changed
  106941. * @param state New state of the button
  106942. * @param changes Which properties on the state changed since last frame
  106943. */
  106944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106945. /**
  106946. * Moves the buttons on the controller mesh based on their current state
  106947. * @param buttonName the name of the button to move
  106948. * @param buttonValue the value of the button which determines the buttons new position
  106949. */
  106950. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106951. /**
  106952. * Moves the axis on the controller mesh based on its current state
  106953. * @param axis the index of the axis
  106954. * @param axisValue the value of the axis which determines the meshes new position
  106955. * @hidden
  106956. */
  106957. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106958. /**
  106959. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106960. * @param scene scene in which to add meshes
  106961. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106962. */
  106963. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106964. /**
  106965. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106966. * can be transformed by button presses and axes values, based on this._mapping.
  106967. *
  106968. * @param scene scene in which the meshes exist
  106969. * @param meshes list of meshes that make up the controller model to process
  106970. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106971. */
  106972. private processModel;
  106973. private createMeshInfo;
  106974. /**
  106975. * Gets the ray of the controller in the direction the controller is pointing
  106976. * @param length the length the resulting ray should be
  106977. * @returns a ray in the direction the controller is pointing
  106978. */
  106979. getForwardRay(length?: number): Ray;
  106980. /**
  106981. * Disposes of the controller
  106982. */
  106983. dispose(): void;
  106984. }
  106985. }
  106986. declare module BABYLON {
  106987. /**
  106988. * Oculus Touch Controller
  106989. */
  106990. export class OculusTouchController extends WebVRController {
  106991. /**
  106992. * Base Url for the controller model.
  106993. */
  106994. static MODEL_BASE_URL: string;
  106995. /**
  106996. * File name for the left controller model.
  106997. */
  106998. static MODEL_LEFT_FILENAME: string;
  106999. /**
  107000. * File name for the right controller model.
  107001. */
  107002. static MODEL_RIGHT_FILENAME: string;
  107003. /**
  107004. * Base Url for the Quest controller model.
  107005. */
  107006. static QUEST_MODEL_BASE_URL: string;
  107007. /**
  107008. * @hidden
  107009. * If the controllers are running on a device that needs the updated Quest controller models
  107010. */
  107011. static _IsQuest: boolean;
  107012. /**
  107013. * Fired when the secondary trigger on this controller is modified
  107014. */
  107015. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107016. /**
  107017. * Fired when the thumb rest on this controller is modified
  107018. */
  107019. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107020. /**
  107021. * Creates a new OculusTouchController from a gamepad
  107022. * @param vrGamepad the gamepad that the controller should be created from
  107023. */
  107024. constructor(vrGamepad: any);
  107025. /**
  107026. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107027. * @param scene scene in which to add meshes
  107028. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107029. */
  107030. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107031. /**
  107032. * Fired when the A button on this controller is modified
  107033. */
  107034. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107035. /**
  107036. * Fired when the B button on this controller is modified
  107037. */
  107038. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107039. /**
  107040. * Fired when the X button on this controller is modified
  107041. */
  107042. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107043. /**
  107044. * Fired when the Y button on this controller is modified
  107045. */
  107046. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107047. /**
  107048. * Called once for each button that changed state since the last frame
  107049. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107050. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107051. * 2) secondary trigger (same)
  107052. * 3) A (right) X (left), touch, pressed = value
  107053. * 4) B / Y
  107054. * 5) thumb rest
  107055. * @param buttonIdx Which button index changed
  107056. * @param state New state of the button
  107057. * @param changes Which properties on the state changed since last frame
  107058. */
  107059. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107060. }
  107061. }
  107062. declare module BABYLON {
  107063. /**
  107064. * Vive Controller
  107065. */
  107066. export class ViveController extends WebVRController {
  107067. /**
  107068. * Base Url for the controller model.
  107069. */
  107070. static MODEL_BASE_URL: string;
  107071. /**
  107072. * File name for the controller model.
  107073. */
  107074. static MODEL_FILENAME: string;
  107075. /**
  107076. * Creates a new ViveController from a gamepad
  107077. * @param vrGamepad the gamepad that the controller should be created from
  107078. */
  107079. constructor(vrGamepad: any);
  107080. /**
  107081. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107082. * @param scene scene in which to add meshes
  107083. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107084. */
  107085. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107086. /**
  107087. * Fired when the left button on this controller is modified
  107088. */
  107089. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107090. /**
  107091. * Fired when the right button on this controller is modified
  107092. */
  107093. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107094. /**
  107095. * Fired when the menu button on this controller is modified
  107096. */
  107097. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107098. /**
  107099. * Called once for each button that changed state since the last frame
  107100. * Vive mapping:
  107101. * 0: touchpad
  107102. * 1: trigger
  107103. * 2: left AND right buttons
  107104. * 3: menu button
  107105. * @param buttonIdx Which button index changed
  107106. * @param state New state of the button
  107107. * @param changes Which properties on the state changed since last frame
  107108. */
  107109. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107110. }
  107111. }
  107112. declare module BABYLON {
  107113. /**
  107114. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107115. */
  107116. export class WebXRControllerModelLoader {
  107117. /**
  107118. * Creates the WebXRControllerModelLoader
  107119. * @param input xr input that creates the controllers
  107120. */
  107121. constructor(input: WebXRInput);
  107122. }
  107123. }
  107124. declare module BABYLON {
  107125. /**
  107126. * Contains an array of blocks representing the octree
  107127. */
  107128. export interface IOctreeContainer<T> {
  107129. /**
  107130. * Blocks within the octree
  107131. */
  107132. blocks: Array<OctreeBlock<T>>;
  107133. }
  107134. /**
  107135. * Class used to store a cell in an octree
  107136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107137. */
  107138. export class OctreeBlock<T> {
  107139. /**
  107140. * Gets the content of the current block
  107141. */
  107142. entries: T[];
  107143. /**
  107144. * Gets the list of block children
  107145. */
  107146. blocks: Array<OctreeBlock<T>>;
  107147. private _depth;
  107148. private _maxDepth;
  107149. private _capacity;
  107150. private _minPoint;
  107151. private _maxPoint;
  107152. private _boundingVectors;
  107153. private _creationFunc;
  107154. /**
  107155. * Creates a new block
  107156. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107157. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107158. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107159. * @param depth defines the current depth of this block in the octree
  107160. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107161. * @param creationFunc defines a callback to call when an element is added to the block
  107162. */
  107163. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107164. /**
  107165. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107166. */
  107167. readonly capacity: number;
  107168. /**
  107169. * Gets the minimum vector (in world space) of the block's bounding box
  107170. */
  107171. readonly minPoint: Vector3;
  107172. /**
  107173. * Gets the maximum vector (in world space) of the block's bounding box
  107174. */
  107175. readonly maxPoint: Vector3;
  107176. /**
  107177. * Add a new element to this block
  107178. * @param entry defines the element to add
  107179. */
  107180. addEntry(entry: T): void;
  107181. /**
  107182. * Remove an element from this block
  107183. * @param entry defines the element to remove
  107184. */
  107185. removeEntry(entry: T): void;
  107186. /**
  107187. * Add an array of elements to this block
  107188. * @param entries defines the array of elements to add
  107189. */
  107190. addEntries(entries: T[]): void;
  107191. /**
  107192. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107193. * @param frustumPlanes defines the frustum planes to test
  107194. * @param selection defines the array to store current content if selection is positive
  107195. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107196. */
  107197. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107198. /**
  107199. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107200. * @param sphereCenter defines the bounding sphere center
  107201. * @param sphereRadius defines the bounding sphere radius
  107202. * @param selection defines the array to store current content if selection is positive
  107203. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107204. */
  107205. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107206. /**
  107207. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107208. * @param ray defines the ray to test with
  107209. * @param selection defines the array to store current content if selection is positive
  107210. */
  107211. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107212. /**
  107213. * Subdivide the content into child blocks (this block will then be empty)
  107214. */
  107215. createInnerBlocks(): void;
  107216. /**
  107217. * @hidden
  107218. */
  107219. 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;
  107220. }
  107221. }
  107222. declare module BABYLON {
  107223. /**
  107224. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107226. */
  107227. export class Octree<T> {
  107228. /** 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.) */
  107229. maxDepth: number;
  107230. /**
  107231. * Blocks within the octree containing objects
  107232. */
  107233. blocks: Array<OctreeBlock<T>>;
  107234. /**
  107235. * Content stored in the octree
  107236. */
  107237. dynamicContent: T[];
  107238. private _maxBlockCapacity;
  107239. private _selectionContent;
  107240. private _creationFunc;
  107241. /**
  107242. * Creates a octree
  107243. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107244. * @param creationFunc function to be used to instatiate the octree
  107245. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107246. * @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.)
  107247. */
  107248. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107249. /** 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.) */
  107250. maxDepth?: number);
  107251. /**
  107252. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107253. * @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);
  107254. * @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);
  107255. * @param entries meshes to be added to the octree blocks
  107256. */
  107257. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107258. /**
  107259. * Adds a mesh to the octree
  107260. * @param entry Mesh to add to the octree
  107261. */
  107262. addMesh(entry: T): void;
  107263. /**
  107264. * Remove an element from the octree
  107265. * @param entry defines the element to remove
  107266. */
  107267. removeMesh(entry: T): void;
  107268. /**
  107269. * Selects an array of meshes within the frustum
  107270. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  107271. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  107272. * @returns array of meshes within the frustum
  107273. */
  107274. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  107275. /**
  107276. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  107277. * @param sphereCenter defines the bounding sphere center
  107278. * @param sphereRadius defines the bounding sphere radius
  107279. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107280. * @returns an array of objects that intersect the sphere
  107281. */
  107282. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  107283. /**
  107284. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107285. * @param ray defines the ray to test with
  107286. * @returns array of intersected objects
  107287. */
  107288. intersectsRay(ray: Ray): SmartArray<T>;
  107289. /**
  107290. * Adds a mesh into the octree block if it intersects the block
  107291. */
  107292. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107293. /**
  107294. * Adds a submesh into the octree block if it intersects the block
  107295. */
  107296. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107297. }
  107298. }
  107299. declare module BABYLON {
  107300. interface Scene {
  107301. /**
  107302. * @hidden
  107303. * Backing Filed
  107304. */
  107305. _selectionOctree: Octree<AbstractMesh>;
  107306. /**
  107307. * Gets the octree used to boost mesh selection (picking)
  107308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107309. */
  107310. selectionOctree: Octree<AbstractMesh>;
  107311. /**
  107312. * Creates or updates the octree used to boost selection (picking)
  107313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107314. * @param maxCapacity defines the maximum capacity per leaf
  107315. * @param maxDepth defines the maximum depth of the octree
  107316. * @returns an octree of AbstractMesh
  107317. */
  107318. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107319. }
  107320. interface AbstractMesh {
  107321. /**
  107322. * @hidden
  107323. * Backing Field
  107324. */
  107325. _submeshesOctree: Octree<SubMesh>;
  107326. /**
  107327. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107328. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107329. * @param maxCapacity defines the maximum size of each block (64 by default)
  107330. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107331. * @returns the new octree
  107332. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107334. */
  107335. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107336. }
  107337. /**
  107338. * Defines the octree scene component responsible to manage any octrees
  107339. * in a given scene.
  107340. */
  107341. export class OctreeSceneComponent {
  107342. /**
  107343. * The component name help to identify the component in the list of scene components.
  107344. */
  107345. readonly name: string;
  107346. /**
  107347. * The scene the component belongs to.
  107348. */
  107349. scene: Scene;
  107350. /**
  107351. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107352. */
  107353. readonly checksIsEnabled: boolean;
  107354. /**
  107355. * Creates a new instance of the component for the given scene
  107356. * @param scene Defines the scene to register the component in
  107357. */
  107358. constructor(scene: Scene);
  107359. /**
  107360. * Registers the component in a given scene
  107361. */
  107362. register(): void;
  107363. /**
  107364. * Return the list of active meshes
  107365. * @returns the list of active meshes
  107366. */
  107367. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107368. /**
  107369. * Return the list of active sub meshes
  107370. * @param mesh The mesh to get the candidates sub meshes from
  107371. * @returns the list of active sub meshes
  107372. */
  107373. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107374. private _tempRay;
  107375. /**
  107376. * Return the list of sub meshes intersecting with a given local ray
  107377. * @param mesh defines the mesh to find the submesh for
  107378. * @param localRay defines the ray in local space
  107379. * @returns the list of intersecting sub meshes
  107380. */
  107381. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107382. /**
  107383. * Return the list of sub meshes colliding with a collider
  107384. * @param mesh defines the mesh to find the submesh for
  107385. * @param collider defines the collider to evaluate the collision against
  107386. * @returns the list of colliding sub meshes
  107387. */
  107388. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107389. /**
  107390. * Rebuilds the elements related to this component in case of
  107391. * context lost for instance.
  107392. */
  107393. rebuild(): void;
  107394. /**
  107395. * Disposes the component and the associated ressources.
  107396. */
  107397. dispose(): void;
  107398. }
  107399. }
  107400. declare module BABYLON {
  107401. /**
  107402. * Renders a layer on top of an existing scene
  107403. */
  107404. export class UtilityLayerRenderer implements IDisposable {
  107405. /** the original scene that will be rendered on top of */
  107406. originalScene: Scene;
  107407. private _pointerCaptures;
  107408. private _lastPointerEvents;
  107409. private static _DefaultUtilityLayer;
  107410. private static _DefaultKeepDepthUtilityLayer;
  107411. private _sharedGizmoLight;
  107412. private _renderCamera;
  107413. /**
  107414. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  107415. * @returns the camera that is used when rendering the utility layer
  107416. */
  107417. getRenderCamera(): Nullable<Camera>;
  107418. /**
  107419. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  107420. * @param cam the camera that should be used when rendering the utility layer
  107421. */
  107422. setRenderCamera(cam: Nullable<Camera>): void;
  107423. /**
  107424. * @hidden
  107425. * Light which used by gizmos to get light shading
  107426. */
  107427. _getSharedGizmoLight(): HemisphericLight;
  107428. /**
  107429. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  107430. */
  107431. pickUtilitySceneFirst: boolean;
  107432. /**
  107433. * 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)
  107434. */
  107435. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  107436. /**
  107437. * 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)
  107438. */
  107439. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  107440. /**
  107441. * The scene that is rendered on top of the original scene
  107442. */
  107443. utilityLayerScene: Scene;
  107444. /**
  107445. * If the utility layer should automatically be rendered on top of existing scene
  107446. */
  107447. shouldRender: boolean;
  107448. /**
  107449. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  107450. */
  107451. onlyCheckPointerDownEvents: boolean;
  107452. /**
  107453. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107454. */
  107455. processAllEvents: boolean;
  107456. /**
  107457. * Observable raised when the pointer move from the utility layer scene to the main scene
  107458. */
  107459. onPointerOutObservable: Observable<number>;
  107460. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107461. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107462. private _afterRenderObserver;
  107463. private _sceneDisposeObserver;
  107464. private _originalPointerObserver;
  107465. /**
  107466. * Instantiates a UtilityLayerRenderer
  107467. * @param originalScene the original scene that will be rendered on top of
  107468. * @param handleEvents boolean indicating if the utility layer should handle events
  107469. */
  107470. constructor(
  107471. /** the original scene that will be rendered on top of */
  107472. originalScene: Scene, handleEvents?: boolean);
  107473. private _notifyObservers;
  107474. /**
  107475. * Renders the utility layers scene on top of the original scene
  107476. */
  107477. render(): void;
  107478. /**
  107479. * Disposes of the renderer
  107480. */
  107481. dispose(): void;
  107482. private _updateCamera;
  107483. }
  107484. }
  107485. declare module BABYLON {
  107486. /**
  107487. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107488. */
  107489. export class Gizmo implements IDisposable {
  107490. /** The utility layer the gizmo will be added to */
  107491. gizmoLayer: UtilityLayerRenderer;
  107492. /**
  107493. * The root mesh of the gizmo
  107494. */
  107495. _rootMesh: Mesh;
  107496. private _attachedMesh;
  107497. /**
  107498. * Ratio for the scale of the gizmo (Default: 1)
  107499. */
  107500. scaleRatio: number;
  107501. /**
  107502. * If a custom mesh has been set (Default: false)
  107503. */
  107504. protected _customMeshSet: boolean;
  107505. /**
  107506. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107507. * * When set, interactions will be enabled
  107508. */
  107509. attachedMesh: Nullable<AbstractMesh>;
  107510. /**
  107511. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107512. * @param mesh The mesh to replace the default mesh of the gizmo
  107513. */
  107514. setCustomMesh(mesh: Mesh): void;
  107515. /**
  107516. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107517. */
  107518. updateGizmoRotationToMatchAttachedMesh: boolean;
  107519. /**
  107520. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107521. */
  107522. updateGizmoPositionToMatchAttachedMesh: boolean;
  107523. /**
  107524. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107525. */
  107526. updateScale: boolean;
  107527. protected _interactionsEnabled: boolean;
  107528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107529. private _beforeRenderObserver;
  107530. private _tempVector;
  107531. /**
  107532. * Creates a gizmo
  107533. * @param gizmoLayer The utility layer the gizmo will be added to
  107534. */
  107535. constructor(
  107536. /** The utility layer the gizmo will be added to */
  107537. gizmoLayer?: UtilityLayerRenderer);
  107538. /**
  107539. * Updates the gizmo to match the attached mesh's position/rotation
  107540. */
  107541. protected _update(): void;
  107542. /**
  107543. * Disposes of the gizmo
  107544. */
  107545. dispose(): void;
  107546. }
  107547. }
  107548. declare module BABYLON {
  107549. /**
  107550. * Single plane drag gizmo
  107551. */
  107552. export class PlaneDragGizmo extends Gizmo {
  107553. /**
  107554. * Drag behavior responsible for the gizmos dragging interactions
  107555. */
  107556. dragBehavior: PointerDragBehavior;
  107557. private _pointerObserver;
  107558. /**
  107559. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107560. */
  107561. snapDistance: number;
  107562. /**
  107563. * Event that fires each time the gizmo snaps to a new location.
  107564. * * snapDistance is the the change in distance
  107565. */
  107566. onSnapObservable: Observable<{
  107567. snapDistance: number;
  107568. }>;
  107569. private _plane;
  107570. private _coloredMaterial;
  107571. private _hoverMaterial;
  107572. private _isEnabled;
  107573. private _parent;
  107574. /** @hidden */
  107575. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107576. /** @hidden */
  107577. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107578. /**
  107579. * Creates a PlaneDragGizmo
  107580. * @param gizmoLayer The utility layer the gizmo will be added to
  107581. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107582. * @param color The color of the gizmo
  107583. */
  107584. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107585. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107586. /**
  107587. * If the gizmo is enabled
  107588. */
  107589. isEnabled: boolean;
  107590. /**
  107591. * Disposes of the gizmo
  107592. */
  107593. dispose(): void;
  107594. }
  107595. }
  107596. declare module BABYLON {
  107597. /**
  107598. * Gizmo that enables dragging a mesh along 3 axis
  107599. */
  107600. export class PositionGizmo extends Gizmo {
  107601. /**
  107602. * Internal gizmo used for interactions on the x axis
  107603. */
  107604. xGizmo: AxisDragGizmo;
  107605. /**
  107606. * Internal gizmo used for interactions on the y axis
  107607. */
  107608. yGizmo: AxisDragGizmo;
  107609. /**
  107610. * Internal gizmo used for interactions on the z axis
  107611. */
  107612. zGizmo: AxisDragGizmo;
  107613. /**
  107614. * Internal gizmo used for interactions on the yz plane
  107615. */
  107616. xPlaneGizmo: PlaneDragGizmo;
  107617. /**
  107618. * Internal gizmo used for interactions on the xz plane
  107619. */
  107620. yPlaneGizmo: PlaneDragGizmo;
  107621. /**
  107622. * Internal gizmo used for interactions on the xy plane
  107623. */
  107624. zPlaneGizmo: PlaneDragGizmo;
  107625. /**
  107626. * private variables
  107627. */
  107628. private _meshAttached;
  107629. private _updateGizmoRotationToMatchAttachedMesh;
  107630. private _snapDistance;
  107631. private _scaleRatio;
  107632. /** Fires an event when any of it's sub gizmos are dragged */
  107633. onDragStartObservable: Observable<unknown>;
  107634. /** Fires an event when any of it's sub gizmos are released from dragging */
  107635. onDragEndObservable: Observable<unknown>;
  107636. /**
  107637. * If set to true, planar drag is enabled
  107638. */
  107639. private _planarGizmoEnabled;
  107640. attachedMesh: Nullable<AbstractMesh>;
  107641. /**
  107642. * Creates a PositionGizmo
  107643. * @param gizmoLayer The utility layer the gizmo will be added to
  107644. */
  107645. constructor(gizmoLayer?: UtilityLayerRenderer);
  107646. /**
  107647. * If the planar drag gizmo is enabled
  107648. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107649. */
  107650. planarGizmoEnabled: boolean;
  107651. updateGizmoRotationToMatchAttachedMesh: boolean;
  107652. /**
  107653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107654. */
  107655. snapDistance: number;
  107656. /**
  107657. * Ratio for the scale of the gizmo (Default: 1)
  107658. */
  107659. scaleRatio: number;
  107660. /**
  107661. * Disposes of the gizmo
  107662. */
  107663. dispose(): void;
  107664. /**
  107665. * CustomMeshes are not supported by this gizmo
  107666. * @param mesh The mesh to replace the default mesh of the gizmo
  107667. */
  107668. setCustomMesh(mesh: Mesh): void;
  107669. }
  107670. }
  107671. declare module BABYLON {
  107672. /**
  107673. * Single axis drag gizmo
  107674. */
  107675. export class AxisDragGizmo extends Gizmo {
  107676. /**
  107677. * Drag behavior responsible for the gizmos dragging interactions
  107678. */
  107679. dragBehavior: PointerDragBehavior;
  107680. private _pointerObserver;
  107681. /**
  107682. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107683. */
  107684. snapDistance: number;
  107685. /**
  107686. * Event that fires each time the gizmo snaps to a new location.
  107687. * * snapDistance is the the change in distance
  107688. */
  107689. onSnapObservable: Observable<{
  107690. snapDistance: number;
  107691. }>;
  107692. private _isEnabled;
  107693. private _parent;
  107694. private _arrow;
  107695. private _coloredMaterial;
  107696. private _hoverMaterial;
  107697. /** @hidden */
  107698. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107699. /** @hidden */
  107700. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107701. /**
  107702. * Creates an AxisDragGizmo
  107703. * @param gizmoLayer The utility layer the gizmo will be added to
  107704. * @param dragAxis The axis which the gizmo will be able to drag on
  107705. * @param color The color of the gizmo
  107706. */
  107707. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107708. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107709. /**
  107710. * If the gizmo is enabled
  107711. */
  107712. isEnabled: boolean;
  107713. /**
  107714. * Disposes of the gizmo
  107715. */
  107716. dispose(): void;
  107717. }
  107718. }
  107719. declare module BABYLON.Debug {
  107720. /**
  107721. * The Axes viewer will show 3 axes in a specific point in space
  107722. */
  107723. export class AxesViewer {
  107724. private _xAxis;
  107725. private _yAxis;
  107726. private _zAxis;
  107727. private _scaleLinesFactor;
  107728. private _instanced;
  107729. /**
  107730. * Gets the hosting scene
  107731. */
  107732. scene: Scene;
  107733. /**
  107734. * Gets or sets a number used to scale line length
  107735. */
  107736. scaleLines: number;
  107737. /** Gets the node hierarchy used to render x-axis */
  107738. readonly xAxis: TransformNode;
  107739. /** Gets the node hierarchy used to render y-axis */
  107740. readonly yAxis: TransformNode;
  107741. /** Gets the node hierarchy used to render z-axis */
  107742. readonly zAxis: TransformNode;
  107743. /**
  107744. * Creates a new AxesViewer
  107745. * @param scene defines the hosting scene
  107746. * @param scaleLines defines a number used to scale line length (1 by default)
  107747. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107748. * @param xAxis defines the node hierarchy used to render the x-axis
  107749. * @param yAxis defines the node hierarchy used to render the y-axis
  107750. * @param zAxis defines the node hierarchy used to render the z-axis
  107751. */
  107752. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107753. /**
  107754. * Force the viewer to update
  107755. * @param position defines the position of the viewer
  107756. * @param xaxis defines the x axis of the viewer
  107757. * @param yaxis defines the y axis of the viewer
  107758. * @param zaxis defines the z axis of the viewer
  107759. */
  107760. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107761. /**
  107762. * Creates an instance of this axes viewer.
  107763. * @returns a new axes viewer with instanced meshes
  107764. */
  107765. createInstance(): AxesViewer;
  107766. /** Releases resources */
  107767. dispose(): void;
  107768. private static _SetRenderingGroupId;
  107769. }
  107770. }
  107771. declare module BABYLON.Debug {
  107772. /**
  107773. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107774. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107775. */
  107776. export class BoneAxesViewer extends AxesViewer {
  107777. /**
  107778. * Gets or sets the target mesh where to display the axes viewer
  107779. */
  107780. mesh: Nullable<Mesh>;
  107781. /**
  107782. * Gets or sets the target bone where to display the axes viewer
  107783. */
  107784. bone: Nullable<Bone>;
  107785. /** Gets current position */
  107786. pos: Vector3;
  107787. /** Gets direction of X axis */
  107788. xaxis: Vector3;
  107789. /** Gets direction of Y axis */
  107790. yaxis: Vector3;
  107791. /** Gets direction of Z axis */
  107792. zaxis: Vector3;
  107793. /**
  107794. * Creates a new BoneAxesViewer
  107795. * @param scene defines the hosting scene
  107796. * @param bone defines the target bone
  107797. * @param mesh defines the target mesh
  107798. * @param scaleLines defines a scaling factor for line length (1 by default)
  107799. */
  107800. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107801. /**
  107802. * Force the viewer to update
  107803. */
  107804. update(): void;
  107805. /** Releases resources */
  107806. dispose(): void;
  107807. }
  107808. }
  107809. declare module BABYLON {
  107810. /**
  107811. * Interface used to define scene explorer extensibility option
  107812. */
  107813. export interface IExplorerExtensibilityOption {
  107814. /**
  107815. * Define the option label
  107816. */
  107817. label: string;
  107818. /**
  107819. * Defines the action to execute on click
  107820. */
  107821. action: (entity: any) => void;
  107822. }
  107823. /**
  107824. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107825. */
  107826. export interface IExplorerExtensibilityGroup {
  107827. /**
  107828. * Defines a predicate to test if a given type mut be extended
  107829. */
  107830. predicate: (entity: any) => boolean;
  107831. /**
  107832. * Gets the list of options added to a type
  107833. */
  107834. entries: IExplorerExtensibilityOption[];
  107835. }
  107836. /**
  107837. * Interface used to define the options to use to create the Inspector
  107838. */
  107839. export interface IInspectorOptions {
  107840. /**
  107841. * Display in overlay mode (default: false)
  107842. */
  107843. overlay?: boolean;
  107844. /**
  107845. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107846. */
  107847. globalRoot?: HTMLElement;
  107848. /**
  107849. * Display the Scene explorer
  107850. */
  107851. showExplorer?: boolean;
  107852. /**
  107853. * Display the property inspector
  107854. */
  107855. showInspector?: boolean;
  107856. /**
  107857. * Display in embed mode (both panes on the right)
  107858. */
  107859. embedMode?: boolean;
  107860. /**
  107861. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107862. */
  107863. handleResize?: boolean;
  107864. /**
  107865. * Allow the panes to popup (default: true)
  107866. */
  107867. enablePopup?: boolean;
  107868. /**
  107869. * Allow the panes to be closed by users (default: true)
  107870. */
  107871. enableClose?: boolean;
  107872. /**
  107873. * Optional list of extensibility entries
  107874. */
  107875. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107876. /**
  107877. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107878. */
  107879. inspectorURL?: string;
  107880. }
  107881. interface Scene {
  107882. /**
  107883. * @hidden
  107884. * Backing field
  107885. */
  107886. _debugLayer: DebugLayer;
  107887. /**
  107888. * Gets the debug layer (aka Inspector) associated with the scene
  107889. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107890. */
  107891. debugLayer: DebugLayer;
  107892. }
  107893. /**
  107894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107895. * what is happening in your scene
  107896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107897. */
  107898. export class DebugLayer {
  107899. /**
  107900. * Define the url to get the inspector script from.
  107901. * By default it uses the babylonjs CDN.
  107902. * @ignoreNaming
  107903. */
  107904. static InspectorURL: string;
  107905. private _scene;
  107906. private BJSINSPECTOR;
  107907. private _onPropertyChangedObservable?;
  107908. /**
  107909. * Observable triggered when a property is changed through the inspector.
  107910. */
  107911. readonly onPropertyChangedObservable: any;
  107912. /**
  107913. * Instantiates a new debug layer.
  107914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107915. * what is happening in your scene
  107916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107917. * @param scene Defines the scene to inspect
  107918. */
  107919. constructor(scene: Scene);
  107920. /** Creates the inspector window. */
  107921. private _createInspector;
  107922. /**
  107923. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107924. * @param entity defines the entity to select
  107925. * @param lineContainerTitle defines the specific block to highlight
  107926. */
  107927. select(entity: any, lineContainerTitle?: string): void;
  107928. /** Get the inspector from bundle or global */
  107929. private _getGlobalInspector;
  107930. /**
  107931. * Get if the inspector is visible or not.
  107932. * @returns true if visible otherwise, false
  107933. */
  107934. isVisible(): boolean;
  107935. /**
  107936. * Hide the inspector and close its window.
  107937. */
  107938. hide(): void;
  107939. /**
  107940. * Launch the debugLayer.
  107941. * @param config Define the configuration of the inspector
  107942. * @return a promise fulfilled when the debug layer is visible
  107943. */
  107944. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107945. }
  107946. }
  107947. declare module BABYLON {
  107948. /**
  107949. * Class containing static functions to help procedurally build meshes
  107950. */
  107951. export class BoxBuilder {
  107952. /**
  107953. * Creates a box mesh
  107954. * * The parameter `size` sets the size (float) of each box side (default 1)
  107955. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107956. * * 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)
  107957. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107962. * @param name defines the name of the mesh
  107963. * @param options defines the options used to create the mesh
  107964. * @param scene defines the hosting scene
  107965. * @returns the box mesh
  107966. */
  107967. static CreateBox(name: string, options: {
  107968. size?: number;
  107969. width?: number;
  107970. height?: number;
  107971. depth?: number;
  107972. faceUV?: Vector4[];
  107973. faceColors?: Color4[];
  107974. sideOrientation?: number;
  107975. frontUVs?: Vector4;
  107976. backUVs?: Vector4;
  107977. wrap?: boolean;
  107978. topBaseAt?: number;
  107979. bottomBaseAt?: number;
  107980. updatable?: boolean;
  107981. }, scene?: Nullable<Scene>): Mesh;
  107982. }
  107983. }
  107984. declare module BABYLON {
  107985. /**
  107986. * Class containing static functions to help procedurally build meshes
  107987. */
  107988. export class SphereBuilder {
  107989. /**
  107990. * Creates a sphere mesh
  107991. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107992. * * 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`)
  107993. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107994. * * 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
  107995. * * 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)
  107996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107999. * @param name defines the name of the mesh
  108000. * @param options defines the options used to create the mesh
  108001. * @param scene defines the hosting scene
  108002. * @returns the sphere mesh
  108003. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108004. */
  108005. static CreateSphere(name: string, options: {
  108006. segments?: number;
  108007. diameter?: number;
  108008. diameterX?: number;
  108009. diameterY?: number;
  108010. diameterZ?: number;
  108011. arc?: number;
  108012. slice?: number;
  108013. sideOrientation?: number;
  108014. frontUVs?: Vector4;
  108015. backUVs?: Vector4;
  108016. updatable?: boolean;
  108017. }, scene?: Nullable<Scene>): Mesh;
  108018. }
  108019. }
  108020. declare module BABYLON.Debug {
  108021. /**
  108022. * Used to show the physics impostor around the specific mesh
  108023. */
  108024. export class PhysicsViewer {
  108025. /** @hidden */
  108026. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108027. /** @hidden */
  108028. protected _meshes: Array<Nullable<AbstractMesh>>;
  108029. /** @hidden */
  108030. protected _scene: Nullable<Scene>;
  108031. /** @hidden */
  108032. protected _numMeshes: number;
  108033. /** @hidden */
  108034. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108035. private _renderFunction;
  108036. private _utilityLayer;
  108037. private _debugBoxMesh;
  108038. private _debugSphereMesh;
  108039. private _debugCylinderMesh;
  108040. private _debugMaterial;
  108041. private _debugMeshMeshes;
  108042. /**
  108043. * Creates a new PhysicsViewer
  108044. * @param scene defines the hosting scene
  108045. */
  108046. constructor(scene: Scene);
  108047. /** @hidden */
  108048. protected _updateDebugMeshes(): void;
  108049. /**
  108050. * Renders a specified physic impostor
  108051. * @param impostor defines the impostor to render
  108052. * @param targetMesh defines the mesh represented by the impostor
  108053. * @returns the new debug mesh used to render the impostor
  108054. */
  108055. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108056. /**
  108057. * Hides a specified physic impostor
  108058. * @param impostor defines the impostor to hide
  108059. */
  108060. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108061. private _getDebugMaterial;
  108062. private _getDebugBoxMesh;
  108063. private _getDebugSphereMesh;
  108064. private _getDebugCylinderMesh;
  108065. private _getDebugMeshMesh;
  108066. private _getDebugMesh;
  108067. /** Releases all resources */
  108068. dispose(): void;
  108069. }
  108070. }
  108071. declare module BABYLON {
  108072. /**
  108073. * Class containing static functions to help procedurally build meshes
  108074. */
  108075. export class LinesBuilder {
  108076. /**
  108077. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108078. * * 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
  108079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108080. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108081. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108082. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108083. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108084. * * 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
  108085. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108088. * @param name defines the name of the new line system
  108089. * @param options defines the options used to create the line system
  108090. * @param scene defines the hosting scene
  108091. * @returns a new line system mesh
  108092. */
  108093. static CreateLineSystem(name: string, options: {
  108094. lines: Vector3[][];
  108095. updatable?: boolean;
  108096. instance?: Nullable<LinesMesh>;
  108097. colors?: Nullable<Color4[][]>;
  108098. useVertexAlpha?: boolean;
  108099. }, scene: Nullable<Scene>): LinesMesh;
  108100. /**
  108101. * Creates a line mesh
  108102. * 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
  108103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108104. * * The parameter `points` is an array successive Vector3
  108105. * * 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
  108106. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108108. * * When updating an instance, remember that only point positions can change, not the number of points
  108109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108111. * @param name defines the name of the new line system
  108112. * @param options defines the options used to create the line system
  108113. * @param scene defines the hosting scene
  108114. * @returns a new line mesh
  108115. */
  108116. static CreateLines(name: string, options: {
  108117. points: Vector3[];
  108118. updatable?: boolean;
  108119. instance?: Nullable<LinesMesh>;
  108120. colors?: Color4[];
  108121. useVertexAlpha?: boolean;
  108122. }, scene?: Nullable<Scene>): LinesMesh;
  108123. /**
  108124. * Creates a dashed line mesh
  108125. * * 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
  108126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108127. * * The parameter `points` is an array successive Vector3
  108128. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108129. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108130. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108131. * * 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
  108132. * * When updating an instance, remember that only point positions can change, not the number of points
  108133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108134. * @param name defines the name of the mesh
  108135. * @param options defines the options used to create the mesh
  108136. * @param scene defines the hosting scene
  108137. * @returns the dashed line mesh
  108138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108139. */
  108140. static CreateDashedLines(name: string, options: {
  108141. points: Vector3[];
  108142. dashSize?: number;
  108143. gapSize?: number;
  108144. dashNb?: number;
  108145. updatable?: boolean;
  108146. instance?: LinesMesh;
  108147. }, scene?: Nullable<Scene>): LinesMesh;
  108148. }
  108149. }
  108150. declare module BABYLON {
  108151. /**
  108152. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108153. * in order to better appreciate the issue one might have.
  108154. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108155. */
  108156. export class RayHelper {
  108157. /**
  108158. * Defines the ray we are currently tryin to visualize.
  108159. */
  108160. ray: Nullable<Ray>;
  108161. private _renderPoints;
  108162. private _renderLine;
  108163. private _renderFunction;
  108164. private _scene;
  108165. private _updateToMeshFunction;
  108166. private _attachedToMesh;
  108167. private _meshSpaceDirection;
  108168. private _meshSpaceOrigin;
  108169. /**
  108170. * Helper function to create a colored helper in a scene in one line.
  108171. * @param ray Defines the ray we are currently tryin to visualize
  108172. * @param scene Defines the scene the ray is used in
  108173. * @param color Defines the color we want to see the ray in
  108174. * @returns The newly created ray helper.
  108175. */
  108176. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108177. /**
  108178. * Instantiate a new ray helper.
  108179. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108180. * in order to better appreciate the issue one might have.
  108181. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108182. * @param ray Defines the ray we are currently tryin to visualize
  108183. */
  108184. constructor(ray: Ray);
  108185. /**
  108186. * Shows the ray we are willing to debug.
  108187. * @param scene Defines the scene the ray needs to be rendered in
  108188. * @param color Defines the color the ray needs to be rendered in
  108189. */
  108190. show(scene: Scene, color?: Color3): void;
  108191. /**
  108192. * Hides the ray we are debugging.
  108193. */
  108194. hide(): void;
  108195. private _render;
  108196. /**
  108197. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108198. * @param mesh Defines the mesh we want the helper attached to
  108199. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108200. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108201. * @param length Defines the length of the ray
  108202. */
  108203. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108204. /**
  108205. * Detach the ray helper from the mesh it has previously been attached to.
  108206. */
  108207. detachFromMesh(): void;
  108208. private _updateToMesh;
  108209. /**
  108210. * Dispose the helper and release its associated resources.
  108211. */
  108212. dispose(): void;
  108213. }
  108214. }
  108215. declare module BABYLON.Debug {
  108216. /**
  108217. * Class used to render a debug view of a given skeleton
  108218. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108219. */
  108220. export class SkeletonViewer {
  108221. /** defines the skeleton to render */
  108222. skeleton: Skeleton;
  108223. /** defines the mesh attached to the skeleton */
  108224. mesh: AbstractMesh;
  108225. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108226. autoUpdateBonesMatrices: boolean;
  108227. /** defines the rendering group id to use with the viewer */
  108228. renderingGroupId: number;
  108229. /** Gets or sets the color used to render the skeleton */
  108230. color: Color3;
  108231. private _scene;
  108232. private _debugLines;
  108233. private _debugMesh;
  108234. private _isEnabled;
  108235. private _renderFunction;
  108236. private _utilityLayer;
  108237. /**
  108238. * Returns the mesh used to render the bones
  108239. */
  108240. readonly debugMesh: Nullable<LinesMesh>;
  108241. /**
  108242. * Creates a new SkeletonViewer
  108243. * @param skeleton defines the skeleton to render
  108244. * @param mesh defines the mesh attached to the skeleton
  108245. * @param scene defines the hosting scene
  108246. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108247. * @param renderingGroupId defines the rendering group id to use with the viewer
  108248. */
  108249. constructor(
  108250. /** defines the skeleton to render */
  108251. skeleton: Skeleton,
  108252. /** defines the mesh attached to the skeleton */
  108253. mesh: AbstractMesh, scene: Scene,
  108254. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108255. autoUpdateBonesMatrices?: boolean,
  108256. /** defines the rendering group id to use with the viewer */
  108257. renderingGroupId?: number);
  108258. /** Gets or sets a boolean indicating if the viewer is enabled */
  108259. isEnabled: boolean;
  108260. private _getBonePosition;
  108261. private _getLinesForBonesWithLength;
  108262. private _getLinesForBonesNoLength;
  108263. /** Update the viewer to sync with current skeleton state */
  108264. update(): void;
  108265. /** Release associated resources */
  108266. dispose(): void;
  108267. }
  108268. }
  108269. declare module BABYLON {
  108270. /**
  108271. * Options to create the null engine
  108272. */
  108273. export class NullEngineOptions {
  108274. /**
  108275. * Render width (Default: 512)
  108276. */
  108277. renderWidth: number;
  108278. /**
  108279. * Render height (Default: 256)
  108280. */
  108281. renderHeight: number;
  108282. /**
  108283. * Texture size (Default: 512)
  108284. */
  108285. textureSize: number;
  108286. /**
  108287. * If delta time between frames should be constant
  108288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108289. */
  108290. deterministicLockstep: boolean;
  108291. /**
  108292. * Maximum about of steps between frames (Default: 4)
  108293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108294. */
  108295. lockstepMaxSteps: number;
  108296. }
  108297. /**
  108298. * The null engine class provides support for headless version of babylon.js.
  108299. * This can be used in server side scenario or for testing purposes
  108300. */
  108301. export class NullEngine extends Engine {
  108302. private _options;
  108303. /**
  108304. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108305. */
  108306. isDeterministicLockStep(): boolean;
  108307. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108308. getLockstepMaxSteps(): number;
  108309. /**
  108310. * Sets hardware scaling, used to save performance if needed
  108311. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108312. */
  108313. getHardwareScalingLevel(): number;
  108314. constructor(options?: NullEngineOptions);
  108315. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108316. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108317. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108318. getRenderWidth(useScreen?: boolean): number;
  108319. getRenderHeight(useScreen?: boolean): number;
  108320. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108321. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108322. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108323. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108324. bindSamplers(effect: Effect): void;
  108325. enableEffect(effect: Effect): void;
  108326. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108327. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108328. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108329. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108330. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108331. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108332. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108333. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108334. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108335. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108336. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108337. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108338. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108339. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108340. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108341. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108342. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108343. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108344. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108345. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108346. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108348. bindBuffers(vertexBuffers: {
  108349. [key: string]: VertexBuffer;
  108350. }, indexBuffer: DataBuffer, effect: Effect): void;
  108351. wipeCaches(bruteForce?: boolean): void;
  108352. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108353. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108354. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108355. /** @hidden */
  108356. _createTexture(): WebGLTexture;
  108357. /** @hidden */
  108358. _releaseTexture(texture: InternalTexture): void;
  108359. 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;
  108360. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108361. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108362. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108363. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108364. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108365. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108366. areAllEffectsReady(): boolean;
  108367. /**
  108368. * @hidden
  108369. * Get the current error code of the webGL context
  108370. * @returns the error code
  108371. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108372. */
  108373. getError(): number;
  108374. /** @hidden */
  108375. _getUnpackAlignement(): number;
  108376. /** @hidden */
  108377. _unpackFlipY(value: boolean): void;
  108378. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108379. /**
  108380. * Updates a dynamic vertex buffer.
  108381. * @param vertexBuffer the vertex buffer to update
  108382. * @param data the data used to update the vertex buffer
  108383. * @param byteOffset the byte offset of the data (optional)
  108384. * @param byteLength the byte length of the data (optional)
  108385. */
  108386. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108387. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108388. /** @hidden */
  108389. _bindTexture(channel: number, texture: InternalTexture): void;
  108390. /** @hidden */
  108391. _releaseBuffer(buffer: DataBuffer): boolean;
  108392. releaseEffects(): void;
  108393. displayLoadingUI(): void;
  108394. hideLoadingUI(): void;
  108395. /** @hidden */
  108396. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108397. /** @hidden */
  108398. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108399. /** @hidden */
  108400. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108401. /** @hidden */
  108402. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  108403. }
  108404. }
  108405. declare module BABYLON {
  108406. /** @hidden */
  108407. export class _OcclusionDataStorage {
  108408. /** @hidden */
  108409. occlusionInternalRetryCounter: number;
  108410. /** @hidden */
  108411. isOcclusionQueryInProgress: boolean;
  108412. /** @hidden */
  108413. isOccluded: boolean;
  108414. /** @hidden */
  108415. occlusionRetryCount: number;
  108416. /** @hidden */
  108417. occlusionType: number;
  108418. /** @hidden */
  108419. occlusionQueryAlgorithmType: number;
  108420. }
  108421. interface Engine {
  108422. /**
  108423. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  108424. * @return the new query
  108425. */
  108426. createQuery(): WebGLQuery;
  108427. /**
  108428. * Delete and release a webGL query
  108429. * @param query defines the query to delete
  108430. * @return the current engine
  108431. */
  108432. deleteQuery(query: WebGLQuery): Engine;
  108433. /**
  108434. * Check if a given query has resolved and got its value
  108435. * @param query defines the query to check
  108436. * @returns true if the query got its value
  108437. */
  108438. isQueryResultAvailable(query: WebGLQuery): boolean;
  108439. /**
  108440. * Gets the value of a given query
  108441. * @param query defines the query to check
  108442. * @returns the value of the query
  108443. */
  108444. getQueryResult(query: WebGLQuery): number;
  108445. /**
  108446. * Initiates an occlusion query
  108447. * @param algorithmType defines the algorithm to use
  108448. * @param query defines the query to use
  108449. * @returns the current engine
  108450. * @see http://doc.babylonjs.com/features/occlusionquery
  108451. */
  108452. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  108453. /**
  108454. * Ends an occlusion query
  108455. * @see http://doc.babylonjs.com/features/occlusionquery
  108456. * @param algorithmType defines the algorithm to use
  108457. * @returns the current engine
  108458. */
  108459. endOcclusionQuery(algorithmType: number): Engine;
  108460. /**
  108461. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108462. * Please note that only one query can be issued at a time
  108463. * @returns a time token used to track the time span
  108464. */
  108465. startTimeQuery(): Nullable<_TimeToken>;
  108466. /**
  108467. * Ends a time query
  108468. * @param token defines the token used to measure the time span
  108469. * @returns the time spent (in ns)
  108470. */
  108471. endTimeQuery(token: _TimeToken): int;
  108472. /** @hidden */
  108473. _currentNonTimestampToken: Nullable<_TimeToken>;
  108474. /** @hidden */
  108475. _createTimeQuery(): WebGLQuery;
  108476. /** @hidden */
  108477. _deleteTimeQuery(query: WebGLQuery): void;
  108478. /** @hidden */
  108479. _getGlAlgorithmType(algorithmType: number): number;
  108480. /** @hidden */
  108481. _getTimeQueryResult(query: WebGLQuery): any;
  108482. /** @hidden */
  108483. _getTimeQueryAvailability(query: WebGLQuery): any;
  108484. }
  108485. interface AbstractMesh {
  108486. /**
  108487. * Backing filed
  108488. * @hidden
  108489. */
  108490. __occlusionDataStorage: _OcclusionDataStorage;
  108491. /**
  108492. * Access property
  108493. * @hidden
  108494. */
  108495. _occlusionDataStorage: _OcclusionDataStorage;
  108496. /**
  108497. * 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.
  108498. * The default value is -1 which means don't break the query and wait till the result
  108499. * @see http://doc.babylonjs.com/features/occlusionquery
  108500. */
  108501. occlusionRetryCount: number;
  108502. /**
  108503. * 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:
  108504. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108505. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108506. * * 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.
  108507. * @see http://doc.babylonjs.com/features/occlusionquery
  108508. */
  108509. occlusionType: number;
  108510. /**
  108511. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108512. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108513. * * 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.
  108514. * @see http://doc.babylonjs.com/features/occlusionquery
  108515. */
  108516. occlusionQueryAlgorithmType: number;
  108517. /**
  108518. * 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
  108519. * @see http://doc.babylonjs.com/features/occlusionquery
  108520. */
  108521. isOccluded: boolean;
  108522. /**
  108523. * Flag to check the progress status of the query
  108524. * @see http://doc.babylonjs.com/features/occlusionquery
  108525. */
  108526. isOcclusionQueryInProgress: boolean;
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /** @hidden */
  108531. export var _forceTransformFeedbackToBundle: boolean;
  108532. interface Engine {
  108533. /**
  108534. * Creates a webGL transform feedback object
  108535. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108536. * @returns the webGL transform feedback object
  108537. */
  108538. createTransformFeedback(): WebGLTransformFeedback;
  108539. /**
  108540. * Delete a webGL transform feedback object
  108541. * @param value defines the webGL transform feedback object to delete
  108542. */
  108543. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108544. /**
  108545. * Bind a webGL transform feedback object to the webgl context
  108546. * @param value defines the webGL transform feedback object to bind
  108547. */
  108548. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108549. /**
  108550. * Begins a transform feedback operation
  108551. * @param usePoints defines if points or triangles must be used
  108552. */
  108553. beginTransformFeedback(usePoints: boolean): void;
  108554. /**
  108555. * Ends a transform feedback operation
  108556. */
  108557. endTransformFeedback(): void;
  108558. /**
  108559. * Specify the varyings to use with transform feedback
  108560. * @param program defines the associated webGL program
  108561. * @param value defines the list of strings representing the varying names
  108562. */
  108563. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108564. /**
  108565. * Bind a webGL buffer for a transform feedback operation
  108566. * @param value defines the webGL buffer to bind
  108567. */
  108568. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108569. }
  108570. }
  108571. declare module BABYLON {
  108572. /**
  108573. * Creation options of the multi render target texture.
  108574. */
  108575. export interface IMultiRenderTargetOptions {
  108576. /**
  108577. * Define if the texture needs to create mip maps after render.
  108578. */
  108579. generateMipMaps?: boolean;
  108580. /**
  108581. * Define the types of all the draw buffers we want to create
  108582. */
  108583. types?: number[];
  108584. /**
  108585. * Define the sampling modes of all the draw buffers we want to create
  108586. */
  108587. samplingModes?: number[];
  108588. /**
  108589. * Define if a depth buffer is required
  108590. */
  108591. generateDepthBuffer?: boolean;
  108592. /**
  108593. * Define if a stencil buffer is required
  108594. */
  108595. generateStencilBuffer?: boolean;
  108596. /**
  108597. * Define if a depth texture is required instead of a depth buffer
  108598. */
  108599. generateDepthTexture?: boolean;
  108600. /**
  108601. * Define the number of desired draw buffers
  108602. */
  108603. textureCount?: number;
  108604. /**
  108605. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108606. */
  108607. doNotChangeAspectRatio?: boolean;
  108608. /**
  108609. * Define the default type of the buffers we are creating
  108610. */
  108611. defaultType?: number;
  108612. }
  108613. /**
  108614. * A multi render target, like a render target provides the ability to render to a texture.
  108615. * Unlike the render target, it can render to several draw buffers in one draw.
  108616. * This is specially interesting in deferred rendering or for any effects requiring more than
  108617. * just one color from a single pass.
  108618. */
  108619. export class MultiRenderTarget extends RenderTargetTexture {
  108620. private _internalTextures;
  108621. private _textures;
  108622. private _multiRenderTargetOptions;
  108623. /**
  108624. * Get if draw buffers are currently supported by the used hardware and browser.
  108625. */
  108626. readonly isSupported: boolean;
  108627. /**
  108628. * Get the list of textures generated by the multi render target.
  108629. */
  108630. readonly textures: Texture[];
  108631. /**
  108632. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108633. */
  108634. readonly depthTexture: Texture;
  108635. /**
  108636. * Set the wrapping mode on U of all the textures we are rendering to.
  108637. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108638. */
  108639. wrapU: number;
  108640. /**
  108641. * Set the wrapping mode on V of all the textures we are rendering to.
  108642. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108643. */
  108644. wrapV: number;
  108645. /**
  108646. * Instantiate a new multi render target texture.
  108647. * A multi render target, like a render target provides the ability to render to a texture.
  108648. * Unlike the render target, it can render to several draw buffers in one draw.
  108649. * This is specially interesting in deferred rendering or for any effects requiring more than
  108650. * just one color from a single pass.
  108651. * @param name Define the name of the texture
  108652. * @param size Define the size of the buffers to render to
  108653. * @param count Define the number of target we are rendering into
  108654. * @param scene Define the scene the texture belongs to
  108655. * @param options Define the options used to create the multi render target
  108656. */
  108657. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108658. /** @hidden */
  108659. _rebuild(): void;
  108660. private _createInternalTextures;
  108661. private _createTextures;
  108662. /**
  108663. * Define the number of samples used if MSAA is enabled.
  108664. */
  108665. samples: number;
  108666. /**
  108667. * Resize all the textures in the multi render target.
  108668. * Be carrefull as it will recreate all the data in the new texture.
  108669. * @param size Define the new size
  108670. */
  108671. resize(size: any): void;
  108672. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108673. /**
  108674. * Dispose the render targets and their associated resources
  108675. */
  108676. dispose(): void;
  108677. /**
  108678. * Release all the underlying texture used as draw buffers.
  108679. */
  108680. releaseInternalTextures(): void;
  108681. }
  108682. }
  108683. declare module BABYLON {
  108684. interface Engine {
  108685. /**
  108686. * Unbind a list of render target textures from the webGL context
  108687. * This is used only when drawBuffer extension or webGL2 are active
  108688. * @param textures defines the render target textures to unbind
  108689. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108690. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108691. */
  108692. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108693. /**
  108694. * Create a multi render target texture
  108695. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108696. * @param size defines the size of the texture
  108697. * @param options defines the creation options
  108698. * @returns the cube texture as an InternalTexture
  108699. */
  108700. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108701. /**
  108702. * Update the sample count for a given multiple render target texture
  108703. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108704. * @param textures defines the textures to update
  108705. * @param samples defines the sample count to set
  108706. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108707. */
  108708. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108709. }
  108710. }
  108711. declare module BABYLON {
  108712. /**
  108713. * Gather the list of clipboard event types as constants.
  108714. */
  108715. export class ClipboardEventTypes {
  108716. /**
  108717. * The clipboard event is fired when a copy command is active (pressed).
  108718. */
  108719. static readonly COPY: number;
  108720. /**
  108721. * The clipboard event is fired when a cut command is active (pressed).
  108722. */
  108723. static readonly CUT: number;
  108724. /**
  108725. * The clipboard event is fired when a paste command is active (pressed).
  108726. */
  108727. static readonly PASTE: number;
  108728. }
  108729. /**
  108730. * This class is used to store clipboard related info for the onClipboardObservable event.
  108731. */
  108732. export class ClipboardInfo {
  108733. /**
  108734. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108735. */
  108736. type: number;
  108737. /**
  108738. * Defines the related dom event
  108739. */
  108740. event: ClipboardEvent;
  108741. /**
  108742. *Creates an instance of ClipboardInfo.
  108743. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108744. * @param event Defines the related dom event
  108745. */
  108746. constructor(
  108747. /**
  108748. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108749. */
  108750. type: number,
  108751. /**
  108752. * Defines the related dom event
  108753. */
  108754. event: ClipboardEvent);
  108755. /**
  108756. * Get the clipboard event's type from the keycode.
  108757. * @param keyCode Defines the keyCode for the current keyboard event.
  108758. * @return {number}
  108759. */
  108760. static GetTypeFromCharacter(keyCode: number): number;
  108761. }
  108762. }
  108763. declare module BABYLON {
  108764. /**
  108765. * Google Daydream controller
  108766. */
  108767. export class DaydreamController extends WebVRController {
  108768. /**
  108769. * Base Url for the controller model.
  108770. */
  108771. static MODEL_BASE_URL: string;
  108772. /**
  108773. * File name for the controller model.
  108774. */
  108775. static MODEL_FILENAME: string;
  108776. /**
  108777. * Gamepad Id prefix used to identify Daydream Controller.
  108778. */
  108779. static readonly GAMEPAD_ID_PREFIX: string;
  108780. /**
  108781. * Creates a new DaydreamController from a gamepad
  108782. * @param vrGamepad the gamepad that the controller should be created from
  108783. */
  108784. constructor(vrGamepad: any);
  108785. /**
  108786. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108787. * @param scene scene in which to add meshes
  108788. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108789. */
  108790. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108791. /**
  108792. * Called once for each button that changed state since the last frame
  108793. * @param buttonIdx Which button index changed
  108794. * @param state New state of the button
  108795. * @param changes Which properties on the state changed since last frame
  108796. */
  108797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108798. }
  108799. }
  108800. declare module BABYLON {
  108801. /**
  108802. * Gear VR Controller
  108803. */
  108804. export class GearVRController extends WebVRController {
  108805. /**
  108806. * Base Url for the controller model.
  108807. */
  108808. static MODEL_BASE_URL: string;
  108809. /**
  108810. * File name for the controller model.
  108811. */
  108812. static MODEL_FILENAME: string;
  108813. /**
  108814. * Gamepad Id prefix used to identify this controller.
  108815. */
  108816. static readonly GAMEPAD_ID_PREFIX: string;
  108817. private readonly _buttonIndexToObservableNameMap;
  108818. /**
  108819. * Creates a new GearVRController from a gamepad
  108820. * @param vrGamepad the gamepad that the controller should be created from
  108821. */
  108822. constructor(vrGamepad: any);
  108823. /**
  108824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108825. * @param scene scene in which to add meshes
  108826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108827. */
  108828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108829. /**
  108830. * Called once for each button that changed state since the last frame
  108831. * @param buttonIdx Which button index changed
  108832. * @param state New state of the button
  108833. * @param changes Which properties on the state changed since last frame
  108834. */
  108835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108836. }
  108837. }
  108838. declare module BABYLON {
  108839. /**
  108840. * Class containing static functions to help procedurally build meshes
  108841. */
  108842. export class PolyhedronBuilder {
  108843. /**
  108844. * Creates a polyhedron mesh
  108845. * * 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
  108846. * * The parameter `size` (positive float, default 1) sets the polygon size
  108847. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108848. * * 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`
  108849. * * 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
  108850. * * 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)`)
  108851. * * 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
  108852. * * 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
  108853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108856. * @param name defines the name of the mesh
  108857. * @param options defines the options used to create the mesh
  108858. * @param scene defines the hosting scene
  108859. * @returns the polyhedron mesh
  108860. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108861. */
  108862. static CreatePolyhedron(name: string, options: {
  108863. type?: number;
  108864. size?: number;
  108865. sizeX?: number;
  108866. sizeY?: number;
  108867. sizeZ?: number;
  108868. custom?: any;
  108869. faceUV?: Vector4[];
  108870. faceColors?: Color4[];
  108871. flat?: boolean;
  108872. updatable?: boolean;
  108873. sideOrientation?: number;
  108874. frontUVs?: Vector4;
  108875. backUVs?: Vector4;
  108876. }, scene?: Nullable<Scene>): Mesh;
  108877. }
  108878. }
  108879. declare module BABYLON {
  108880. /**
  108881. * Gizmo that enables scaling a mesh along 3 axis
  108882. */
  108883. export class ScaleGizmo extends Gizmo {
  108884. /**
  108885. * Internal gizmo used for interactions on the x axis
  108886. */
  108887. xGizmo: AxisScaleGizmo;
  108888. /**
  108889. * Internal gizmo used for interactions on the y axis
  108890. */
  108891. yGizmo: AxisScaleGizmo;
  108892. /**
  108893. * Internal gizmo used for interactions on the z axis
  108894. */
  108895. zGizmo: AxisScaleGizmo;
  108896. /**
  108897. * Internal gizmo used to scale all axis equally
  108898. */
  108899. uniformScaleGizmo: AxisScaleGizmo;
  108900. private _meshAttached;
  108901. private _updateGizmoRotationToMatchAttachedMesh;
  108902. private _snapDistance;
  108903. private _scaleRatio;
  108904. private _uniformScalingMesh;
  108905. private _octahedron;
  108906. /** Fires an event when any of it's sub gizmos are dragged */
  108907. onDragStartObservable: Observable<unknown>;
  108908. /** Fires an event when any of it's sub gizmos are released from dragging */
  108909. onDragEndObservable: Observable<unknown>;
  108910. attachedMesh: Nullable<AbstractMesh>;
  108911. /**
  108912. * Creates a ScaleGizmo
  108913. * @param gizmoLayer The utility layer the gizmo will be added to
  108914. */
  108915. constructor(gizmoLayer?: UtilityLayerRenderer);
  108916. updateGizmoRotationToMatchAttachedMesh: boolean;
  108917. /**
  108918. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108919. */
  108920. snapDistance: number;
  108921. /**
  108922. * Ratio for the scale of the gizmo (Default: 1)
  108923. */
  108924. scaleRatio: number;
  108925. /**
  108926. * Disposes of the gizmo
  108927. */
  108928. dispose(): void;
  108929. }
  108930. }
  108931. declare module BABYLON {
  108932. /**
  108933. * Single axis scale gizmo
  108934. */
  108935. export class AxisScaleGizmo extends Gizmo {
  108936. /**
  108937. * Drag behavior responsible for the gizmos dragging interactions
  108938. */
  108939. dragBehavior: PointerDragBehavior;
  108940. private _pointerObserver;
  108941. /**
  108942. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108943. */
  108944. snapDistance: number;
  108945. /**
  108946. * Event that fires each time the gizmo snaps to a new location.
  108947. * * snapDistance is the the change in distance
  108948. */
  108949. onSnapObservable: Observable<{
  108950. snapDistance: number;
  108951. }>;
  108952. /**
  108953. * If the scaling operation should be done on all axis (default: false)
  108954. */
  108955. uniformScaling: boolean;
  108956. private _isEnabled;
  108957. private _parent;
  108958. private _arrow;
  108959. private _coloredMaterial;
  108960. private _hoverMaterial;
  108961. /**
  108962. * Creates an AxisScaleGizmo
  108963. * @param gizmoLayer The utility layer the gizmo will be added to
  108964. * @param dragAxis The axis which the gizmo will be able to scale on
  108965. * @param color The color of the gizmo
  108966. */
  108967. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108968. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108969. /**
  108970. * If the gizmo is enabled
  108971. */
  108972. isEnabled: boolean;
  108973. /**
  108974. * Disposes of the gizmo
  108975. */
  108976. dispose(): void;
  108977. /**
  108978. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108979. * @param mesh The mesh to replace the default mesh of the gizmo
  108980. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108981. */
  108982. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108983. }
  108984. }
  108985. declare module BABYLON {
  108986. /**
  108987. * Bounding box gizmo
  108988. */
  108989. export class BoundingBoxGizmo extends Gizmo {
  108990. private _lineBoundingBox;
  108991. private _rotateSpheresParent;
  108992. private _scaleBoxesParent;
  108993. private _boundingDimensions;
  108994. private _renderObserver;
  108995. private _pointerObserver;
  108996. private _scaleDragSpeed;
  108997. private _tmpQuaternion;
  108998. private _tmpVector;
  108999. private _tmpRotationMatrix;
  109000. /**
  109001. * 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)
  109002. */
  109003. ignoreChildren: boolean;
  109004. /**
  109005. * 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)
  109006. */
  109007. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  109008. /**
  109009. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  109010. */
  109011. rotationSphereSize: number;
  109012. /**
  109013. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  109014. */
  109015. scaleBoxSize: number;
  109016. /**
  109017. * 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)
  109018. */
  109019. fixedDragMeshScreenSize: boolean;
  109020. /**
  109021. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  109022. */
  109023. fixedDragMeshScreenSizeDistanceFactor: number;
  109024. /**
  109025. * Fired when a rotation sphere or scale box is dragged
  109026. */
  109027. onDragStartObservable: Observable<{}>;
  109028. /**
  109029. * Fired when a scale box is dragged
  109030. */
  109031. onScaleBoxDragObservable: Observable<{}>;
  109032. /**
  109033. * Fired when a scale box drag is ended
  109034. */
  109035. onScaleBoxDragEndObservable: Observable<{}>;
  109036. /**
  109037. * Fired when a rotation sphere is dragged
  109038. */
  109039. onRotationSphereDragObservable: Observable<{}>;
  109040. /**
  109041. * Fired when a rotation sphere drag is ended
  109042. */
  109043. onRotationSphereDragEndObservable: Observable<{}>;
  109044. /**
  109045. * 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)
  109046. */
  109047. scalePivot: Nullable<Vector3>;
  109048. /**
  109049. * Mesh used as a pivot to rotate the attached mesh
  109050. */
  109051. private _anchorMesh;
  109052. private _existingMeshScale;
  109053. private _dragMesh;
  109054. private pointerDragBehavior;
  109055. private coloredMaterial;
  109056. private hoverColoredMaterial;
  109057. /**
  109058. * Sets the color of the bounding box gizmo
  109059. * @param color the color to set
  109060. */
  109061. setColor(color: Color3): void;
  109062. /**
  109063. * Creates an BoundingBoxGizmo
  109064. * @param gizmoLayer The utility layer the gizmo will be added to
  109065. * @param color The color of the gizmo
  109066. */
  109067. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  109068. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109069. private _selectNode;
  109070. /**
  109071. * Updates the bounding box information for the Gizmo
  109072. */
  109073. updateBoundingBox(): void;
  109074. private _updateRotationSpheres;
  109075. private _updateScaleBoxes;
  109076. /**
  109077. * Enables rotation on the specified axis and disables rotation on the others
  109078. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  109079. */
  109080. setEnabledRotationAxis(axis: string): void;
  109081. /**
  109082. * Enables/disables scaling
  109083. * @param enable if scaling should be enabled
  109084. */
  109085. setEnabledScaling(enable: boolean): void;
  109086. private _updateDummy;
  109087. /**
  109088. * Enables a pointer drag behavior on the bounding box of the gizmo
  109089. */
  109090. enableDragBehavior(): void;
  109091. /**
  109092. * Disposes of the gizmo
  109093. */
  109094. dispose(): void;
  109095. /**
  109096. * 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)
  109097. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  109098. * @returns the bounding box mesh with the passed in mesh as a child
  109099. */
  109100. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  109101. /**
  109102. * CustomMeshes are not supported by this gizmo
  109103. * @param mesh The mesh to replace the default mesh of the gizmo
  109104. */
  109105. setCustomMesh(mesh: Mesh): void;
  109106. }
  109107. }
  109108. declare module BABYLON {
  109109. /**
  109110. * Single plane rotation gizmo
  109111. */
  109112. export class PlaneRotationGizmo extends Gizmo {
  109113. /**
  109114. * Drag behavior responsible for the gizmos dragging interactions
  109115. */
  109116. dragBehavior: PointerDragBehavior;
  109117. private _pointerObserver;
  109118. /**
  109119. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  109120. */
  109121. snapDistance: number;
  109122. /**
  109123. * Event that fires each time the gizmo snaps to a new location.
  109124. * * snapDistance is the the change in distance
  109125. */
  109126. onSnapObservable: Observable<{
  109127. snapDistance: number;
  109128. }>;
  109129. private _isEnabled;
  109130. private _parent;
  109131. /**
  109132. * Creates a PlaneRotationGizmo
  109133. * @param gizmoLayer The utility layer the gizmo will be added to
  109134. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  109135. * @param color The color of the gizmo
  109136. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109137. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109138. */
  109139. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  109140. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109141. /**
  109142. * If the gizmo is enabled
  109143. */
  109144. isEnabled: boolean;
  109145. /**
  109146. * Disposes of the gizmo
  109147. */
  109148. dispose(): void;
  109149. }
  109150. }
  109151. declare module BABYLON {
  109152. /**
  109153. * Gizmo that enables rotating a mesh along 3 axis
  109154. */
  109155. export class RotationGizmo extends Gizmo {
  109156. /**
  109157. * Internal gizmo used for interactions on the x axis
  109158. */
  109159. xGizmo: PlaneRotationGizmo;
  109160. /**
  109161. * Internal gizmo used for interactions on the y axis
  109162. */
  109163. yGizmo: PlaneRotationGizmo;
  109164. /**
  109165. * Internal gizmo used for interactions on the z axis
  109166. */
  109167. zGizmo: PlaneRotationGizmo;
  109168. /** Fires an event when any of it's sub gizmos are dragged */
  109169. onDragStartObservable: Observable<unknown>;
  109170. /** Fires an event when any of it's sub gizmos are released from dragging */
  109171. onDragEndObservable: Observable<unknown>;
  109172. private _meshAttached;
  109173. attachedMesh: Nullable<AbstractMesh>;
  109174. /**
  109175. * Creates a RotationGizmo
  109176. * @param gizmoLayer The utility layer the gizmo will be added to
  109177. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109178. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109179. */
  109180. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  109181. updateGizmoRotationToMatchAttachedMesh: boolean;
  109182. /**
  109183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109184. */
  109185. snapDistance: number;
  109186. /**
  109187. * Ratio for the scale of the gizmo (Default: 1)
  109188. */
  109189. scaleRatio: number;
  109190. /**
  109191. * Disposes of the gizmo
  109192. */
  109193. dispose(): void;
  109194. /**
  109195. * CustomMeshes are not supported by this gizmo
  109196. * @param mesh The mesh to replace the default mesh of the gizmo
  109197. */
  109198. setCustomMesh(mesh: Mesh): void;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  109204. */
  109205. export class GizmoManager implements IDisposable {
  109206. private scene;
  109207. /**
  109208. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  109209. */
  109210. gizmos: {
  109211. positionGizmo: Nullable<PositionGizmo>;
  109212. rotationGizmo: Nullable<RotationGizmo>;
  109213. scaleGizmo: Nullable<ScaleGizmo>;
  109214. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  109215. };
  109216. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  109217. clearGizmoOnEmptyPointerEvent: boolean;
  109218. /** Fires an event when the manager is attached to a mesh */
  109219. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  109220. private _gizmosEnabled;
  109221. private _pointerObserver;
  109222. private _attachedMesh;
  109223. private _boundingBoxColor;
  109224. private _defaultUtilityLayer;
  109225. private _defaultKeepDepthUtilityLayer;
  109226. /**
  109227. * When bounding box gizmo is enabled, this can be used to track drag/end events
  109228. */
  109229. boundingBoxDragBehavior: SixDofDragBehavior;
  109230. /**
  109231. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  109232. */
  109233. attachableMeshes: Nullable<Array<AbstractMesh>>;
  109234. /**
  109235. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  109236. */
  109237. usePointerToAttachGizmos: boolean;
  109238. /**
  109239. * Utility layer that the bounding box gizmo belongs to
  109240. */
  109241. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  109242. /**
  109243. * Utility layer that all gizmos besides bounding box belong to
  109244. */
  109245. readonly utilityLayer: UtilityLayerRenderer;
  109246. /**
  109247. * Instatiates a gizmo manager
  109248. * @param scene the scene to overlay the gizmos on top of
  109249. */
  109250. constructor(scene: Scene);
  109251. /**
  109252. * Attaches a set of gizmos to the specified mesh
  109253. * @param mesh The mesh the gizmo's should be attached to
  109254. */
  109255. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  109256. /**
  109257. * If the position gizmo is enabled
  109258. */
  109259. positionGizmoEnabled: boolean;
  109260. /**
  109261. * If the rotation gizmo is enabled
  109262. */
  109263. rotationGizmoEnabled: boolean;
  109264. /**
  109265. * If the scale gizmo is enabled
  109266. */
  109267. scaleGizmoEnabled: boolean;
  109268. /**
  109269. * If the boundingBox gizmo is enabled
  109270. */
  109271. boundingBoxGizmoEnabled: boolean;
  109272. /**
  109273. * Disposes of the gizmo manager
  109274. */
  109275. dispose(): void;
  109276. }
  109277. }
  109278. declare module BABYLON {
  109279. /**
  109280. * A directional light is defined by a direction (what a surprise!).
  109281. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  109282. * 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.
  109283. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109284. */
  109285. export class DirectionalLight extends ShadowLight {
  109286. private _shadowFrustumSize;
  109287. /**
  109288. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  109289. */
  109290. /**
  109291. * Specifies a fix frustum size for the shadow generation.
  109292. */
  109293. shadowFrustumSize: number;
  109294. private _shadowOrthoScale;
  109295. /**
  109296. * Gets the shadow projection scale against the optimal computed one.
  109297. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109298. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109299. */
  109300. /**
  109301. * Sets the shadow projection scale against the optimal computed one.
  109302. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109303. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109304. */
  109305. shadowOrthoScale: number;
  109306. /**
  109307. * Automatically compute the projection matrix to best fit (including all the casters)
  109308. * on each frame.
  109309. */
  109310. autoUpdateExtends: boolean;
  109311. private _orthoLeft;
  109312. private _orthoRight;
  109313. private _orthoTop;
  109314. private _orthoBottom;
  109315. /**
  109316. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  109317. * The directional light is emitted from everywhere in the given direction.
  109318. * It can cast shadows.
  109319. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109320. * @param name The friendly name of the light
  109321. * @param direction The direction of the light
  109322. * @param scene The scene the light belongs to
  109323. */
  109324. constructor(name: string, direction: Vector3, scene: Scene);
  109325. /**
  109326. * Returns the string "DirectionalLight".
  109327. * @return The class name
  109328. */
  109329. getClassName(): string;
  109330. /**
  109331. * Returns the integer 1.
  109332. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109333. */
  109334. getTypeID(): number;
  109335. /**
  109336. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  109337. * Returns the DirectionalLight Shadow projection matrix.
  109338. */
  109339. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109340. /**
  109341. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  109342. * Returns the DirectionalLight Shadow projection matrix.
  109343. */
  109344. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  109345. /**
  109346. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  109347. * Returns the DirectionalLight Shadow projection matrix.
  109348. */
  109349. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109350. protected _buildUniformLayout(): void;
  109351. /**
  109352. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  109353. * @param effect The effect to update
  109354. * @param lightIndex The index of the light in the effect to update
  109355. * @returns The directional light
  109356. */
  109357. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  109358. /**
  109359. * Gets the minZ used for shadow according to both the scene and the light.
  109360. *
  109361. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109362. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109363. * @param activeCamera The camera we are returning the min for
  109364. * @returns the depth min z
  109365. */
  109366. getDepthMinZ(activeCamera: Camera): number;
  109367. /**
  109368. * Gets the maxZ used for shadow according to both the scene and the light.
  109369. *
  109370. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109371. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109372. * @param activeCamera The camera we are returning the max for
  109373. * @returns the depth max z
  109374. */
  109375. getDepthMaxZ(activeCamera: Camera): number;
  109376. /**
  109377. * Prepares the list of defines specific to the light type.
  109378. * @param defines the list of defines
  109379. * @param lightIndex defines the index of the light for the effect
  109380. */
  109381. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109382. }
  109383. }
  109384. declare module BABYLON {
  109385. /**
  109386. * Class containing static functions to help procedurally build meshes
  109387. */
  109388. export class HemisphereBuilder {
  109389. /**
  109390. * Creates a hemisphere mesh
  109391. * @param name defines the name of the mesh
  109392. * @param options defines the options used to create the mesh
  109393. * @param scene defines the hosting scene
  109394. * @returns the hemisphere mesh
  109395. */
  109396. static CreateHemisphere(name: string, options: {
  109397. segments?: number;
  109398. diameter?: number;
  109399. sideOrientation?: number;
  109400. }, scene: any): Mesh;
  109401. }
  109402. }
  109403. declare module BABYLON {
  109404. /**
  109405. * A spot light is defined by a position, a direction, an angle, and an exponent.
  109406. * These values define a cone of light starting from the position, emitting toward the direction.
  109407. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  109408. * and the exponent defines the speed of the decay of the light with distance (reach).
  109409. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109410. */
  109411. export class SpotLight extends ShadowLight {
  109412. private _angle;
  109413. private _innerAngle;
  109414. private _cosHalfAngle;
  109415. private _lightAngleScale;
  109416. private _lightAngleOffset;
  109417. /**
  109418. * Gets the cone angle of the spot light in Radians.
  109419. */
  109420. /**
  109421. * Sets the cone angle of the spot light in Radians.
  109422. */
  109423. angle: number;
  109424. /**
  109425. * Only used in gltf falloff mode, this defines the angle where
  109426. * the directional falloff will start before cutting at angle which could be seen
  109427. * as outer angle.
  109428. */
  109429. /**
  109430. * Only used in gltf falloff mode, this defines the angle where
  109431. * the directional falloff will start before cutting at angle which could be seen
  109432. * as outer angle.
  109433. */
  109434. innerAngle: number;
  109435. private _shadowAngleScale;
  109436. /**
  109437. * Allows scaling the angle of the light for shadow generation only.
  109438. */
  109439. /**
  109440. * Allows scaling the angle of the light for shadow generation only.
  109441. */
  109442. shadowAngleScale: number;
  109443. /**
  109444. * The light decay speed with the distance from the emission spot.
  109445. */
  109446. exponent: number;
  109447. private _projectionTextureMatrix;
  109448. /**
  109449. * Allows reading the projecton texture
  109450. */
  109451. readonly projectionTextureMatrix: Matrix;
  109452. protected _projectionTextureLightNear: number;
  109453. /**
  109454. * Gets the near clip of the Spotlight for texture projection.
  109455. */
  109456. /**
  109457. * Sets the near clip of the Spotlight for texture projection.
  109458. */
  109459. projectionTextureLightNear: number;
  109460. protected _projectionTextureLightFar: number;
  109461. /**
  109462. * Gets the far clip of the Spotlight for texture projection.
  109463. */
  109464. /**
  109465. * Sets the far clip of the Spotlight for texture projection.
  109466. */
  109467. projectionTextureLightFar: number;
  109468. protected _projectionTextureUpDirection: Vector3;
  109469. /**
  109470. * Gets the Up vector of the Spotlight for texture projection.
  109471. */
  109472. /**
  109473. * Sets the Up vector of the Spotlight for texture projection.
  109474. */
  109475. projectionTextureUpDirection: Vector3;
  109476. private _projectionTexture;
  109477. /**
  109478. * Gets the projection texture of the light.
  109479. */
  109480. /**
  109481. * Sets the projection texture of the light.
  109482. */
  109483. projectionTexture: Nullable<BaseTexture>;
  109484. private _projectionTextureViewLightDirty;
  109485. private _projectionTextureProjectionLightDirty;
  109486. private _projectionTextureDirty;
  109487. private _projectionTextureViewTargetVector;
  109488. private _projectionTextureViewLightMatrix;
  109489. private _projectionTextureProjectionLightMatrix;
  109490. private _projectionTextureScalingMatrix;
  109491. /**
  109492. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109493. * It can cast shadows.
  109494. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109495. * @param name The light friendly name
  109496. * @param position The position of the spot light in the scene
  109497. * @param direction The direction of the light in the scene
  109498. * @param angle The cone angle of the light in Radians
  109499. * @param exponent The light decay speed with the distance from the emission spot
  109500. * @param scene The scene the lights belongs to
  109501. */
  109502. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109503. /**
  109504. * Returns the string "SpotLight".
  109505. * @returns the class name
  109506. */
  109507. getClassName(): string;
  109508. /**
  109509. * Returns the integer 2.
  109510. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109511. */
  109512. getTypeID(): number;
  109513. /**
  109514. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109515. */
  109516. protected _setDirection(value: Vector3): void;
  109517. /**
  109518. * Overrides the position setter to recompute the projection texture view light Matrix.
  109519. */
  109520. protected _setPosition(value: Vector3): void;
  109521. /**
  109522. * 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.
  109523. * Returns the SpotLight.
  109524. */
  109525. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109526. protected _computeProjectionTextureViewLightMatrix(): void;
  109527. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109528. /**
  109529. * Main function for light texture projection matrix computing.
  109530. */
  109531. protected _computeProjectionTextureMatrix(): void;
  109532. protected _buildUniformLayout(): void;
  109533. private _computeAngleValues;
  109534. /**
  109535. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109536. * @param effect The effect to update
  109537. * @param lightIndex The index of the light in the effect to update
  109538. * @returns The spot light
  109539. */
  109540. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109541. /**
  109542. * Disposes the light and the associated resources.
  109543. */
  109544. dispose(): void;
  109545. /**
  109546. * Prepares the list of defines specific to the light type.
  109547. * @param defines the list of defines
  109548. * @param lightIndex defines the index of the light for the effect
  109549. */
  109550. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109551. }
  109552. }
  109553. declare module BABYLON {
  109554. /**
  109555. * Gizmo that enables viewing a light
  109556. */
  109557. export class LightGizmo extends Gizmo {
  109558. private _lightMesh;
  109559. private _material;
  109560. private cachedPosition;
  109561. private cachedForward;
  109562. /**
  109563. * Creates a LightGizmo
  109564. * @param gizmoLayer The utility layer the gizmo will be added to
  109565. */
  109566. constructor(gizmoLayer?: UtilityLayerRenderer);
  109567. private _light;
  109568. /**
  109569. * The light that the gizmo is attached to
  109570. */
  109571. light: Nullable<Light>;
  109572. /**
  109573. * Gets the material used to render the light gizmo
  109574. */
  109575. readonly material: StandardMaterial;
  109576. /**
  109577. * @hidden
  109578. * Updates the gizmo to match the attached mesh's position/rotation
  109579. */
  109580. protected _update(): void;
  109581. private static _Scale;
  109582. /**
  109583. * Creates the lines for a light mesh
  109584. */
  109585. private static _createLightLines;
  109586. /**
  109587. * Disposes of the light gizmo
  109588. */
  109589. dispose(): void;
  109590. private static _CreateHemisphericLightMesh;
  109591. private static _CreatePointLightMesh;
  109592. private static _CreateSpotLightMesh;
  109593. private static _CreateDirectionalLightMesh;
  109594. }
  109595. }
  109596. declare module BABYLON {
  109597. /** @hidden */
  109598. export var backgroundFragmentDeclaration: {
  109599. name: string;
  109600. shader: string;
  109601. };
  109602. }
  109603. declare module BABYLON {
  109604. /** @hidden */
  109605. export var backgroundUboDeclaration: {
  109606. name: string;
  109607. shader: string;
  109608. };
  109609. }
  109610. declare module BABYLON {
  109611. /** @hidden */
  109612. export var backgroundPixelShader: {
  109613. name: string;
  109614. shader: string;
  109615. };
  109616. }
  109617. declare module BABYLON {
  109618. /** @hidden */
  109619. export var backgroundVertexDeclaration: {
  109620. name: string;
  109621. shader: string;
  109622. };
  109623. }
  109624. declare module BABYLON {
  109625. /** @hidden */
  109626. export var backgroundVertexShader: {
  109627. name: string;
  109628. shader: string;
  109629. };
  109630. }
  109631. declare module BABYLON {
  109632. /**
  109633. * Background material used to create an efficient environement around your scene.
  109634. */
  109635. export class BackgroundMaterial extends PushMaterial {
  109636. /**
  109637. * Standard reflectance value at parallel view angle.
  109638. */
  109639. static StandardReflectance0: number;
  109640. /**
  109641. * Standard reflectance value at grazing angle.
  109642. */
  109643. static StandardReflectance90: number;
  109644. protected _primaryColor: Color3;
  109645. /**
  109646. * Key light Color (multiply against the environement texture)
  109647. */
  109648. primaryColor: Color3;
  109649. protected __perceptualColor: Nullable<Color3>;
  109650. /**
  109651. * Experimental Internal Use Only.
  109652. *
  109653. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109654. * This acts as a helper to set the primary color to a more "human friendly" value.
  109655. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109656. * output color as close as possible from the chosen value.
  109657. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109658. * part of lighting setup.)
  109659. */
  109660. _perceptualColor: Nullable<Color3>;
  109661. protected _primaryColorShadowLevel: float;
  109662. /**
  109663. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109664. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109665. */
  109666. primaryColorShadowLevel: float;
  109667. protected _primaryColorHighlightLevel: float;
  109668. /**
  109669. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109670. * The primary color is used at the level chosen to define what the white area would look.
  109671. */
  109672. primaryColorHighlightLevel: float;
  109673. protected _reflectionTexture: Nullable<BaseTexture>;
  109674. /**
  109675. * Reflection Texture used in the material.
  109676. * Should be author in a specific way for the best result (refer to the documentation).
  109677. */
  109678. reflectionTexture: Nullable<BaseTexture>;
  109679. protected _reflectionBlur: float;
  109680. /**
  109681. * Reflection Texture level of blur.
  109682. *
  109683. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109684. * texture twice.
  109685. */
  109686. reflectionBlur: float;
  109687. protected _diffuseTexture: Nullable<BaseTexture>;
  109688. /**
  109689. * Diffuse Texture used in the material.
  109690. * Should be author in a specific way for the best result (refer to the documentation).
  109691. */
  109692. diffuseTexture: Nullable<BaseTexture>;
  109693. protected _shadowLights: Nullable<IShadowLight[]>;
  109694. /**
  109695. * Specify the list of lights casting shadow on the material.
  109696. * All scene shadow lights will be included if null.
  109697. */
  109698. shadowLights: Nullable<IShadowLight[]>;
  109699. protected _shadowLevel: float;
  109700. /**
  109701. * Helps adjusting the shadow to a softer level if required.
  109702. * 0 means black shadows and 1 means no shadows.
  109703. */
  109704. shadowLevel: float;
  109705. protected _sceneCenter: Vector3;
  109706. /**
  109707. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109708. * It is usually zero but might be interesting to modify according to your setup.
  109709. */
  109710. sceneCenter: Vector3;
  109711. protected _opacityFresnel: boolean;
  109712. /**
  109713. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109714. * This helps ensuring a nice transition when the camera goes under the ground.
  109715. */
  109716. opacityFresnel: boolean;
  109717. protected _reflectionFresnel: boolean;
  109718. /**
  109719. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109720. * This helps adding a mirror texture on the ground.
  109721. */
  109722. reflectionFresnel: boolean;
  109723. protected _reflectionFalloffDistance: number;
  109724. /**
  109725. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109726. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109727. */
  109728. reflectionFalloffDistance: number;
  109729. protected _reflectionAmount: number;
  109730. /**
  109731. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109732. */
  109733. reflectionAmount: number;
  109734. protected _reflectionReflectance0: number;
  109735. /**
  109736. * This specifies the weight of the reflection at grazing angle.
  109737. */
  109738. reflectionReflectance0: number;
  109739. protected _reflectionReflectance90: number;
  109740. /**
  109741. * This specifies the weight of the reflection at a perpendicular point of view.
  109742. */
  109743. reflectionReflectance90: number;
  109744. /**
  109745. * Sets the reflection reflectance fresnel values according to the default standard
  109746. * empirically know to work well :-)
  109747. */
  109748. reflectionStandardFresnelWeight: number;
  109749. protected _useRGBColor: boolean;
  109750. /**
  109751. * Helps to directly use the maps channels instead of their level.
  109752. */
  109753. useRGBColor: boolean;
  109754. protected _enableNoise: boolean;
  109755. /**
  109756. * This helps reducing the banding effect that could occur on the background.
  109757. */
  109758. enableNoise: boolean;
  109759. /**
  109760. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109761. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109762. * Recommended to be keep at 1.0 except for special cases.
  109763. */
  109764. fovMultiplier: number;
  109765. private _fovMultiplier;
  109766. /**
  109767. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109768. */
  109769. useEquirectangularFOV: boolean;
  109770. private _maxSimultaneousLights;
  109771. /**
  109772. * Number of Simultaneous lights allowed on the material.
  109773. */
  109774. maxSimultaneousLights: int;
  109775. /**
  109776. * Default configuration related to image processing available in the Background Material.
  109777. */
  109778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109779. /**
  109780. * Keep track of the image processing observer to allow dispose and replace.
  109781. */
  109782. private _imageProcessingObserver;
  109783. /**
  109784. * Attaches a new image processing configuration to the PBR Material.
  109785. * @param configuration (if null the scene configuration will be use)
  109786. */
  109787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109788. /**
  109789. * Gets the image processing configuration used either in this material.
  109790. */
  109791. /**
  109792. * Sets the Default image processing configuration used either in the this material.
  109793. *
  109794. * If sets to null, the scene one is in use.
  109795. */
  109796. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109797. /**
  109798. * Gets wether the color curves effect is enabled.
  109799. */
  109800. /**
  109801. * Sets wether the color curves effect is enabled.
  109802. */
  109803. cameraColorCurvesEnabled: boolean;
  109804. /**
  109805. * Gets wether the color grading effect is enabled.
  109806. */
  109807. /**
  109808. * Gets wether the color grading effect is enabled.
  109809. */
  109810. cameraColorGradingEnabled: boolean;
  109811. /**
  109812. * Gets wether tonemapping is enabled or not.
  109813. */
  109814. /**
  109815. * Sets wether tonemapping is enabled or not
  109816. */
  109817. cameraToneMappingEnabled: boolean;
  109818. /**
  109819. * The camera exposure used on this material.
  109820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109821. * This corresponds to a photographic exposure.
  109822. */
  109823. /**
  109824. * The camera exposure used on this material.
  109825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109826. * This corresponds to a photographic exposure.
  109827. */
  109828. cameraExposure: float;
  109829. /**
  109830. * Gets The camera contrast used on this material.
  109831. */
  109832. /**
  109833. * Sets The camera contrast used on this material.
  109834. */
  109835. cameraContrast: float;
  109836. /**
  109837. * Gets the Color Grading 2D Lookup Texture.
  109838. */
  109839. /**
  109840. * Sets the Color Grading 2D Lookup Texture.
  109841. */
  109842. cameraColorGradingTexture: Nullable<BaseTexture>;
  109843. /**
  109844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109846. * 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;
  109847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109848. */
  109849. /**
  109850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109852. * 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;
  109853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109854. */
  109855. cameraColorCurves: Nullable<ColorCurves>;
  109856. /**
  109857. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109858. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109859. */
  109860. switchToBGR: boolean;
  109861. private _renderTargets;
  109862. private _reflectionControls;
  109863. private _white;
  109864. private _primaryShadowColor;
  109865. private _primaryHighlightColor;
  109866. /**
  109867. * Instantiates a Background Material in the given scene
  109868. * @param name The friendly name of the material
  109869. * @param scene The scene to add the material to
  109870. */
  109871. constructor(name: string, scene: Scene);
  109872. /**
  109873. * Gets a boolean indicating that current material needs to register RTT
  109874. */
  109875. readonly hasRenderTargetTextures: boolean;
  109876. /**
  109877. * The entire material has been created in order to prevent overdraw.
  109878. * @returns false
  109879. */
  109880. needAlphaTesting(): boolean;
  109881. /**
  109882. * The entire material has been created in order to prevent overdraw.
  109883. * @returns true if blending is enable
  109884. */
  109885. needAlphaBlending(): boolean;
  109886. /**
  109887. * Checks wether the material is ready to be rendered for a given mesh.
  109888. * @param mesh The mesh to render
  109889. * @param subMesh The submesh to check against
  109890. * @param useInstances Specify wether or not the material is used with instances
  109891. * @returns true if all the dependencies are ready (Textures, Effects...)
  109892. */
  109893. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109894. /**
  109895. * Compute the primary color according to the chosen perceptual color.
  109896. */
  109897. private _computePrimaryColorFromPerceptualColor;
  109898. /**
  109899. * Compute the highlights and shadow colors according to their chosen levels.
  109900. */
  109901. private _computePrimaryColors;
  109902. /**
  109903. * Build the uniform buffer used in the material.
  109904. */
  109905. buildUniformLayout(): void;
  109906. /**
  109907. * Unbind the material.
  109908. */
  109909. unbind(): void;
  109910. /**
  109911. * Bind only the world matrix to the material.
  109912. * @param world The world matrix to bind.
  109913. */
  109914. bindOnlyWorldMatrix(world: Matrix): void;
  109915. /**
  109916. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109917. * @param world The world matrix to bind.
  109918. * @param subMesh The submesh to bind for.
  109919. */
  109920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109921. /**
  109922. * Checks to see if a texture is used in the material.
  109923. * @param texture - Base texture to use.
  109924. * @returns - Boolean specifying if a texture is used in the material.
  109925. */
  109926. hasTexture(texture: BaseTexture): boolean;
  109927. /**
  109928. * Dispose the material.
  109929. * @param forceDisposeEffect Force disposal of the associated effect.
  109930. * @param forceDisposeTextures Force disposal of the associated textures.
  109931. */
  109932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109933. /**
  109934. * Clones the material.
  109935. * @param name The cloned name.
  109936. * @returns The cloned material.
  109937. */
  109938. clone(name: string): BackgroundMaterial;
  109939. /**
  109940. * Serializes the current material to its JSON representation.
  109941. * @returns The JSON representation.
  109942. */
  109943. serialize(): any;
  109944. /**
  109945. * Gets the class name of the material
  109946. * @returns "BackgroundMaterial"
  109947. */
  109948. getClassName(): string;
  109949. /**
  109950. * Parse a JSON input to create back a background material.
  109951. * @param source The JSON data to parse
  109952. * @param scene The scene to create the parsed material in
  109953. * @param rootUrl The root url of the assets the material depends upon
  109954. * @returns the instantiated BackgroundMaterial.
  109955. */
  109956. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109957. }
  109958. }
  109959. declare module BABYLON {
  109960. /**
  109961. * Represents the different options available during the creation of
  109962. * a Environment helper.
  109963. *
  109964. * This can control the default ground, skybox and image processing setup of your scene.
  109965. */
  109966. export interface IEnvironmentHelperOptions {
  109967. /**
  109968. * Specifies wether or not to create a ground.
  109969. * True by default.
  109970. */
  109971. createGround: boolean;
  109972. /**
  109973. * Specifies the ground size.
  109974. * 15 by default.
  109975. */
  109976. groundSize: number;
  109977. /**
  109978. * The texture used on the ground for the main color.
  109979. * Comes from the BabylonJS CDN by default.
  109980. *
  109981. * Remarks: Can be either a texture or a url.
  109982. */
  109983. groundTexture: string | BaseTexture;
  109984. /**
  109985. * The color mixed in the ground texture by default.
  109986. * BabylonJS clearColor by default.
  109987. */
  109988. groundColor: Color3;
  109989. /**
  109990. * Specifies the ground opacity.
  109991. * 1 by default.
  109992. */
  109993. groundOpacity: number;
  109994. /**
  109995. * Enables the ground to receive shadows.
  109996. * True by default.
  109997. */
  109998. enableGroundShadow: boolean;
  109999. /**
  110000. * Helps preventing the shadow to be fully black on the ground.
  110001. * 0.5 by default.
  110002. */
  110003. groundShadowLevel: number;
  110004. /**
  110005. * Creates a mirror texture attach to the ground.
  110006. * false by default.
  110007. */
  110008. enableGroundMirror: boolean;
  110009. /**
  110010. * Specifies the ground mirror size ratio.
  110011. * 0.3 by default as the default kernel is 64.
  110012. */
  110013. groundMirrorSizeRatio: number;
  110014. /**
  110015. * Specifies the ground mirror blur kernel size.
  110016. * 64 by default.
  110017. */
  110018. groundMirrorBlurKernel: number;
  110019. /**
  110020. * Specifies the ground mirror visibility amount.
  110021. * 1 by default
  110022. */
  110023. groundMirrorAmount: number;
  110024. /**
  110025. * Specifies the ground mirror reflectance weight.
  110026. * This uses the standard weight of the background material to setup the fresnel effect
  110027. * of the mirror.
  110028. * 1 by default.
  110029. */
  110030. groundMirrorFresnelWeight: number;
  110031. /**
  110032. * Specifies the ground mirror Falloff distance.
  110033. * This can helps reducing the size of the reflection.
  110034. * 0 by Default.
  110035. */
  110036. groundMirrorFallOffDistance: number;
  110037. /**
  110038. * Specifies the ground mirror texture type.
  110039. * Unsigned Int by Default.
  110040. */
  110041. groundMirrorTextureType: number;
  110042. /**
  110043. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  110044. * the shown objects.
  110045. */
  110046. groundYBias: number;
  110047. /**
  110048. * Specifies wether or not to create a skybox.
  110049. * True by default.
  110050. */
  110051. createSkybox: boolean;
  110052. /**
  110053. * Specifies the skybox size.
  110054. * 20 by default.
  110055. */
  110056. skyboxSize: number;
  110057. /**
  110058. * The texture used on the skybox for the main color.
  110059. * Comes from the BabylonJS CDN by default.
  110060. *
  110061. * Remarks: Can be either a texture or a url.
  110062. */
  110063. skyboxTexture: string | BaseTexture;
  110064. /**
  110065. * The color mixed in the skybox texture by default.
  110066. * BabylonJS clearColor by default.
  110067. */
  110068. skyboxColor: Color3;
  110069. /**
  110070. * The background rotation around the Y axis of the scene.
  110071. * This helps aligning the key lights of your scene with the background.
  110072. * 0 by default.
  110073. */
  110074. backgroundYRotation: number;
  110075. /**
  110076. * Compute automatically the size of the elements to best fit with the scene.
  110077. */
  110078. sizeAuto: boolean;
  110079. /**
  110080. * Default position of the rootMesh if autoSize is not true.
  110081. */
  110082. rootPosition: Vector3;
  110083. /**
  110084. * Sets up the image processing in the scene.
  110085. * true by default.
  110086. */
  110087. setupImageProcessing: boolean;
  110088. /**
  110089. * The texture used as your environment texture in the scene.
  110090. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  110091. *
  110092. * Remarks: Can be either a texture or a url.
  110093. */
  110094. environmentTexture: string | BaseTexture;
  110095. /**
  110096. * The value of the exposure to apply to the scene.
  110097. * 0.6 by default if setupImageProcessing is true.
  110098. */
  110099. cameraExposure: number;
  110100. /**
  110101. * The value of the contrast to apply to the scene.
  110102. * 1.6 by default if setupImageProcessing is true.
  110103. */
  110104. cameraContrast: number;
  110105. /**
  110106. * Specifies wether or not tonemapping should be enabled in the scene.
  110107. * true by default if setupImageProcessing is true.
  110108. */
  110109. toneMappingEnabled: boolean;
  110110. }
  110111. /**
  110112. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  110113. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  110114. * It also helps with the default setup of your imageProcessing configuration.
  110115. */
  110116. export class EnvironmentHelper {
  110117. /**
  110118. * Default ground texture URL.
  110119. */
  110120. private static _groundTextureCDNUrl;
  110121. /**
  110122. * Default skybox texture URL.
  110123. */
  110124. private static _skyboxTextureCDNUrl;
  110125. /**
  110126. * Default environment texture URL.
  110127. */
  110128. private static _environmentTextureCDNUrl;
  110129. /**
  110130. * Creates the default options for the helper.
  110131. */
  110132. private static _getDefaultOptions;
  110133. private _rootMesh;
  110134. /**
  110135. * Gets the root mesh created by the helper.
  110136. */
  110137. readonly rootMesh: Mesh;
  110138. private _skybox;
  110139. /**
  110140. * Gets the skybox created by the helper.
  110141. */
  110142. readonly skybox: Nullable<Mesh>;
  110143. private _skyboxTexture;
  110144. /**
  110145. * Gets the skybox texture created by the helper.
  110146. */
  110147. readonly skyboxTexture: Nullable<BaseTexture>;
  110148. private _skyboxMaterial;
  110149. /**
  110150. * Gets the skybox material created by the helper.
  110151. */
  110152. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  110153. private _ground;
  110154. /**
  110155. * Gets the ground mesh created by the helper.
  110156. */
  110157. readonly ground: Nullable<Mesh>;
  110158. private _groundTexture;
  110159. /**
  110160. * Gets the ground texture created by the helper.
  110161. */
  110162. readonly groundTexture: Nullable<BaseTexture>;
  110163. private _groundMirror;
  110164. /**
  110165. * Gets the ground mirror created by the helper.
  110166. */
  110167. readonly groundMirror: Nullable<MirrorTexture>;
  110168. /**
  110169. * Gets the ground mirror render list to helps pushing the meshes
  110170. * you wish in the ground reflection.
  110171. */
  110172. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  110173. private _groundMaterial;
  110174. /**
  110175. * Gets the ground material created by the helper.
  110176. */
  110177. readonly groundMaterial: Nullable<BackgroundMaterial>;
  110178. /**
  110179. * Stores the creation options.
  110180. */
  110181. private readonly _scene;
  110182. private _options;
  110183. /**
  110184. * This observable will be notified with any error during the creation of the environment,
  110185. * mainly texture creation errors.
  110186. */
  110187. onErrorObservable: Observable<{
  110188. message?: string;
  110189. exception?: any;
  110190. }>;
  110191. /**
  110192. * constructor
  110193. * @param options Defines the options we want to customize the helper
  110194. * @param scene The scene to add the material to
  110195. */
  110196. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  110197. /**
  110198. * Updates the background according to the new options
  110199. * @param options
  110200. */
  110201. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  110202. /**
  110203. * Sets the primary color of all the available elements.
  110204. * @param color the main color to affect to the ground and the background
  110205. */
  110206. setMainColor(color: Color3): void;
  110207. /**
  110208. * Setup the image processing according to the specified options.
  110209. */
  110210. private _setupImageProcessing;
  110211. /**
  110212. * Setup the environment texture according to the specified options.
  110213. */
  110214. private _setupEnvironmentTexture;
  110215. /**
  110216. * Setup the background according to the specified options.
  110217. */
  110218. private _setupBackground;
  110219. /**
  110220. * Get the scene sizes according to the setup.
  110221. */
  110222. private _getSceneSize;
  110223. /**
  110224. * Setup the ground according to the specified options.
  110225. */
  110226. private _setupGround;
  110227. /**
  110228. * Setup the ground material according to the specified options.
  110229. */
  110230. private _setupGroundMaterial;
  110231. /**
  110232. * Setup the ground diffuse texture according to the specified options.
  110233. */
  110234. private _setupGroundDiffuseTexture;
  110235. /**
  110236. * Setup the ground mirror texture according to the specified options.
  110237. */
  110238. private _setupGroundMirrorTexture;
  110239. /**
  110240. * Setup the ground to receive the mirror texture.
  110241. */
  110242. private _setupMirrorInGroundMaterial;
  110243. /**
  110244. * Setup the skybox according to the specified options.
  110245. */
  110246. private _setupSkybox;
  110247. /**
  110248. * Setup the skybox material according to the specified options.
  110249. */
  110250. private _setupSkyboxMaterial;
  110251. /**
  110252. * Setup the skybox reflection texture according to the specified options.
  110253. */
  110254. private _setupSkyboxReflectionTexture;
  110255. private _errorHandler;
  110256. /**
  110257. * Dispose all the elements created by the Helper.
  110258. */
  110259. dispose(): void;
  110260. }
  110261. }
  110262. declare module BABYLON {
  110263. /**
  110264. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  110265. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  110266. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  110267. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110268. */
  110269. export class PhotoDome extends TransformNode {
  110270. /**
  110271. * Define the image as a Monoscopic panoramic 360 image.
  110272. */
  110273. static readonly MODE_MONOSCOPIC: number;
  110274. /**
  110275. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110276. */
  110277. static readonly MODE_TOPBOTTOM: number;
  110278. /**
  110279. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110280. */
  110281. static readonly MODE_SIDEBYSIDE: number;
  110282. private _useDirectMapping;
  110283. /**
  110284. * The texture being displayed on the sphere
  110285. */
  110286. protected _photoTexture: Texture;
  110287. /**
  110288. * Gets or sets the texture being displayed on the sphere
  110289. */
  110290. photoTexture: Texture;
  110291. /**
  110292. * Observable raised when an error occured while loading the 360 image
  110293. */
  110294. onLoadErrorObservable: Observable<string>;
  110295. /**
  110296. * The skybox material
  110297. */
  110298. protected _material: BackgroundMaterial;
  110299. /**
  110300. * The surface used for the skybox
  110301. */
  110302. protected _mesh: Mesh;
  110303. /**
  110304. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110305. * Also see the options.resolution property.
  110306. */
  110307. fovMultiplier: number;
  110308. private _imageMode;
  110309. /**
  110310. * Gets or set the current video mode for the video. It can be:
  110311. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  110312. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110313. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110314. */
  110315. imageMode: number;
  110316. /**
  110317. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  110318. * @param name Element's name, child elements will append suffixes for their own names.
  110319. * @param urlsOfPhoto defines the url of the photo to display
  110320. * @param options defines an object containing optional or exposed sub element properties
  110321. * @param onError defines a callback called when an error occured while loading the texture
  110322. */
  110323. constructor(name: string, urlOfPhoto: string, options: {
  110324. resolution?: number;
  110325. size?: number;
  110326. useDirectMapping?: boolean;
  110327. faceForward?: boolean;
  110328. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  110329. private _onBeforeCameraRenderObserver;
  110330. private _changeImageMode;
  110331. /**
  110332. * Releases resources associated with this node.
  110333. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110334. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110335. */
  110336. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110337. }
  110338. }
  110339. declare module BABYLON {
  110340. /** @hidden */
  110341. export var rgbdDecodePixelShader: {
  110342. name: string;
  110343. shader: string;
  110344. };
  110345. }
  110346. declare module BABYLON {
  110347. /**
  110348. * Class used to host texture specific utilities
  110349. */
  110350. export class BRDFTextureTools {
  110351. /**
  110352. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  110353. * @param texture the texture to expand.
  110354. */
  110355. private static _ExpandDefaultBRDFTexture;
  110356. /**
  110357. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  110358. * @param scene defines the hosting scene
  110359. * @returns the environment BRDF texture
  110360. */
  110361. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  110362. private static _environmentBRDFBase64Texture;
  110363. }
  110364. }
  110365. declare module BABYLON {
  110366. /**
  110367. * @hidden
  110368. */
  110369. export interface IMaterialClearCoatDefines {
  110370. CLEARCOAT: boolean;
  110371. CLEARCOAT_DEFAULTIOR: boolean;
  110372. CLEARCOAT_TEXTURE: boolean;
  110373. CLEARCOAT_TEXTUREDIRECTUV: number;
  110374. CLEARCOAT_BUMP: boolean;
  110375. CLEARCOAT_BUMPDIRECTUV: number;
  110376. CLEARCOAT_TINT: boolean;
  110377. CLEARCOAT_TINT_TEXTURE: boolean;
  110378. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110379. /** @hidden */
  110380. _areTexturesDirty: boolean;
  110381. }
  110382. /**
  110383. * Define the code related to the clear coat parameters of the pbr material.
  110384. */
  110385. export class PBRClearCoatConfiguration {
  110386. /**
  110387. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110388. * The default fits with a polyurethane material.
  110389. */
  110390. private static readonly _DefaultIndexOfRefraction;
  110391. private _isEnabled;
  110392. /**
  110393. * Defines if the clear coat is enabled in the material.
  110394. */
  110395. isEnabled: boolean;
  110396. /**
  110397. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  110398. */
  110399. intensity: number;
  110400. /**
  110401. * Defines the clear coat layer roughness.
  110402. */
  110403. roughness: number;
  110404. private _indexOfRefraction;
  110405. /**
  110406. * Defines the index of refraction of the clear coat.
  110407. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110408. * The default fits with a polyurethane material.
  110409. * Changing the default value is more performance intensive.
  110410. */
  110411. indexOfRefraction: number;
  110412. private _texture;
  110413. /**
  110414. * Stores the clear coat values in a texture.
  110415. */
  110416. texture: Nullable<BaseTexture>;
  110417. private _bumpTexture;
  110418. /**
  110419. * Define the clear coat specific bump texture.
  110420. */
  110421. bumpTexture: Nullable<BaseTexture>;
  110422. private _isTintEnabled;
  110423. /**
  110424. * Defines if the clear coat tint is enabled in the material.
  110425. */
  110426. isTintEnabled: boolean;
  110427. /**
  110428. * Defines the clear coat tint of the material.
  110429. * This is only use if tint is enabled
  110430. */
  110431. tintColor: Color3;
  110432. /**
  110433. * Defines the distance at which the tint color should be found in the
  110434. * clear coat media.
  110435. * This is only use if tint is enabled
  110436. */
  110437. tintColorAtDistance: number;
  110438. /**
  110439. * Defines the clear coat layer thickness.
  110440. * This is only use if tint is enabled
  110441. */
  110442. tintThickness: number;
  110443. private _tintTexture;
  110444. /**
  110445. * Stores the clear tint values in a texture.
  110446. * rgb is tint
  110447. * a is a thickness factor
  110448. */
  110449. tintTexture: Nullable<BaseTexture>;
  110450. /** @hidden */
  110451. private _internalMarkAllSubMeshesAsTexturesDirty;
  110452. /** @hidden */
  110453. _markAllSubMeshesAsTexturesDirty(): void;
  110454. /**
  110455. * Instantiate a new istance of clear coat configuration.
  110456. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110457. */
  110458. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110459. /**
  110460. * Gets wehter the submesh is ready to be used or not.
  110461. * @param defines the list of "defines" to update.
  110462. * @param scene defines the scene the material belongs to.
  110463. * @param engine defines the engine the material belongs to.
  110464. * @param disableBumpMap defines wether the material disables bump or not.
  110465. * @returns - boolean indicating that the submesh is ready or not.
  110466. */
  110467. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110468. /**
  110469. * Checks to see if a texture is used in the material.
  110470. * @param defines the list of "defines" to update.
  110471. * @param scene defines the scene to the material belongs to.
  110472. */
  110473. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110474. /**
  110475. * Binds the material data.
  110476. * @param uniformBuffer defines the Uniform buffer to fill in.
  110477. * @param scene defines the scene the material belongs to.
  110478. * @param engine defines the engine the material belongs to.
  110479. * @param disableBumpMap defines wether the material disables bump or not.
  110480. * @param isFrozen defines wether the material is frozen or not.
  110481. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110482. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110483. */
  110484. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110485. /**
  110486. * Checks to see if a texture is used in the material.
  110487. * @param texture - Base texture to use.
  110488. * @returns - Boolean specifying if a texture is used in the material.
  110489. */
  110490. hasTexture(texture: BaseTexture): boolean;
  110491. /**
  110492. * Returns an array of the actively used textures.
  110493. * @param activeTextures Array of BaseTextures
  110494. */
  110495. getActiveTextures(activeTextures: BaseTexture[]): void;
  110496. /**
  110497. * Returns the animatable textures.
  110498. * @param animatables Array of animatable textures.
  110499. */
  110500. getAnimatables(animatables: IAnimatable[]): void;
  110501. /**
  110502. * Disposes the resources of the material.
  110503. * @param forceDisposeTextures - Forces the disposal of all textures.
  110504. */
  110505. dispose(forceDisposeTextures?: boolean): void;
  110506. /**
  110507. * Get the current class name of the texture useful for serialization or dynamic coding.
  110508. * @returns "PBRClearCoatConfiguration"
  110509. */
  110510. getClassName(): string;
  110511. /**
  110512. * Add fallbacks to the effect fallbacks list.
  110513. * @param defines defines the Base texture to use.
  110514. * @param fallbacks defines the current fallback list.
  110515. * @param currentRank defines the current fallback rank.
  110516. * @returns the new fallback rank.
  110517. */
  110518. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110519. /**
  110520. * Add the required uniforms to the current list.
  110521. * @param uniforms defines the current uniform list.
  110522. */
  110523. static AddUniforms(uniforms: string[]): void;
  110524. /**
  110525. * Add the required samplers to the current list.
  110526. * @param samplers defines the current sampler list.
  110527. */
  110528. static AddSamplers(samplers: string[]): void;
  110529. /**
  110530. * Add the required uniforms to the current buffer.
  110531. * @param uniformBuffer defines the current uniform buffer.
  110532. */
  110533. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110534. /**
  110535. * Makes a duplicate of the current configuration into another one.
  110536. * @param clearCoatConfiguration define the config where to copy the info
  110537. */
  110538. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110539. /**
  110540. * Serializes this clear coat configuration.
  110541. * @returns - An object with the serialized config.
  110542. */
  110543. serialize(): any;
  110544. /**
  110545. * Parses a anisotropy Configuration from a serialized object.
  110546. * @param source - Serialized object.
  110547. * @param scene Defines the scene we are parsing for
  110548. * @param rootUrl Defines the rootUrl to load from
  110549. */
  110550. parse(source: any, scene: Scene, rootUrl: string): void;
  110551. }
  110552. }
  110553. declare module BABYLON {
  110554. /**
  110555. * @hidden
  110556. */
  110557. export interface IMaterialAnisotropicDefines {
  110558. ANISOTROPIC: boolean;
  110559. ANISOTROPIC_TEXTURE: boolean;
  110560. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110561. MAINUV1: boolean;
  110562. _areTexturesDirty: boolean;
  110563. _needUVs: boolean;
  110564. }
  110565. /**
  110566. * Define the code related to the anisotropic parameters of the pbr material.
  110567. */
  110568. export class PBRAnisotropicConfiguration {
  110569. private _isEnabled;
  110570. /**
  110571. * Defines if the anisotropy is enabled in the material.
  110572. */
  110573. isEnabled: boolean;
  110574. /**
  110575. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110576. */
  110577. intensity: number;
  110578. /**
  110579. * Defines if the effect is along the tangents, bitangents or in between.
  110580. * By default, the effect is "strectching" the highlights along the tangents.
  110581. */
  110582. direction: Vector2;
  110583. private _texture;
  110584. /**
  110585. * Stores the anisotropy values in a texture.
  110586. * rg is direction (like normal from -1 to 1)
  110587. * b is a intensity
  110588. */
  110589. texture: Nullable<BaseTexture>;
  110590. /** @hidden */
  110591. private _internalMarkAllSubMeshesAsTexturesDirty;
  110592. /** @hidden */
  110593. _markAllSubMeshesAsTexturesDirty(): void;
  110594. /**
  110595. * Instantiate a new istance of anisotropy configuration.
  110596. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110597. */
  110598. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110599. /**
  110600. * Specifies that the submesh is ready to be used.
  110601. * @param defines the list of "defines" to update.
  110602. * @param scene defines the scene the material belongs to.
  110603. * @returns - boolean indicating that the submesh is ready or not.
  110604. */
  110605. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110606. /**
  110607. * Checks to see if a texture is used in the material.
  110608. * @param defines the list of "defines" to update.
  110609. * @param mesh the mesh we are preparing the defines for.
  110610. * @param scene defines the scene the material belongs to.
  110611. */
  110612. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110613. /**
  110614. * Binds the material data.
  110615. * @param uniformBuffer defines the Uniform buffer to fill in.
  110616. * @param scene defines the scene the material belongs to.
  110617. * @param isFrozen defines wether the material is frozen or not.
  110618. */
  110619. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110620. /**
  110621. * Checks to see if a texture is used in the material.
  110622. * @param texture - Base texture to use.
  110623. * @returns - Boolean specifying if a texture is used in the material.
  110624. */
  110625. hasTexture(texture: BaseTexture): boolean;
  110626. /**
  110627. * Returns an array of the actively used textures.
  110628. * @param activeTextures Array of BaseTextures
  110629. */
  110630. getActiveTextures(activeTextures: BaseTexture[]): void;
  110631. /**
  110632. * Returns the animatable textures.
  110633. * @param animatables Array of animatable textures.
  110634. */
  110635. getAnimatables(animatables: IAnimatable[]): void;
  110636. /**
  110637. * Disposes the resources of the material.
  110638. * @param forceDisposeTextures - Forces the disposal of all textures.
  110639. */
  110640. dispose(forceDisposeTextures?: boolean): void;
  110641. /**
  110642. * Get the current class name of the texture useful for serialization or dynamic coding.
  110643. * @returns "PBRAnisotropicConfiguration"
  110644. */
  110645. getClassName(): string;
  110646. /**
  110647. * Add fallbacks to the effect fallbacks list.
  110648. * @param defines defines the Base texture to use.
  110649. * @param fallbacks defines the current fallback list.
  110650. * @param currentRank defines the current fallback rank.
  110651. * @returns the new fallback rank.
  110652. */
  110653. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110654. /**
  110655. * Add the required uniforms to the current list.
  110656. * @param uniforms defines the current uniform list.
  110657. */
  110658. static AddUniforms(uniforms: string[]): void;
  110659. /**
  110660. * Add the required uniforms to the current buffer.
  110661. * @param uniformBuffer defines the current uniform buffer.
  110662. */
  110663. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110664. /**
  110665. * Add the required samplers to the current list.
  110666. * @param samplers defines the current sampler list.
  110667. */
  110668. static AddSamplers(samplers: string[]): void;
  110669. /**
  110670. * Makes a duplicate of the current configuration into another one.
  110671. * @param anisotropicConfiguration define the config where to copy the info
  110672. */
  110673. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110674. /**
  110675. * Serializes this anisotropy configuration.
  110676. * @returns - An object with the serialized config.
  110677. */
  110678. serialize(): any;
  110679. /**
  110680. * Parses a anisotropy Configuration from a serialized object.
  110681. * @param source - Serialized object.
  110682. * @param scene Defines the scene we are parsing for
  110683. * @param rootUrl Defines the rootUrl to load from
  110684. */
  110685. parse(source: any, scene: Scene, rootUrl: string): void;
  110686. }
  110687. }
  110688. declare module BABYLON {
  110689. /**
  110690. * @hidden
  110691. */
  110692. export interface IMaterialBRDFDefines {
  110693. BRDF_V_HEIGHT_CORRELATED: boolean;
  110694. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110695. SPHERICAL_HARMONICS: boolean;
  110696. /** @hidden */
  110697. _areMiscDirty: boolean;
  110698. }
  110699. /**
  110700. * Define the code related to the BRDF parameters of the pbr material.
  110701. */
  110702. export class PBRBRDFConfiguration {
  110703. /**
  110704. * Default value used for the energy conservation.
  110705. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110706. */
  110707. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110708. /**
  110709. * Default value used for the Smith Visibility Height Correlated mode.
  110710. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110711. */
  110712. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110713. /**
  110714. * Default value used for the IBL diffuse part.
  110715. * This can help switching back to the polynomials mode globally which is a tiny bit
  110716. * less GPU intensive at the drawback of a lower quality.
  110717. */
  110718. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110719. private _useEnergyConservation;
  110720. /**
  110721. * Defines if the material uses energy conservation.
  110722. */
  110723. useEnergyConservation: boolean;
  110724. private _useSmithVisibilityHeightCorrelated;
  110725. /**
  110726. * LEGACY Mode set to false
  110727. * Defines if the material uses height smith correlated visibility term.
  110728. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110729. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110730. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110731. * Not relying on height correlated will also disable energy conservation.
  110732. */
  110733. useSmithVisibilityHeightCorrelated: boolean;
  110734. private _useSphericalHarmonics;
  110735. /**
  110736. * LEGACY Mode set to false
  110737. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110738. * diffuse part of the IBL.
  110739. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110740. * to the ground truth.
  110741. */
  110742. useSphericalHarmonics: boolean;
  110743. /** @hidden */
  110744. private _internalMarkAllSubMeshesAsMiscDirty;
  110745. /** @hidden */
  110746. _markAllSubMeshesAsMiscDirty(): void;
  110747. /**
  110748. * Instantiate a new istance of clear coat configuration.
  110749. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110750. */
  110751. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110752. /**
  110753. * Checks to see if a texture is used in the material.
  110754. * @param defines the list of "defines" to update.
  110755. */
  110756. prepareDefines(defines: IMaterialBRDFDefines): void;
  110757. /**
  110758. * Get the current class name of the texture useful for serialization or dynamic coding.
  110759. * @returns "PBRClearCoatConfiguration"
  110760. */
  110761. getClassName(): string;
  110762. /**
  110763. * Makes a duplicate of the current configuration into another one.
  110764. * @param brdfConfiguration define the config where to copy the info
  110765. */
  110766. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110767. /**
  110768. * Serializes this BRDF configuration.
  110769. * @returns - An object with the serialized config.
  110770. */
  110771. serialize(): any;
  110772. /**
  110773. * Parses a anisotropy Configuration from a serialized object.
  110774. * @param source - Serialized object.
  110775. * @param scene Defines the scene we are parsing for
  110776. * @param rootUrl Defines the rootUrl to load from
  110777. */
  110778. parse(source: any, scene: Scene, rootUrl: string): void;
  110779. }
  110780. }
  110781. declare module BABYLON {
  110782. /**
  110783. * @hidden
  110784. */
  110785. export interface IMaterialSheenDefines {
  110786. SHEEN: boolean;
  110787. SHEEN_TEXTURE: boolean;
  110788. SHEEN_TEXTUREDIRECTUV: number;
  110789. SHEEN_LINKWITHALBEDO: boolean;
  110790. /** @hidden */
  110791. _areTexturesDirty: boolean;
  110792. }
  110793. /**
  110794. * Define the code related to the Sheen parameters of the pbr material.
  110795. */
  110796. export class PBRSheenConfiguration {
  110797. private _isEnabled;
  110798. /**
  110799. * Defines if the material uses sheen.
  110800. */
  110801. isEnabled: boolean;
  110802. private _linkSheenWithAlbedo;
  110803. /**
  110804. * Defines if the sheen is linked to the sheen color.
  110805. */
  110806. linkSheenWithAlbedo: boolean;
  110807. /**
  110808. * Defines the sheen intensity.
  110809. */
  110810. intensity: number;
  110811. /**
  110812. * Defines the sheen color.
  110813. */
  110814. color: Color3;
  110815. private _texture;
  110816. /**
  110817. * Stores the sheen tint values in a texture.
  110818. * rgb is tint
  110819. * a is a intensity
  110820. */
  110821. texture: Nullable<BaseTexture>;
  110822. /** @hidden */
  110823. private _internalMarkAllSubMeshesAsTexturesDirty;
  110824. /** @hidden */
  110825. _markAllSubMeshesAsTexturesDirty(): void;
  110826. /**
  110827. * Instantiate a new istance of clear coat configuration.
  110828. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110829. */
  110830. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110831. /**
  110832. * Specifies that the submesh is ready to be used.
  110833. * @param defines the list of "defines" to update.
  110834. * @param scene defines the scene the material belongs to.
  110835. * @returns - boolean indicating that the submesh is ready or not.
  110836. */
  110837. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110838. /**
  110839. * Checks to see if a texture is used in the material.
  110840. * @param defines the list of "defines" to update.
  110841. * @param scene defines the scene the material belongs to.
  110842. */
  110843. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110844. /**
  110845. * Binds the material data.
  110846. * @param uniformBuffer defines the Uniform buffer to fill in.
  110847. * @param scene defines the scene the material belongs to.
  110848. * @param isFrozen defines wether the material is frozen or not.
  110849. */
  110850. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110851. /**
  110852. * Checks to see if a texture is used in the material.
  110853. * @param texture - Base texture to use.
  110854. * @returns - Boolean specifying if a texture is used in the material.
  110855. */
  110856. hasTexture(texture: BaseTexture): boolean;
  110857. /**
  110858. * Returns an array of the actively used textures.
  110859. * @param activeTextures Array of BaseTextures
  110860. */
  110861. getActiveTextures(activeTextures: BaseTexture[]): void;
  110862. /**
  110863. * Returns the animatable textures.
  110864. * @param animatables Array of animatable textures.
  110865. */
  110866. getAnimatables(animatables: IAnimatable[]): void;
  110867. /**
  110868. * Disposes the resources of the material.
  110869. * @param forceDisposeTextures - Forces the disposal of all textures.
  110870. */
  110871. dispose(forceDisposeTextures?: boolean): void;
  110872. /**
  110873. * Get the current class name of the texture useful for serialization or dynamic coding.
  110874. * @returns "PBRSheenConfiguration"
  110875. */
  110876. getClassName(): string;
  110877. /**
  110878. * Add fallbacks to the effect fallbacks list.
  110879. * @param defines defines the Base texture to use.
  110880. * @param fallbacks defines the current fallback list.
  110881. * @param currentRank defines the current fallback rank.
  110882. * @returns the new fallback rank.
  110883. */
  110884. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110885. /**
  110886. * Add the required uniforms to the current list.
  110887. * @param uniforms defines the current uniform list.
  110888. */
  110889. static AddUniforms(uniforms: string[]): void;
  110890. /**
  110891. * Add the required uniforms to the current buffer.
  110892. * @param uniformBuffer defines the current uniform buffer.
  110893. */
  110894. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110895. /**
  110896. * Add the required samplers to the current list.
  110897. * @param samplers defines the current sampler list.
  110898. */
  110899. static AddSamplers(samplers: string[]): void;
  110900. /**
  110901. * Makes a duplicate of the current configuration into another one.
  110902. * @param sheenConfiguration define the config where to copy the info
  110903. */
  110904. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110905. /**
  110906. * Serializes this BRDF configuration.
  110907. * @returns - An object with the serialized config.
  110908. */
  110909. serialize(): any;
  110910. /**
  110911. * Parses a anisotropy Configuration from a serialized object.
  110912. * @param source - Serialized object.
  110913. * @param scene Defines the scene we are parsing for
  110914. * @param rootUrl Defines the rootUrl to load from
  110915. */
  110916. parse(source: any, scene: Scene, rootUrl: string): void;
  110917. }
  110918. }
  110919. declare module BABYLON {
  110920. /**
  110921. * @hidden
  110922. */
  110923. export interface IMaterialSubSurfaceDefines {
  110924. SUBSURFACE: boolean;
  110925. SS_REFRACTION: boolean;
  110926. SS_TRANSLUCENCY: boolean;
  110927. SS_SCATERRING: boolean;
  110928. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110929. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110930. SS_REFRACTIONMAP_3D: boolean;
  110931. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110932. SS_LODINREFRACTIONALPHA: boolean;
  110933. SS_GAMMAREFRACTION: boolean;
  110934. SS_RGBDREFRACTION: boolean;
  110935. SS_LINEARSPECULARREFRACTION: boolean;
  110936. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110937. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110938. /** @hidden */
  110939. _areTexturesDirty: boolean;
  110940. }
  110941. /**
  110942. * Define the code related to the sub surface parameters of the pbr material.
  110943. */
  110944. export class PBRSubSurfaceConfiguration {
  110945. private _isRefractionEnabled;
  110946. /**
  110947. * Defines if the refraction is enabled in the material.
  110948. */
  110949. isRefractionEnabled: boolean;
  110950. private _isTranslucencyEnabled;
  110951. /**
  110952. * Defines if the translucency is enabled in the material.
  110953. */
  110954. isTranslucencyEnabled: boolean;
  110955. private _isScatteringEnabled;
  110956. /**
  110957. * Defines the refraction intensity of the material.
  110958. * The refraction when enabled replaces the Diffuse part of the material.
  110959. * The intensity helps transitionning between diffuse and refraction.
  110960. */
  110961. refractionIntensity: number;
  110962. /**
  110963. * Defines the translucency intensity of the material.
  110964. * When translucency has been enabled, this defines how much of the "translucency"
  110965. * is addded to the diffuse part of the material.
  110966. */
  110967. translucencyIntensity: number;
  110968. /**
  110969. * Defines the scattering intensity of the material.
  110970. * When scattering has been enabled, this defines how much of the "scattered light"
  110971. * is addded to the diffuse part of the material.
  110972. */
  110973. scatteringIntensity: number;
  110974. private _thicknessTexture;
  110975. /**
  110976. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110977. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110978. * 0 would mean minimumThickness
  110979. * 1 would mean maximumThickness
  110980. * The other channels might be use as a mask to vary the different effects intensity.
  110981. */
  110982. thicknessTexture: Nullable<BaseTexture>;
  110983. private _refractionTexture;
  110984. /**
  110985. * Defines the texture to use for refraction.
  110986. */
  110987. refractionTexture: Nullable<BaseTexture>;
  110988. private _indexOfRefraction;
  110989. /**
  110990. * Defines the index of refraction used in the material.
  110991. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110992. */
  110993. indexOfRefraction: number;
  110994. private _invertRefractionY;
  110995. /**
  110996. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110997. */
  110998. invertRefractionY: boolean;
  110999. private _linkRefractionWithTransparency;
  111000. /**
  111001. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111002. * Materials half opaque for instance using refraction could benefit from this control.
  111003. */
  111004. linkRefractionWithTransparency: boolean;
  111005. /**
  111006. * Defines the minimum thickness stored in the thickness map.
  111007. * If no thickness map is defined, this value will be used to simulate thickness.
  111008. */
  111009. minimumThickness: number;
  111010. /**
  111011. * Defines the maximum thickness stored in the thickness map.
  111012. */
  111013. maximumThickness: number;
  111014. /**
  111015. * Defines the volume tint of the material.
  111016. * This is used for both translucency and scattering.
  111017. */
  111018. tintColor: Color3;
  111019. /**
  111020. * Defines the distance at which the tint color should be found in the media.
  111021. * This is used for refraction only.
  111022. */
  111023. tintColorAtDistance: number;
  111024. /**
  111025. * Defines how far each channel transmit through the media.
  111026. * It is defined as a color to simplify it selection.
  111027. */
  111028. diffusionDistance: Color3;
  111029. private _useMaskFromThicknessTexture;
  111030. /**
  111031. * Stores the intensity of the different subsurface effects in the thickness texture.
  111032. * * the green channel is the translucency intensity.
  111033. * * the blue channel is the scattering intensity.
  111034. * * the alpha channel is the refraction intensity.
  111035. */
  111036. useMaskFromThicknessTexture: boolean;
  111037. /** @hidden */
  111038. private _internalMarkAllSubMeshesAsTexturesDirty;
  111039. /** @hidden */
  111040. _markAllSubMeshesAsTexturesDirty(): void;
  111041. /**
  111042. * Instantiate a new istance of sub surface configuration.
  111043. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111044. */
  111045. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111046. /**
  111047. * Gets wehter the submesh is ready to be used or not.
  111048. * @param defines the list of "defines" to update.
  111049. * @param scene defines the scene the material belongs to.
  111050. * @returns - boolean indicating that the submesh is ready or not.
  111051. */
  111052. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  111053. /**
  111054. * Checks to see if a texture is used in the material.
  111055. * @param defines the list of "defines" to update.
  111056. * @param scene defines the scene to the material belongs to.
  111057. */
  111058. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  111059. /**
  111060. * Binds the material data.
  111061. * @param uniformBuffer defines the Uniform buffer to fill in.
  111062. * @param scene defines the scene the material belongs to.
  111063. * @param engine defines the engine the material belongs to.
  111064. * @param isFrozen defines wether the material is frozen or not.
  111065. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  111066. */
  111067. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  111068. /**
  111069. * Unbinds the material from the mesh.
  111070. * @param activeEffect defines the effect that should be unbound from.
  111071. * @returns true if unbound, otherwise false
  111072. */
  111073. unbind(activeEffect: Effect): boolean;
  111074. /**
  111075. * Returns the texture used for refraction or null if none is used.
  111076. * @param scene defines the scene the material belongs to.
  111077. * @returns - Refraction texture if present. If no refraction texture and refraction
  111078. * is linked with transparency, returns environment texture. Otherwise, returns null.
  111079. */
  111080. private _getRefractionTexture;
  111081. /**
  111082. * Returns true if alpha blending should be disabled.
  111083. */
  111084. readonly disableAlphaBlending: boolean;
  111085. /**
  111086. * Fills the list of render target textures.
  111087. * @param renderTargets the list of render targets to update
  111088. */
  111089. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  111090. /**
  111091. * Checks to see if a texture is used in the material.
  111092. * @param texture - Base texture to use.
  111093. * @returns - Boolean specifying if a texture is used in the material.
  111094. */
  111095. hasTexture(texture: BaseTexture): boolean;
  111096. /**
  111097. * Gets a boolean indicating that current material needs to register RTT
  111098. * @returns true if this uses a render target otherwise false.
  111099. */
  111100. hasRenderTargetTextures(): boolean;
  111101. /**
  111102. * Returns an array of the actively used textures.
  111103. * @param activeTextures Array of BaseTextures
  111104. */
  111105. getActiveTextures(activeTextures: BaseTexture[]): void;
  111106. /**
  111107. * Returns the animatable textures.
  111108. * @param animatables Array of animatable textures.
  111109. */
  111110. getAnimatables(animatables: IAnimatable[]): void;
  111111. /**
  111112. * Disposes the resources of the material.
  111113. * @param forceDisposeTextures - Forces the disposal of all textures.
  111114. */
  111115. dispose(forceDisposeTextures?: boolean): void;
  111116. /**
  111117. * Get the current class name of the texture useful for serialization or dynamic coding.
  111118. * @returns "PBRSubSurfaceConfiguration"
  111119. */
  111120. getClassName(): string;
  111121. /**
  111122. * Add fallbacks to the effect fallbacks list.
  111123. * @param defines defines the Base texture to use.
  111124. * @param fallbacks defines the current fallback list.
  111125. * @param currentRank defines the current fallback rank.
  111126. * @returns the new fallback rank.
  111127. */
  111128. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111129. /**
  111130. * Add the required uniforms to the current list.
  111131. * @param uniforms defines the current uniform list.
  111132. */
  111133. static AddUniforms(uniforms: string[]): void;
  111134. /**
  111135. * Add the required samplers to the current list.
  111136. * @param samplers defines the current sampler list.
  111137. */
  111138. static AddSamplers(samplers: string[]): void;
  111139. /**
  111140. * Add the required uniforms to the current buffer.
  111141. * @param uniformBuffer defines the current uniform buffer.
  111142. */
  111143. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111144. /**
  111145. * Makes a duplicate of the current configuration into another one.
  111146. * @param configuration define the config where to copy the info
  111147. */
  111148. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  111149. /**
  111150. * Serializes this Sub Surface configuration.
  111151. * @returns - An object with the serialized config.
  111152. */
  111153. serialize(): any;
  111154. /**
  111155. * Parses a anisotropy Configuration from a serialized object.
  111156. * @param source - Serialized object.
  111157. * @param scene Defines the scene we are parsing for
  111158. * @param rootUrl Defines the rootUrl to load from
  111159. */
  111160. parse(source: any, scene: Scene, rootUrl: string): void;
  111161. }
  111162. }
  111163. declare module BABYLON {
  111164. /** @hidden */
  111165. export var pbrFragmentDeclaration: {
  111166. name: string;
  111167. shader: string;
  111168. };
  111169. }
  111170. declare module BABYLON {
  111171. /** @hidden */
  111172. export var pbrUboDeclaration: {
  111173. name: string;
  111174. shader: string;
  111175. };
  111176. }
  111177. declare module BABYLON {
  111178. /** @hidden */
  111179. export var pbrFragmentExtraDeclaration: {
  111180. name: string;
  111181. shader: string;
  111182. };
  111183. }
  111184. declare module BABYLON {
  111185. /** @hidden */
  111186. export var pbrFragmentSamplersDeclaration: {
  111187. name: string;
  111188. shader: string;
  111189. };
  111190. }
  111191. declare module BABYLON {
  111192. /** @hidden */
  111193. export var pbrHelperFunctions: {
  111194. name: string;
  111195. shader: string;
  111196. };
  111197. }
  111198. declare module BABYLON {
  111199. /** @hidden */
  111200. export var harmonicsFunctions: {
  111201. name: string;
  111202. shader: string;
  111203. };
  111204. }
  111205. declare module BABYLON {
  111206. /** @hidden */
  111207. export var pbrDirectLightingSetupFunctions: {
  111208. name: string;
  111209. shader: string;
  111210. };
  111211. }
  111212. declare module BABYLON {
  111213. /** @hidden */
  111214. export var pbrDirectLightingFalloffFunctions: {
  111215. name: string;
  111216. shader: string;
  111217. };
  111218. }
  111219. declare module BABYLON {
  111220. /** @hidden */
  111221. export var pbrBRDFFunctions: {
  111222. name: string;
  111223. shader: string;
  111224. };
  111225. }
  111226. declare module BABYLON {
  111227. /** @hidden */
  111228. export var pbrDirectLightingFunctions: {
  111229. name: string;
  111230. shader: string;
  111231. };
  111232. }
  111233. declare module BABYLON {
  111234. /** @hidden */
  111235. export var pbrIBLFunctions: {
  111236. name: string;
  111237. shader: string;
  111238. };
  111239. }
  111240. declare module BABYLON {
  111241. /** @hidden */
  111242. export var pbrDebug: {
  111243. name: string;
  111244. shader: string;
  111245. };
  111246. }
  111247. declare module BABYLON {
  111248. /** @hidden */
  111249. export var pbrPixelShader: {
  111250. name: string;
  111251. shader: string;
  111252. };
  111253. }
  111254. declare module BABYLON {
  111255. /** @hidden */
  111256. export var pbrVertexDeclaration: {
  111257. name: string;
  111258. shader: string;
  111259. };
  111260. }
  111261. declare module BABYLON {
  111262. /** @hidden */
  111263. export var pbrVertexShader: {
  111264. name: string;
  111265. shader: string;
  111266. };
  111267. }
  111268. declare module BABYLON {
  111269. /**
  111270. * Manages the defines for the PBR Material.
  111271. * @hidden
  111272. */
  111273. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  111274. PBR: boolean;
  111275. MAINUV1: boolean;
  111276. MAINUV2: boolean;
  111277. UV1: boolean;
  111278. UV2: boolean;
  111279. ALBEDO: boolean;
  111280. ALBEDODIRECTUV: number;
  111281. VERTEXCOLOR: boolean;
  111282. AMBIENT: boolean;
  111283. AMBIENTDIRECTUV: number;
  111284. AMBIENTINGRAYSCALE: boolean;
  111285. OPACITY: boolean;
  111286. VERTEXALPHA: boolean;
  111287. OPACITYDIRECTUV: number;
  111288. OPACITYRGB: boolean;
  111289. ALPHATEST: boolean;
  111290. DEPTHPREPASS: boolean;
  111291. ALPHABLEND: boolean;
  111292. ALPHAFROMALBEDO: boolean;
  111293. ALPHATESTVALUE: string;
  111294. SPECULAROVERALPHA: boolean;
  111295. RADIANCEOVERALPHA: boolean;
  111296. ALPHAFRESNEL: boolean;
  111297. LINEARALPHAFRESNEL: boolean;
  111298. PREMULTIPLYALPHA: boolean;
  111299. EMISSIVE: boolean;
  111300. EMISSIVEDIRECTUV: number;
  111301. REFLECTIVITY: boolean;
  111302. REFLECTIVITYDIRECTUV: number;
  111303. SPECULARTERM: boolean;
  111304. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  111305. MICROSURFACEAUTOMATIC: boolean;
  111306. LODBASEDMICROSFURACE: boolean;
  111307. MICROSURFACEMAP: boolean;
  111308. MICROSURFACEMAPDIRECTUV: number;
  111309. METALLICWORKFLOW: boolean;
  111310. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  111311. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  111312. METALLNESSSTOREINMETALMAPBLUE: boolean;
  111313. AOSTOREINMETALMAPRED: boolean;
  111314. ENVIRONMENTBRDF: boolean;
  111315. ENVIRONMENTBRDF_RGBD: boolean;
  111316. NORMAL: boolean;
  111317. TANGENT: boolean;
  111318. BUMP: boolean;
  111319. BUMPDIRECTUV: number;
  111320. OBJECTSPACE_NORMALMAP: boolean;
  111321. PARALLAX: boolean;
  111322. PARALLAXOCCLUSION: boolean;
  111323. NORMALXYSCALE: boolean;
  111324. LIGHTMAP: boolean;
  111325. LIGHTMAPDIRECTUV: number;
  111326. USELIGHTMAPASSHADOWMAP: boolean;
  111327. GAMMALIGHTMAP: boolean;
  111328. REFLECTION: boolean;
  111329. REFLECTIONMAP_3D: boolean;
  111330. REFLECTIONMAP_SPHERICAL: boolean;
  111331. REFLECTIONMAP_PLANAR: boolean;
  111332. REFLECTIONMAP_CUBIC: boolean;
  111333. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111334. REFLECTIONMAP_PROJECTION: boolean;
  111335. REFLECTIONMAP_SKYBOX: boolean;
  111336. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  111337. REFLECTIONMAP_EXPLICIT: boolean;
  111338. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111339. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111340. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111341. INVERTCUBICMAP: boolean;
  111342. USESPHERICALFROMREFLECTIONMAP: boolean;
  111343. USEIRRADIANCEMAP: boolean;
  111344. SPHERICAL_HARMONICS: boolean;
  111345. USESPHERICALINVERTEX: boolean;
  111346. REFLECTIONMAP_OPPOSITEZ: boolean;
  111347. LODINREFLECTIONALPHA: boolean;
  111348. GAMMAREFLECTION: boolean;
  111349. RGBDREFLECTION: boolean;
  111350. LINEARSPECULARREFLECTION: boolean;
  111351. RADIANCEOCCLUSION: boolean;
  111352. HORIZONOCCLUSION: boolean;
  111353. INSTANCES: boolean;
  111354. NUM_BONE_INFLUENCERS: number;
  111355. BonesPerMesh: number;
  111356. BONETEXTURE: boolean;
  111357. NONUNIFORMSCALING: boolean;
  111358. MORPHTARGETS: boolean;
  111359. MORPHTARGETS_NORMAL: boolean;
  111360. MORPHTARGETS_TANGENT: boolean;
  111361. MORPHTARGETS_UV: boolean;
  111362. NUM_MORPH_INFLUENCERS: number;
  111363. IMAGEPROCESSING: boolean;
  111364. VIGNETTE: boolean;
  111365. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111366. VIGNETTEBLENDMODEOPAQUE: boolean;
  111367. TONEMAPPING: boolean;
  111368. TONEMAPPING_ACES: boolean;
  111369. CONTRAST: boolean;
  111370. COLORCURVES: boolean;
  111371. COLORGRADING: boolean;
  111372. COLORGRADING3D: boolean;
  111373. SAMPLER3DGREENDEPTH: boolean;
  111374. SAMPLER3DBGRMAP: boolean;
  111375. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111376. EXPOSURE: boolean;
  111377. MULTIVIEW: boolean;
  111378. USEPHYSICALLIGHTFALLOFF: boolean;
  111379. USEGLTFLIGHTFALLOFF: boolean;
  111380. TWOSIDEDLIGHTING: boolean;
  111381. SHADOWFLOAT: boolean;
  111382. CLIPPLANE: boolean;
  111383. CLIPPLANE2: boolean;
  111384. CLIPPLANE3: boolean;
  111385. CLIPPLANE4: boolean;
  111386. POINTSIZE: boolean;
  111387. FOG: boolean;
  111388. LOGARITHMICDEPTH: boolean;
  111389. FORCENORMALFORWARD: boolean;
  111390. SPECULARAA: boolean;
  111391. CLEARCOAT: boolean;
  111392. CLEARCOAT_DEFAULTIOR: boolean;
  111393. CLEARCOAT_TEXTURE: boolean;
  111394. CLEARCOAT_TEXTUREDIRECTUV: number;
  111395. CLEARCOAT_BUMP: boolean;
  111396. CLEARCOAT_BUMPDIRECTUV: number;
  111397. CLEARCOAT_TINT: boolean;
  111398. CLEARCOAT_TINT_TEXTURE: boolean;
  111399. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111400. ANISOTROPIC: boolean;
  111401. ANISOTROPIC_TEXTURE: boolean;
  111402. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111403. BRDF_V_HEIGHT_CORRELATED: boolean;
  111404. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111405. SHEEN: boolean;
  111406. SHEEN_TEXTURE: boolean;
  111407. SHEEN_TEXTUREDIRECTUV: number;
  111408. SHEEN_LINKWITHALBEDO: boolean;
  111409. SUBSURFACE: boolean;
  111410. SS_REFRACTION: boolean;
  111411. SS_TRANSLUCENCY: boolean;
  111412. SS_SCATERRING: boolean;
  111413. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111414. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111415. SS_REFRACTIONMAP_3D: boolean;
  111416. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111417. SS_LODINREFRACTIONALPHA: boolean;
  111418. SS_GAMMAREFRACTION: boolean;
  111419. SS_RGBDREFRACTION: boolean;
  111420. SS_LINEARSPECULARREFRACTION: boolean;
  111421. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111422. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111423. UNLIT: boolean;
  111424. DEBUGMODE: number;
  111425. /**
  111426. * Initializes the PBR Material defines.
  111427. */
  111428. constructor();
  111429. /**
  111430. * Resets the PBR Material defines.
  111431. */
  111432. reset(): void;
  111433. }
  111434. /**
  111435. * The Physically based material base class of BJS.
  111436. *
  111437. * This offers the main features of a standard PBR material.
  111438. * For more information, please refer to the documentation :
  111439. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111440. */
  111441. export abstract class PBRBaseMaterial extends PushMaterial {
  111442. /**
  111443. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111444. */
  111445. static readonly PBRMATERIAL_OPAQUE: number;
  111446. /**
  111447. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111448. */
  111449. static readonly PBRMATERIAL_ALPHATEST: number;
  111450. /**
  111451. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111452. */
  111453. static readonly PBRMATERIAL_ALPHABLEND: number;
  111454. /**
  111455. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111456. * They are also discarded below the alpha cutoff threshold to improve performances.
  111457. */
  111458. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111459. /**
  111460. * Defines the default value of how much AO map is occluding the analytical lights
  111461. * (point spot...).
  111462. */
  111463. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111464. /**
  111465. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111466. */
  111467. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111468. /**
  111469. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111470. * to enhance interoperability with other engines.
  111471. */
  111472. static readonly LIGHTFALLOFF_GLTF: number;
  111473. /**
  111474. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111475. * to enhance interoperability with other materials.
  111476. */
  111477. static readonly LIGHTFALLOFF_STANDARD: number;
  111478. /**
  111479. * Intensity of the direct lights e.g. the four lights available in your scene.
  111480. * This impacts both the direct diffuse and specular highlights.
  111481. */
  111482. protected _directIntensity: number;
  111483. /**
  111484. * Intensity of the emissive part of the material.
  111485. * This helps controlling the emissive effect without modifying the emissive color.
  111486. */
  111487. protected _emissiveIntensity: number;
  111488. /**
  111489. * Intensity of the environment e.g. how much the environment will light the object
  111490. * either through harmonics for rough material or through the refelction for shiny ones.
  111491. */
  111492. protected _environmentIntensity: number;
  111493. /**
  111494. * This is a special control allowing the reduction of the specular highlights coming from the
  111495. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111496. */
  111497. protected _specularIntensity: number;
  111498. /**
  111499. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111500. */
  111501. private _lightingInfos;
  111502. /**
  111503. * Debug Control allowing disabling the bump map on this material.
  111504. */
  111505. protected _disableBumpMap: boolean;
  111506. /**
  111507. * AKA Diffuse Texture in standard nomenclature.
  111508. */
  111509. protected _albedoTexture: Nullable<BaseTexture>;
  111510. /**
  111511. * AKA Occlusion Texture in other nomenclature.
  111512. */
  111513. protected _ambientTexture: Nullable<BaseTexture>;
  111514. /**
  111515. * AKA Occlusion Texture Intensity in other nomenclature.
  111516. */
  111517. protected _ambientTextureStrength: number;
  111518. /**
  111519. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111520. * 1 means it completely occludes it
  111521. * 0 mean it has no impact
  111522. */
  111523. protected _ambientTextureImpactOnAnalyticalLights: number;
  111524. /**
  111525. * Stores the alpha values in a texture.
  111526. */
  111527. protected _opacityTexture: Nullable<BaseTexture>;
  111528. /**
  111529. * Stores the reflection values in a texture.
  111530. */
  111531. protected _reflectionTexture: Nullable<BaseTexture>;
  111532. /**
  111533. * Stores the emissive values in a texture.
  111534. */
  111535. protected _emissiveTexture: Nullable<BaseTexture>;
  111536. /**
  111537. * AKA Specular texture in other nomenclature.
  111538. */
  111539. protected _reflectivityTexture: Nullable<BaseTexture>;
  111540. /**
  111541. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111542. */
  111543. protected _metallicTexture: Nullable<BaseTexture>;
  111544. /**
  111545. * Specifies the metallic scalar of the metallic/roughness workflow.
  111546. * Can also be used to scale the metalness values of the metallic texture.
  111547. */
  111548. protected _metallic: Nullable<number>;
  111549. /**
  111550. * Specifies the roughness scalar of the metallic/roughness workflow.
  111551. * Can also be used to scale the roughness values of the metallic texture.
  111552. */
  111553. protected _roughness: Nullable<number>;
  111554. /**
  111555. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111556. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111557. */
  111558. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111559. /**
  111560. * Stores surface normal data used to displace a mesh in a texture.
  111561. */
  111562. protected _bumpTexture: Nullable<BaseTexture>;
  111563. /**
  111564. * Stores the pre-calculated light information of a mesh in a texture.
  111565. */
  111566. protected _lightmapTexture: Nullable<BaseTexture>;
  111567. /**
  111568. * The color of a material in ambient lighting.
  111569. */
  111570. protected _ambientColor: Color3;
  111571. /**
  111572. * AKA Diffuse Color in other nomenclature.
  111573. */
  111574. protected _albedoColor: Color3;
  111575. /**
  111576. * AKA Specular Color in other nomenclature.
  111577. */
  111578. protected _reflectivityColor: Color3;
  111579. /**
  111580. * The color applied when light is reflected from a material.
  111581. */
  111582. protected _reflectionColor: Color3;
  111583. /**
  111584. * The color applied when light is emitted from a material.
  111585. */
  111586. protected _emissiveColor: Color3;
  111587. /**
  111588. * AKA Glossiness in other nomenclature.
  111589. */
  111590. protected _microSurface: number;
  111591. /**
  111592. * Specifies that the material will use the light map as a show map.
  111593. */
  111594. protected _useLightmapAsShadowmap: boolean;
  111595. /**
  111596. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111597. * makes the reflect vector face the model (under horizon).
  111598. */
  111599. protected _useHorizonOcclusion: boolean;
  111600. /**
  111601. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111602. * too much the area relying on ambient texture to define their ambient occlusion.
  111603. */
  111604. protected _useRadianceOcclusion: boolean;
  111605. /**
  111606. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111607. */
  111608. protected _useAlphaFromAlbedoTexture: boolean;
  111609. /**
  111610. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111611. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111612. */
  111613. protected _useSpecularOverAlpha: boolean;
  111614. /**
  111615. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111616. */
  111617. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111618. /**
  111619. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111620. */
  111621. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111622. /**
  111623. * Specifies if the metallic texture contains the roughness information in its green channel.
  111624. */
  111625. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111626. /**
  111627. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111628. */
  111629. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111630. /**
  111631. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111632. */
  111633. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111634. /**
  111635. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111636. */
  111637. protected _useAmbientInGrayScale: boolean;
  111638. /**
  111639. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111640. * The material will try to infer what glossiness each pixel should be.
  111641. */
  111642. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111643. /**
  111644. * Defines the falloff type used in this material.
  111645. * It by default is Physical.
  111646. */
  111647. protected _lightFalloff: number;
  111648. /**
  111649. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111650. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111651. */
  111652. protected _useRadianceOverAlpha: boolean;
  111653. /**
  111654. * Allows using an object space normal map (instead of tangent space).
  111655. */
  111656. protected _useObjectSpaceNormalMap: boolean;
  111657. /**
  111658. * Allows using the bump map in parallax mode.
  111659. */
  111660. protected _useParallax: boolean;
  111661. /**
  111662. * Allows using the bump map in parallax occlusion mode.
  111663. */
  111664. protected _useParallaxOcclusion: boolean;
  111665. /**
  111666. * Controls the scale bias of the parallax mode.
  111667. */
  111668. protected _parallaxScaleBias: number;
  111669. /**
  111670. * If sets to true, disables all the lights affecting the material.
  111671. */
  111672. protected _disableLighting: boolean;
  111673. /**
  111674. * Number of Simultaneous lights allowed on the material.
  111675. */
  111676. protected _maxSimultaneousLights: number;
  111677. /**
  111678. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111679. */
  111680. protected _invertNormalMapX: boolean;
  111681. /**
  111682. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111683. */
  111684. protected _invertNormalMapY: boolean;
  111685. /**
  111686. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111687. */
  111688. protected _twoSidedLighting: boolean;
  111689. /**
  111690. * Defines the alpha limits in alpha test mode.
  111691. */
  111692. protected _alphaCutOff: number;
  111693. /**
  111694. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111695. */
  111696. protected _forceAlphaTest: boolean;
  111697. /**
  111698. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111699. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111700. */
  111701. protected _useAlphaFresnel: boolean;
  111702. /**
  111703. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111704. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111705. */
  111706. protected _useLinearAlphaFresnel: boolean;
  111707. /**
  111708. * The transparency mode of the material.
  111709. */
  111710. protected _transparencyMode: Nullable<number>;
  111711. /**
  111712. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111713. * from cos thetav and roughness:
  111714. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111715. */
  111716. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111717. /**
  111718. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111719. */
  111720. protected _forceIrradianceInFragment: boolean;
  111721. /**
  111722. * Force normal to face away from face.
  111723. */
  111724. protected _forceNormalForward: boolean;
  111725. /**
  111726. * Enables specular anti aliasing in the PBR shader.
  111727. * It will both interacts on the Geometry for analytical and IBL lighting.
  111728. * It also prefilter the roughness map based on the bump values.
  111729. */
  111730. protected _enableSpecularAntiAliasing: boolean;
  111731. /**
  111732. * Default configuration related to image processing available in the PBR Material.
  111733. */
  111734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111735. /**
  111736. * Keep track of the image processing observer to allow dispose and replace.
  111737. */
  111738. private _imageProcessingObserver;
  111739. /**
  111740. * Attaches a new image processing configuration to the PBR Material.
  111741. * @param configuration
  111742. */
  111743. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111744. /**
  111745. * Stores the available render targets.
  111746. */
  111747. private _renderTargets;
  111748. /**
  111749. * Sets the global ambient color for the material used in lighting calculations.
  111750. */
  111751. private _globalAmbientColor;
  111752. /**
  111753. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111754. */
  111755. private _useLogarithmicDepth;
  111756. /**
  111757. * If set to true, no lighting calculations will be applied.
  111758. */
  111759. private _unlit;
  111760. private _debugMode;
  111761. /**
  111762. * @hidden
  111763. * This is reserved for the inspector.
  111764. * Defines the material debug mode.
  111765. * It helps seeing only some components of the material while troubleshooting.
  111766. */
  111767. debugMode: number;
  111768. /**
  111769. * @hidden
  111770. * This is reserved for the inspector.
  111771. * Specify from where on screen the debug mode should start.
  111772. * The value goes from -1 (full screen) to 1 (not visible)
  111773. * It helps with side by side comparison against the final render
  111774. * This defaults to -1
  111775. */
  111776. private debugLimit;
  111777. /**
  111778. * @hidden
  111779. * This is reserved for the inspector.
  111780. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111781. * You can use the factor to better multiply the final value.
  111782. */
  111783. private debugFactor;
  111784. /**
  111785. * Defines the clear coat layer parameters for the material.
  111786. */
  111787. readonly clearCoat: PBRClearCoatConfiguration;
  111788. /**
  111789. * Defines the anisotropic parameters for the material.
  111790. */
  111791. readonly anisotropy: PBRAnisotropicConfiguration;
  111792. /**
  111793. * Defines the BRDF parameters for the material.
  111794. */
  111795. readonly brdf: PBRBRDFConfiguration;
  111796. /**
  111797. * Defines the Sheen parameters for the material.
  111798. */
  111799. readonly sheen: PBRSheenConfiguration;
  111800. /**
  111801. * Defines the SubSurface parameters for the material.
  111802. */
  111803. readonly subSurface: PBRSubSurfaceConfiguration;
  111804. /**
  111805. * Custom callback helping to override the default shader used in the material.
  111806. */
  111807. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111808. /**
  111809. * Instantiates a new PBRMaterial instance.
  111810. *
  111811. * @param name The material name
  111812. * @param scene The scene the material will be use in.
  111813. */
  111814. constructor(name: string, scene: Scene);
  111815. /**
  111816. * Gets a boolean indicating that current material needs to register RTT
  111817. */
  111818. readonly hasRenderTargetTextures: boolean;
  111819. /**
  111820. * Gets the name of the material class.
  111821. */
  111822. getClassName(): string;
  111823. /**
  111824. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111825. */
  111826. /**
  111827. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111828. */
  111829. useLogarithmicDepth: boolean;
  111830. /**
  111831. * Gets the current transparency mode.
  111832. */
  111833. /**
  111834. * Sets the transparency mode of the material.
  111835. *
  111836. * | Value | Type | Description |
  111837. * | ----- | ----------------------------------- | ----------- |
  111838. * | 0 | OPAQUE | |
  111839. * | 1 | ALPHATEST | |
  111840. * | 2 | ALPHABLEND | |
  111841. * | 3 | ALPHATESTANDBLEND | |
  111842. *
  111843. */
  111844. transparencyMode: Nullable<number>;
  111845. /**
  111846. * Returns true if alpha blending should be disabled.
  111847. */
  111848. private readonly _disableAlphaBlending;
  111849. /**
  111850. * Specifies whether or not this material should be rendered in alpha blend mode.
  111851. */
  111852. needAlphaBlending(): boolean;
  111853. /**
  111854. * Specifies if the mesh will require alpha blending.
  111855. * @param mesh - BJS mesh.
  111856. */
  111857. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111858. /**
  111859. * Specifies whether or not this material should be rendered in alpha test mode.
  111860. */
  111861. needAlphaTesting(): boolean;
  111862. /**
  111863. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111864. */
  111865. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111866. /**
  111867. * Gets the texture used for the alpha test.
  111868. */
  111869. getAlphaTestTexture(): Nullable<BaseTexture>;
  111870. /**
  111871. * Specifies that the submesh is ready to be used.
  111872. * @param mesh - BJS mesh.
  111873. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111874. * @param useInstances - Specifies that instances should be used.
  111875. * @returns - boolean indicating that the submesh is ready or not.
  111876. */
  111877. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111878. /**
  111879. * Specifies if the material uses metallic roughness workflow.
  111880. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111881. */
  111882. isMetallicWorkflow(): boolean;
  111883. private _prepareEffect;
  111884. private _prepareDefines;
  111885. /**
  111886. * Force shader compilation
  111887. */
  111888. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111889. clipPlane: boolean;
  111890. }>): void;
  111891. /**
  111892. * Initializes the uniform buffer layout for the shader.
  111893. */
  111894. buildUniformLayout(): void;
  111895. /**
  111896. * Unbinds the material from the mesh
  111897. */
  111898. unbind(): void;
  111899. /**
  111900. * Binds the submesh data.
  111901. * @param world - The world matrix.
  111902. * @param mesh - The BJS mesh.
  111903. * @param subMesh - A submesh of the BJS mesh.
  111904. */
  111905. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111906. /**
  111907. * Returns the animatable textures.
  111908. * @returns - Array of animatable textures.
  111909. */
  111910. getAnimatables(): IAnimatable[];
  111911. /**
  111912. * Returns the texture used for reflections.
  111913. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111914. */
  111915. private _getReflectionTexture;
  111916. /**
  111917. * Returns an array of the actively used textures.
  111918. * @returns - Array of BaseTextures
  111919. */
  111920. getActiveTextures(): BaseTexture[];
  111921. /**
  111922. * Checks to see if a texture is used in the material.
  111923. * @param texture - Base texture to use.
  111924. * @returns - Boolean specifying if a texture is used in the material.
  111925. */
  111926. hasTexture(texture: BaseTexture): boolean;
  111927. /**
  111928. * Disposes the resources of the material.
  111929. * @param forceDisposeEffect - Forces the disposal of effects.
  111930. * @param forceDisposeTextures - Forces the disposal of all textures.
  111931. */
  111932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111933. }
  111934. }
  111935. declare module BABYLON {
  111936. /**
  111937. * The Physically based material of BJS.
  111938. *
  111939. * This offers the main features of a standard PBR material.
  111940. * For more information, please refer to the documentation :
  111941. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111942. */
  111943. export class PBRMaterial extends PBRBaseMaterial {
  111944. /**
  111945. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111946. */
  111947. static readonly PBRMATERIAL_OPAQUE: number;
  111948. /**
  111949. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111950. */
  111951. static readonly PBRMATERIAL_ALPHATEST: number;
  111952. /**
  111953. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111954. */
  111955. static readonly PBRMATERIAL_ALPHABLEND: number;
  111956. /**
  111957. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111958. * They are also discarded below the alpha cutoff threshold to improve performances.
  111959. */
  111960. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111961. /**
  111962. * Defines the default value of how much AO map is occluding the analytical lights
  111963. * (point spot...).
  111964. */
  111965. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111966. /**
  111967. * Intensity of the direct lights e.g. the four lights available in your scene.
  111968. * This impacts both the direct diffuse and specular highlights.
  111969. */
  111970. directIntensity: number;
  111971. /**
  111972. * Intensity of the emissive part of the material.
  111973. * This helps controlling the emissive effect without modifying the emissive color.
  111974. */
  111975. emissiveIntensity: number;
  111976. /**
  111977. * Intensity of the environment e.g. how much the environment will light the object
  111978. * either through harmonics for rough material or through the refelction for shiny ones.
  111979. */
  111980. environmentIntensity: number;
  111981. /**
  111982. * This is a special control allowing the reduction of the specular highlights coming from the
  111983. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111984. */
  111985. specularIntensity: number;
  111986. /**
  111987. * Debug Control allowing disabling the bump map on this material.
  111988. */
  111989. disableBumpMap: boolean;
  111990. /**
  111991. * AKA Diffuse Texture in standard nomenclature.
  111992. */
  111993. albedoTexture: BaseTexture;
  111994. /**
  111995. * AKA Occlusion Texture in other nomenclature.
  111996. */
  111997. ambientTexture: BaseTexture;
  111998. /**
  111999. * AKA Occlusion Texture Intensity in other nomenclature.
  112000. */
  112001. ambientTextureStrength: number;
  112002. /**
  112003. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112004. * 1 means it completely occludes it
  112005. * 0 mean it has no impact
  112006. */
  112007. ambientTextureImpactOnAnalyticalLights: number;
  112008. /**
  112009. * Stores the alpha values in a texture.
  112010. */
  112011. opacityTexture: BaseTexture;
  112012. /**
  112013. * Stores the reflection values in a texture.
  112014. */
  112015. reflectionTexture: Nullable<BaseTexture>;
  112016. /**
  112017. * Stores the emissive values in a texture.
  112018. */
  112019. emissiveTexture: BaseTexture;
  112020. /**
  112021. * AKA Specular texture in other nomenclature.
  112022. */
  112023. reflectivityTexture: BaseTexture;
  112024. /**
  112025. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112026. */
  112027. metallicTexture: BaseTexture;
  112028. /**
  112029. * Specifies the metallic scalar of the metallic/roughness workflow.
  112030. * Can also be used to scale the metalness values of the metallic texture.
  112031. */
  112032. metallic: Nullable<number>;
  112033. /**
  112034. * Specifies the roughness scalar of the metallic/roughness workflow.
  112035. * Can also be used to scale the roughness values of the metallic texture.
  112036. */
  112037. roughness: Nullable<number>;
  112038. /**
  112039. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112040. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112041. */
  112042. microSurfaceTexture: BaseTexture;
  112043. /**
  112044. * Stores surface normal data used to displace a mesh in a texture.
  112045. */
  112046. bumpTexture: BaseTexture;
  112047. /**
  112048. * Stores the pre-calculated light information of a mesh in a texture.
  112049. */
  112050. lightmapTexture: BaseTexture;
  112051. /**
  112052. * Stores the refracted light information in a texture.
  112053. */
  112054. refractionTexture: Nullable<BaseTexture>;
  112055. /**
  112056. * The color of a material in ambient lighting.
  112057. */
  112058. ambientColor: Color3;
  112059. /**
  112060. * AKA Diffuse Color in other nomenclature.
  112061. */
  112062. albedoColor: Color3;
  112063. /**
  112064. * AKA Specular Color in other nomenclature.
  112065. */
  112066. reflectivityColor: Color3;
  112067. /**
  112068. * The color reflected from the material.
  112069. */
  112070. reflectionColor: Color3;
  112071. /**
  112072. * The color emitted from the material.
  112073. */
  112074. emissiveColor: Color3;
  112075. /**
  112076. * AKA Glossiness in other nomenclature.
  112077. */
  112078. microSurface: number;
  112079. /**
  112080. * source material index of refraction (IOR)' / 'destination material IOR.
  112081. */
  112082. indexOfRefraction: number;
  112083. /**
  112084. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112085. */
  112086. invertRefractionY: boolean;
  112087. /**
  112088. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112089. * Materials half opaque for instance using refraction could benefit from this control.
  112090. */
  112091. linkRefractionWithTransparency: boolean;
  112092. /**
  112093. * If true, the light map contains occlusion information instead of lighting info.
  112094. */
  112095. useLightmapAsShadowmap: boolean;
  112096. /**
  112097. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112098. */
  112099. useAlphaFromAlbedoTexture: boolean;
  112100. /**
  112101. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112102. */
  112103. forceAlphaTest: boolean;
  112104. /**
  112105. * Defines the alpha limits in alpha test mode.
  112106. */
  112107. alphaCutOff: number;
  112108. /**
  112109. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  112110. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112111. */
  112112. useSpecularOverAlpha: boolean;
  112113. /**
  112114. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112115. */
  112116. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112117. /**
  112118. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112119. */
  112120. useRoughnessFromMetallicTextureAlpha: boolean;
  112121. /**
  112122. * Specifies if the metallic texture contains the roughness information in its green channel.
  112123. */
  112124. useRoughnessFromMetallicTextureGreen: boolean;
  112125. /**
  112126. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112127. */
  112128. useMetallnessFromMetallicTextureBlue: boolean;
  112129. /**
  112130. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112131. */
  112132. useAmbientOcclusionFromMetallicTextureRed: boolean;
  112133. /**
  112134. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112135. */
  112136. useAmbientInGrayScale: boolean;
  112137. /**
  112138. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112139. * The material will try to infer what glossiness each pixel should be.
  112140. */
  112141. useAutoMicroSurfaceFromReflectivityMap: boolean;
  112142. /**
  112143. * BJS is using an harcoded light falloff based on a manually sets up range.
  112144. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112145. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112146. */
  112147. /**
  112148. * BJS is using an harcoded light falloff based on a manually sets up range.
  112149. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112150. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112151. */
  112152. usePhysicalLightFalloff: boolean;
  112153. /**
  112154. * In order to support the falloff compatibility with gltf, a special mode has been added
  112155. * to reproduce the gltf light falloff.
  112156. */
  112157. /**
  112158. * In order to support the falloff compatibility with gltf, a special mode has been added
  112159. * to reproduce the gltf light falloff.
  112160. */
  112161. useGLTFLightFalloff: boolean;
  112162. /**
  112163. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112164. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112165. */
  112166. useRadianceOverAlpha: boolean;
  112167. /**
  112168. * Allows using an object space normal map (instead of tangent space).
  112169. */
  112170. useObjectSpaceNormalMap: boolean;
  112171. /**
  112172. * Allows using the bump map in parallax mode.
  112173. */
  112174. useParallax: boolean;
  112175. /**
  112176. * Allows using the bump map in parallax occlusion mode.
  112177. */
  112178. useParallaxOcclusion: boolean;
  112179. /**
  112180. * Controls the scale bias of the parallax mode.
  112181. */
  112182. parallaxScaleBias: number;
  112183. /**
  112184. * If sets to true, disables all the lights affecting the material.
  112185. */
  112186. disableLighting: boolean;
  112187. /**
  112188. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112189. */
  112190. forceIrradianceInFragment: boolean;
  112191. /**
  112192. * Number of Simultaneous lights allowed on the material.
  112193. */
  112194. maxSimultaneousLights: number;
  112195. /**
  112196. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112197. */
  112198. invertNormalMapX: boolean;
  112199. /**
  112200. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112201. */
  112202. invertNormalMapY: boolean;
  112203. /**
  112204. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112205. */
  112206. twoSidedLighting: boolean;
  112207. /**
  112208. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112209. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112210. */
  112211. useAlphaFresnel: boolean;
  112212. /**
  112213. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112214. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112215. */
  112216. useLinearAlphaFresnel: boolean;
  112217. /**
  112218. * Let user defines the brdf lookup texture used for IBL.
  112219. * A default 8bit version is embedded but you could point at :
  112220. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  112221. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  112222. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  112223. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  112224. */
  112225. environmentBRDFTexture: Nullable<BaseTexture>;
  112226. /**
  112227. * Force normal to face away from face.
  112228. */
  112229. forceNormalForward: boolean;
  112230. /**
  112231. * Enables specular anti aliasing in the PBR shader.
  112232. * It will both interacts on the Geometry for analytical and IBL lighting.
  112233. * It also prefilter the roughness map based on the bump values.
  112234. */
  112235. enableSpecularAntiAliasing: boolean;
  112236. /**
  112237. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112238. * makes the reflect vector face the model (under horizon).
  112239. */
  112240. useHorizonOcclusion: boolean;
  112241. /**
  112242. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112243. * too much the area relying on ambient texture to define their ambient occlusion.
  112244. */
  112245. useRadianceOcclusion: boolean;
  112246. /**
  112247. * If set to true, no lighting calculations will be applied.
  112248. */
  112249. unlit: boolean;
  112250. /**
  112251. * Gets the image processing configuration used either in this material.
  112252. */
  112253. /**
  112254. * Sets the Default image processing configuration used either in the this material.
  112255. *
  112256. * If sets to null, the scene one is in use.
  112257. */
  112258. imageProcessingConfiguration: ImageProcessingConfiguration;
  112259. /**
  112260. * Gets wether the color curves effect is enabled.
  112261. */
  112262. /**
  112263. * Sets wether the color curves effect is enabled.
  112264. */
  112265. cameraColorCurvesEnabled: boolean;
  112266. /**
  112267. * Gets wether the color grading effect is enabled.
  112268. */
  112269. /**
  112270. * Gets wether the color grading effect is enabled.
  112271. */
  112272. cameraColorGradingEnabled: boolean;
  112273. /**
  112274. * Gets wether tonemapping is enabled or not.
  112275. */
  112276. /**
  112277. * Sets wether tonemapping is enabled or not
  112278. */
  112279. cameraToneMappingEnabled: boolean;
  112280. /**
  112281. * The camera exposure used on this material.
  112282. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112283. * This corresponds to a photographic exposure.
  112284. */
  112285. /**
  112286. * The camera exposure used on this material.
  112287. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112288. * This corresponds to a photographic exposure.
  112289. */
  112290. cameraExposure: number;
  112291. /**
  112292. * Gets The camera contrast used on this material.
  112293. */
  112294. /**
  112295. * Sets The camera contrast used on this material.
  112296. */
  112297. cameraContrast: number;
  112298. /**
  112299. * Gets the Color Grading 2D Lookup Texture.
  112300. */
  112301. /**
  112302. * Sets the Color Grading 2D Lookup Texture.
  112303. */
  112304. cameraColorGradingTexture: Nullable<BaseTexture>;
  112305. /**
  112306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112308. * 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;
  112309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112310. */
  112311. /**
  112312. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112313. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112314. * 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;
  112315. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112316. */
  112317. cameraColorCurves: Nullable<ColorCurves>;
  112318. /**
  112319. * Instantiates a new PBRMaterial instance.
  112320. *
  112321. * @param name The material name
  112322. * @param scene The scene the material will be use in.
  112323. */
  112324. constructor(name: string, scene: Scene);
  112325. /**
  112326. * Returns the name of this material class.
  112327. */
  112328. getClassName(): string;
  112329. /**
  112330. * Makes a duplicate of the current material.
  112331. * @param name - name to use for the new material.
  112332. */
  112333. clone(name: string): PBRMaterial;
  112334. /**
  112335. * Serializes this PBR Material.
  112336. * @returns - An object with the serialized material.
  112337. */
  112338. serialize(): any;
  112339. /**
  112340. * Parses a PBR Material from a serialized object.
  112341. * @param source - Serialized object.
  112342. * @param scene - BJS scene instance.
  112343. * @param rootUrl - url for the scene object
  112344. * @returns - PBRMaterial
  112345. */
  112346. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  112347. }
  112348. }
  112349. declare module BABYLON {
  112350. /**
  112351. * Direct draw surface info
  112352. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  112353. */
  112354. export interface DDSInfo {
  112355. /**
  112356. * Width of the texture
  112357. */
  112358. width: number;
  112359. /**
  112360. * Width of the texture
  112361. */
  112362. height: number;
  112363. /**
  112364. * Number of Mipmaps for the texture
  112365. * @see https://en.wikipedia.org/wiki/Mipmap
  112366. */
  112367. mipmapCount: number;
  112368. /**
  112369. * If the textures format is a known fourCC format
  112370. * @see https://www.fourcc.org/
  112371. */
  112372. isFourCC: boolean;
  112373. /**
  112374. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  112375. */
  112376. isRGB: boolean;
  112377. /**
  112378. * If the texture is a lumincance format
  112379. */
  112380. isLuminance: boolean;
  112381. /**
  112382. * If this is a cube texture
  112383. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  112384. */
  112385. isCube: boolean;
  112386. /**
  112387. * If the texture is a compressed format eg. FOURCC_DXT1
  112388. */
  112389. isCompressed: boolean;
  112390. /**
  112391. * The dxgiFormat of the texture
  112392. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  112393. */
  112394. dxgiFormat: number;
  112395. /**
  112396. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  112397. */
  112398. textureType: number;
  112399. /**
  112400. * Sphericle polynomial created for the dds texture
  112401. */
  112402. sphericalPolynomial?: SphericalPolynomial;
  112403. }
  112404. /**
  112405. * Class used to provide DDS decompression tools
  112406. */
  112407. export class DDSTools {
  112408. /**
  112409. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  112410. */
  112411. static StoreLODInAlphaChannel: boolean;
  112412. /**
  112413. * Gets DDS information from an array buffer
  112414. * @param arrayBuffer defines the array buffer to read data from
  112415. * @returns the DDS information
  112416. */
  112417. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  112418. private static _FloatView;
  112419. private static _Int32View;
  112420. private static _ToHalfFloat;
  112421. private static _FromHalfFloat;
  112422. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  112423. private static _GetHalfFloatRGBAArrayBuffer;
  112424. private static _GetFloatRGBAArrayBuffer;
  112425. private static _GetFloatAsUIntRGBAArrayBuffer;
  112426. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  112427. private static _GetRGBAArrayBuffer;
  112428. private static _ExtractLongWordOrder;
  112429. private static _GetRGBArrayBuffer;
  112430. private static _GetLuminanceArrayBuffer;
  112431. /**
  112432. * Uploads DDS Levels to a Babylon Texture
  112433. * @hidden
  112434. */
  112435. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  112436. }
  112437. interface Engine {
  112438. /**
  112439. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  112440. * @param rootUrl defines the url where the file to load is located
  112441. * @param scene defines the current scene
  112442. * @param lodScale defines scale to apply to the mip map selection
  112443. * @param lodOffset defines offset to apply to the mip map selection
  112444. * @param onLoad defines an optional callback raised when the texture is loaded
  112445. * @param onError defines an optional callback raised if there is an issue to load the texture
  112446. * @param format defines the format of the data
  112447. * @param forcedExtension defines the extension to use to pick the right loader
  112448. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  112449. * @returns the cube texture as an InternalTexture
  112450. */
  112451. 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;
  112452. }
  112453. }
  112454. declare module BABYLON {
  112455. /**
  112456. * Implementation of the DDS Texture Loader.
  112457. * @hidden
  112458. */
  112459. export class _DDSTextureLoader implements IInternalTextureLoader {
  112460. /**
  112461. * Defines wether the loader supports cascade loading the different faces.
  112462. */
  112463. readonly supportCascades: boolean;
  112464. /**
  112465. * This returns if the loader support the current file information.
  112466. * @param extension defines the file extension of the file being loaded
  112467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112468. * @param fallback defines the fallback internal texture if any
  112469. * @param isBase64 defines whether the texture is encoded as a base64
  112470. * @param isBuffer defines whether the texture data are stored as a buffer
  112471. * @returns true if the loader can load the specified file
  112472. */
  112473. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112474. /**
  112475. * Transform the url before loading if required.
  112476. * @param rootUrl the url of the texture
  112477. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112478. * @returns the transformed texture
  112479. */
  112480. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112481. /**
  112482. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112483. * @param rootUrl the url of the texture
  112484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112485. * @returns the fallback texture
  112486. */
  112487. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112488. /**
  112489. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112490. * @param data contains the texture data
  112491. * @param texture defines the BabylonJS internal texture
  112492. * @param createPolynomials will be true if polynomials have been requested
  112493. * @param onLoad defines the callback to trigger once the texture is ready
  112494. * @param onError defines the callback to trigger in case of error
  112495. */
  112496. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112497. /**
  112498. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112499. * @param data contains the texture data
  112500. * @param texture defines the BabylonJS internal texture
  112501. * @param callback defines the method to call once ready to upload
  112502. */
  112503. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112504. }
  112505. }
  112506. declare module BABYLON {
  112507. /** @hidden */
  112508. export var rgbdEncodePixelShader: {
  112509. name: string;
  112510. shader: string;
  112511. };
  112512. }
  112513. declare module BABYLON {
  112514. /**
  112515. * Raw texture data and descriptor sufficient for WebGL texture upload
  112516. */
  112517. export interface EnvironmentTextureInfo {
  112518. /**
  112519. * Version of the environment map
  112520. */
  112521. version: number;
  112522. /**
  112523. * Width of image
  112524. */
  112525. width: number;
  112526. /**
  112527. * Irradiance information stored in the file.
  112528. */
  112529. irradiance: any;
  112530. /**
  112531. * Specular information stored in the file.
  112532. */
  112533. specular: any;
  112534. }
  112535. /**
  112536. * Sets of helpers addressing the serialization and deserialization of environment texture
  112537. * stored in a BabylonJS env file.
  112538. * Those files are usually stored as .env files.
  112539. */
  112540. export class EnvironmentTextureTools {
  112541. /**
  112542. * Magic number identifying the env file.
  112543. */
  112544. private static _MagicBytes;
  112545. /**
  112546. * Gets the environment info from an env file.
  112547. * @param data The array buffer containing the .env bytes.
  112548. * @returns the environment file info (the json header) if successfully parsed.
  112549. */
  112550. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112551. /**
  112552. * Creates an environment texture from a loaded cube texture.
  112553. * @param texture defines the cube texture to convert in env file
  112554. * @return a promise containing the environment data if succesfull.
  112555. */
  112556. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112557. /**
  112558. * Creates a JSON representation of the spherical data.
  112559. * @param texture defines the texture containing the polynomials
  112560. * @return the JSON representation of the spherical info
  112561. */
  112562. private static _CreateEnvTextureIrradiance;
  112563. /**
  112564. * Uploads the texture info contained in the env file to the GPU.
  112565. * @param texture defines the internal texture to upload to
  112566. * @param arrayBuffer defines the buffer cotaining the data to load
  112567. * @param info defines the texture info retrieved through the GetEnvInfo method
  112568. * @returns a promise
  112569. */
  112570. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112571. /**
  112572. * Uploads the levels of image data to the GPU.
  112573. * @param texture defines the internal texture to upload to
  112574. * @param imageData defines the array buffer views of image data [mipmap][face]
  112575. * @returns a promise
  112576. */
  112577. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112578. /**
  112579. * Uploads spherical polynomials information to the texture.
  112580. * @param texture defines the texture we are trying to upload the information to
  112581. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112582. */
  112583. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112584. /** @hidden */
  112585. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112586. }
  112587. }
  112588. declare module BABYLON {
  112589. /**
  112590. * Implementation of the ENV Texture Loader.
  112591. * @hidden
  112592. */
  112593. export class _ENVTextureLoader implements IInternalTextureLoader {
  112594. /**
  112595. * Defines wether the loader supports cascade loading the different faces.
  112596. */
  112597. readonly supportCascades: boolean;
  112598. /**
  112599. * This returns if the loader support the current file information.
  112600. * @param extension defines the file extension of the file being loaded
  112601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112602. * @param fallback defines the fallback internal texture if any
  112603. * @param isBase64 defines whether the texture is encoded as a base64
  112604. * @param isBuffer defines whether the texture data are stored as a buffer
  112605. * @returns true if the loader can load the specified file
  112606. */
  112607. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112608. /**
  112609. * Transform the url before loading if required.
  112610. * @param rootUrl the url of the texture
  112611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112612. * @returns the transformed texture
  112613. */
  112614. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112615. /**
  112616. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112617. * @param rootUrl the url of the texture
  112618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112619. * @returns the fallback texture
  112620. */
  112621. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112622. /**
  112623. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112624. * @param data contains the texture data
  112625. * @param texture defines the BabylonJS internal texture
  112626. * @param createPolynomials will be true if polynomials have been requested
  112627. * @param onLoad defines the callback to trigger once the texture is ready
  112628. * @param onError defines the callback to trigger in case of error
  112629. */
  112630. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112631. /**
  112632. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112633. * @param data contains the texture data
  112634. * @param texture defines the BabylonJS internal texture
  112635. * @param callback defines the method to call once ready to upload
  112636. */
  112637. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112638. }
  112639. }
  112640. declare module BABYLON {
  112641. /**
  112642. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112643. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112644. */
  112645. export class KhronosTextureContainer {
  112646. /** contents of the KTX container file */
  112647. arrayBuffer: any;
  112648. private static HEADER_LEN;
  112649. private static COMPRESSED_2D;
  112650. private static COMPRESSED_3D;
  112651. private static TEX_2D;
  112652. private static TEX_3D;
  112653. /**
  112654. * Gets the openGL type
  112655. */
  112656. glType: number;
  112657. /**
  112658. * Gets the openGL type size
  112659. */
  112660. glTypeSize: number;
  112661. /**
  112662. * Gets the openGL format
  112663. */
  112664. glFormat: number;
  112665. /**
  112666. * Gets the openGL internal format
  112667. */
  112668. glInternalFormat: number;
  112669. /**
  112670. * Gets the base internal format
  112671. */
  112672. glBaseInternalFormat: number;
  112673. /**
  112674. * Gets image width in pixel
  112675. */
  112676. pixelWidth: number;
  112677. /**
  112678. * Gets image height in pixel
  112679. */
  112680. pixelHeight: number;
  112681. /**
  112682. * Gets image depth in pixels
  112683. */
  112684. pixelDepth: number;
  112685. /**
  112686. * Gets the number of array elements
  112687. */
  112688. numberOfArrayElements: number;
  112689. /**
  112690. * Gets the number of faces
  112691. */
  112692. numberOfFaces: number;
  112693. /**
  112694. * Gets the number of mipmap levels
  112695. */
  112696. numberOfMipmapLevels: number;
  112697. /**
  112698. * Gets the bytes of key value data
  112699. */
  112700. bytesOfKeyValueData: number;
  112701. /**
  112702. * Gets the load type
  112703. */
  112704. loadType: number;
  112705. /**
  112706. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112707. */
  112708. isInvalid: boolean;
  112709. /**
  112710. * Creates a new KhronosTextureContainer
  112711. * @param arrayBuffer contents of the KTX container file
  112712. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112713. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112714. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112715. */
  112716. constructor(
  112717. /** contents of the KTX container file */
  112718. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112719. /**
  112720. * Uploads KTX content to a Babylon Texture.
  112721. * It is assumed that the texture has already been created & is currently bound
  112722. * @hidden
  112723. */
  112724. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112725. private _upload2DCompressedLevels;
  112726. }
  112727. }
  112728. declare module BABYLON {
  112729. /**
  112730. * Implementation of the KTX Texture Loader.
  112731. * @hidden
  112732. */
  112733. export class _KTXTextureLoader implements IInternalTextureLoader {
  112734. /**
  112735. * Defines wether the loader supports cascade loading the different faces.
  112736. */
  112737. readonly supportCascades: boolean;
  112738. /**
  112739. * This returns if the loader support the current file information.
  112740. * @param extension defines the file extension of the file being loaded
  112741. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112742. * @param fallback defines the fallback internal texture if any
  112743. * @param isBase64 defines whether the texture is encoded as a base64
  112744. * @param isBuffer defines whether the texture data are stored as a buffer
  112745. * @returns true if the loader can load the specified file
  112746. */
  112747. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112748. /**
  112749. * Transform the url before loading if required.
  112750. * @param rootUrl the url of the texture
  112751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112752. * @returns the transformed texture
  112753. */
  112754. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112755. /**
  112756. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112757. * @param rootUrl the url of the texture
  112758. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112759. * @returns the fallback texture
  112760. */
  112761. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112762. /**
  112763. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112764. * @param data contains the texture data
  112765. * @param texture defines the BabylonJS internal texture
  112766. * @param createPolynomials will be true if polynomials have been requested
  112767. * @param onLoad defines the callback to trigger once the texture is ready
  112768. * @param onError defines the callback to trigger in case of error
  112769. */
  112770. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112771. /**
  112772. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112773. * @param data contains the texture data
  112774. * @param texture defines the BabylonJS internal texture
  112775. * @param callback defines the method to call once ready to upload
  112776. */
  112777. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112778. }
  112779. }
  112780. declare module BABYLON {
  112781. /**
  112782. * Options for the default xr helper
  112783. */
  112784. export class WebXRDefaultExperienceOptions {
  112785. /**
  112786. * Floor meshes that should be used for teleporting
  112787. */
  112788. floorMeshes: Array<AbstractMesh>;
  112789. }
  112790. /**
  112791. * Default experience which provides a similar setup to the previous webVRExperience
  112792. */
  112793. export class WebXRDefaultExperience {
  112794. /**
  112795. * Base experience
  112796. */
  112797. baseExperience: WebXRExperienceHelper;
  112798. /**
  112799. * Input experience extension
  112800. */
  112801. input: WebXRInput;
  112802. /**
  112803. * Loads the controller models
  112804. */
  112805. controllerModelLoader: WebXRControllerModelLoader;
  112806. /**
  112807. * Enables laser pointer and selection
  112808. */
  112809. pointerSelection: WebXRControllerPointerSelection;
  112810. /**
  112811. * Enables teleportation
  112812. */
  112813. teleportation: WebXRControllerTeleportation;
  112814. /**
  112815. * Enables ui for enetering/exiting xr
  112816. */
  112817. enterExitUI: WebXREnterExitUI;
  112818. /**
  112819. * Default output canvas xr should render to
  112820. */
  112821. outputCanvas: WebXRManagedOutputCanvas;
  112822. /**
  112823. * Creates the default xr experience
  112824. * @param scene scene
  112825. * @param options options for basic configuration
  112826. * @returns resulting WebXRDefaultExperience
  112827. */
  112828. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112829. private constructor();
  112830. /**
  112831. * DIsposes of the experience helper
  112832. */
  112833. dispose(): void;
  112834. }
  112835. }
  112836. declare module BABYLON {
  112837. /** @hidden */
  112838. export var _forceSceneHelpersToBundle: boolean;
  112839. interface Scene {
  112840. /**
  112841. * Creates a default light for the scene.
  112842. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112843. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112844. */
  112845. createDefaultLight(replace?: boolean): void;
  112846. /**
  112847. * Creates a default camera for the scene.
  112848. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112849. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112850. * @param replace has default false, when true replaces the active camera in the scene
  112851. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112852. */
  112853. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112854. /**
  112855. * Creates a default camera and a default light.
  112856. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112857. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112858. * @param replace has the default false, when true replaces the active camera/light in the scene
  112859. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112860. */
  112861. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112862. /**
  112863. * Creates a new sky box
  112864. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112865. * @param environmentTexture defines the texture to use as environment texture
  112866. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112867. * @param scale defines the overall scale of the skybox
  112868. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112869. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112870. * @returns a new mesh holding the sky box
  112871. */
  112872. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112873. /**
  112874. * Creates a new environment
  112875. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112876. * @param options defines the options you can use to configure the environment
  112877. * @returns the new EnvironmentHelper
  112878. */
  112879. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112880. /**
  112881. * Creates a new VREXperienceHelper
  112882. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112883. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112884. * @returns a new VREXperienceHelper
  112885. */
  112886. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112887. /**
  112888. * Creates a new WebXRDefaultExperience
  112889. * @see http://doc.babylonjs.com/how_to/webxr
  112890. * @param options experience options
  112891. * @returns a promise for a new WebXRDefaultExperience
  112892. */
  112893. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112894. }
  112895. }
  112896. declare module BABYLON {
  112897. /**
  112898. * Contains position and normal vectors for a vertex
  112899. */
  112900. export class PositionNormalVertex {
  112901. /** the position of the vertex (defaut: 0,0,0) */
  112902. position: Vector3;
  112903. /** the normal of the vertex (defaut: 0,1,0) */
  112904. normal: Vector3;
  112905. /**
  112906. * Creates a PositionNormalVertex
  112907. * @param position the position of the vertex (defaut: 0,0,0)
  112908. * @param normal the normal of the vertex (defaut: 0,1,0)
  112909. */
  112910. constructor(
  112911. /** the position of the vertex (defaut: 0,0,0) */
  112912. position?: Vector3,
  112913. /** the normal of the vertex (defaut: 0,1,0) */
  112914. normal?: Vector3);
  112915. /**
  112916. * Clones the PositionNormalVertex
  112917. * @returns the cloned PositionNormalVertex
  112918. */
  112919. clone(): PositionNormalVertex;
  112920. }
  112921. /**
  112922. * Contains position, normal and uv vectors for a vertex
  112923. */
  112924. export class PositionNormalTextureVertex {
  112925. /** the position of the vertex (defaut: 0,0,0) */
  112926. position: Vector3;
  112927. /** the normal of the vertex (defaut: 0,1,0) */
  112928. normal: Vector3;
  112929. /** the uv of the vertex (default: 0,0) */
  112930. uv: Vector2;
  112931. /**
  112932. * Creates a PositionNormalTextureVertex
  112933. * @param position the position of the vertex (defaut: 0,0,0)
  112934. * @param normal the normal of the vertex (defaut: 0,1,0)
  112935. * @param uv the uv of the vertex (default: 0,0)
  112936. */
  112937. constructor(
  112938. /** the position of the vertex (defaut: 0,0,0) */
  112939. position?: Vector3,
  112940. /** the normal of the vertex (defaut: 0,1,0) */
  112941. normal?: Vector3,
  112942. /** the uv of the vertex (default: 0,0) */
  112943. uv?: Vector2);
  112944. /**
  112945. * Clones the PositionNormalTextureVertex
  112946. * @returns the cloned PositionNormalTextureVertex
  112947. */
  112948. clone(): PositionNormalTextureVertex;
  112949. }
  112950. }
  112951. declare module BABYLON {
  112952. /**
  112953. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112954. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112955. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112956. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112957. */
  112958. export class VideoDome extends TransformNode {
  112959. /**
  112960. * Define the video source as a Monoscopic panoramic 360 video.
  112961. */
  112962. static readonly MODE_MONOSCOPIC: number;
  112963. /**
  112964. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112965. */
  112966. static readonly MODE_TOPBOTTOM: number;
  112967. /**
  112968. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112969. */
  112970. static readonly MODE_SIDEBYSIDE: number;
  112971. private _halfDome;
  112972. private _useDirectMapping;
  112973. /**
  112974. * The video texture being displayed on the sphere
  112975. */
  112976. protected _videoTexture: VideoTexture;
  112977. /**
  112978. * Gets the video texture being displayed on the sphere
  112979. */
  112980. readonly videoTexture: VideoTexture;
  112981. /**
  112982. * The skybox material
  112983. */
  112984. protected _material: BackgroundMaterial;
  112985. /**
  112986. * The surface used for the skybox
  112987. */
  112988. protected _mesh: Mesh;
  112989. /**
  112990. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  112991. */
  112992. private _halfDomeMask;
  112993. /**
  112994. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112995. * Also see the options.resolution property.
  112996. */
  112997. fovMultiplier: number;
  112998. private _videoMode;
  112999. /**
  113000. * Gets or set the current video mode for the video. It can be:
  113001. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  113002. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113003. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113004. */
  113005. videoMode: number;
  113006. /**
  113007. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  113008. *
  113009. */
  113010. /**
  113011. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  113012. */
  113013. halfDome: boolean;
  113014. /**
  113015. * Oberserver used in Stereoscopic VR Mode.
  113016. */
  113017. private _onBeforeCameraRenderObserver;
  113018. /**
  113019. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  113020. * @param name Element's name, child elements will append suffixes for their own names.
  113021. * @param urlsOrVideo defines the url(s) or the video element to use
  113022. * @param options An object containing optional or exposed sub element properties
  113023. */
  113024. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  113025. resolution?: number;
  113026. clickToPlay?: boolean;
  113027. autoPlay?: boolean;
  113028. loop?: boolean;
  113029. size?: number;
  113030. poster?: string;
  113031. faceForward?: boolean;
  113032. useDirectMapping?: boolean;
  113033. halfDomeMode?: boolean;
  113034. }, scene: Scene);
  113035. private _changeVideoMode;
  113036. /**
  113037. * Releases resources associated with this node.
  113038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113040. */
  113041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113042. }
  113043. }
  113044. declare module BABYLON {
  113045. /**
  113046. * This class can be used to get instrumentation data from a Babylon engine
  113047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113048. */
  113049. export class EngineInstrumentation implements IDisposable {
  113050. /**
  113051. * Define the instrumented engine.
  113052. */
  113053. engine: Engine;
  113054. private _captureGPUFrameTime;
  113055. private _gpuFrameTimeToken;
  113056. private _gpuFrameTime;
  113057. private _captureShaderCompilationTime;
  113058. private _shaderCompilationTime;
  113059. private _onBeginFrameObserver;
  113060. private _onEndFrameObserver;
  113061. private _onBeforeShaderCompilationObserver;
  113062. private _onAfterShaderCompilationObserver;
  113063. /**
  113064. * Gets the perf counter used for GPU frame time
  113065. */
  113066. readonly gpuFrameTimeCounter: PerfCounter;
  113067. /**
  113068. * Gets the GPU frame time capture status
  113069. */
  113070. /**
  113071. * Enable or disable the GPU frame time capture
  113072. */
  113073. captureGPUFrameTime: boolean;
  113074. /**
  113075. * Gets the perf counter used for shader compilation time
  113076. */
  113077. readonly shaderCompilationTimeCounter: PerfCounter;
  113078. /**
  113079. * Gets the shader compilation time capture status
  113080. */
  113081. /**
  113082. * Enable or disable the shader compilation time capture
  113083. */
  113084. captureShaderCompilationTime: boolean;
  113085. /**
  113086. * Instantiates a new engine instrumentation.
  113087. * This class can be used to get instrumentation data from a Babylon engine
  113088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113089. * @param engine Defines the engine to instrument
  113090. */
  113091. constructor(
  113092. /**
  113093. * Define the instrumented engine.
  113094. */
  113095. engine: Engine);
  113096. /**
  113097. * Dispose and release associated resources.
  113098. */
  113099. dispose(): void;
  113100. }
  113101. }
  113102. declare module BABYLON {
  113103. /**
  113104. * This class can be used to get instrumentation data from a Babylon engine
  113105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113106. */
  113107. export class SceneInstrumentation implements IDisposable {
  113108. /**
  113109. * Defines the scene to instrument
  113110. */
  113111. scene: Scene;
  113112. private _captureActiveMeshesEvaluationTime;
  113113. private _activeMeshesEvaluationTime;
  113114. private _captureRenderTargetsRenderTime;
  113115. private _renderTargetsRenderTime;
  113116. private _captureFrameTime;
  113117. private _frameTime;
  113118. private _captureRenderTime;
  113119. private _renderTime;
  113120. private _captureInterFrameTime;
  113121. private _interFrameTime;
  113122. private _captureParticlesRenderTime;
  113123. private _particlesRenderTime;
  113124. private _captureSpritesRenderTime;
  113125. private _spritesRenderTime;
  113126. private _capturePhysicsTime;
  113127. private _physicsTime;
  113128. private _captureAnimationsTime;
  113129. private _animationsTime;
  113130. private _captureCameraRenderTime;
  113131. private _cameraRenderTime;
  113132. private _onBeforeActiveMeshesEvaluationObserver;
  113133. private _onAfterActiveMeshesEvaluationObserver;
  113134. private _onBeforeRenderTargetsRenderObserver;
  113135. private _onAfterRenderTargetsRenderObserver;
  113136. private _onAfterRenderObserver;
  113137. private _onBeforeDrawPhaseObserver;
  113138. private _onAfterDrawPhaseObserver;
  113139. private _onBeforeAnimationsObserver;
  113140. private _onBeforeParticlesRenderingObserver;
  113141. private _onAfterParticlesRenderingObserver;
  113142. private _onBeforeSpritesRenderingObserver;
  113143. private _onAfterSpritesRenderingObserver;
  113144. private _onBeforePhysicsObserver;
  113145. private _onAfterPhysicsObserver;
  113146. private _onAfterAnimationsObserver;
  113147. private _onBeforeCameraRenderObserver;
  113148. private _onAfterCameraRenderObserver;
  113149. /**
  113150. * Gets the perf counter used for active meshes evaluation time
  113151. */
  113152. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  113153. /**
  113154. * Gets the active meshes evaluation time capture status
  113155. */
  113156. /**
  113157. * Enable or disable the active meshes evaluation time capture
  113158. */
  113159. captureActiveMeshesEvaluationTime: boolean;
  113160. /**
  113161. * Gets the perf counter used for render targets render time
  113162. */
  113163. readonly renderTargetsRenderTimeCounter: PerfCounter;
  113164. /**
  113165. * Gets the render targets render time capture status
  113166. */
  113167. /**
  113168. * Enable or disable the render targets render time capture
  113169. */
  113170. captureRenderTargetsRenderTime: boolean;
  113171. /**
  113172. * Gets the perf counter used for particles render time
  113173. */
  113174. readonly particlesRenderTimeCounter: PerfCounter;
  113175. /**
  113176. * Gets the particles render time capture status
  113177. */
  113178. /**
  113179. * Enable or disable the particles render time capture
  113180. */
  113181. captureParticlesRenderTime: boolean;
  113182. /**
  113183. * Gets the perf counter used for sprites render time
  113184. */
  113185. readonly spritesRenderTimeCounter: PerfCounter;
  113186. /**
  113187. * Gets the sprites render time capture status
  113188. */
  113189. /**
  113190. * Enable or disable the sprites render time capture
  113191. */
  113192. captureSpritesRenderTime: boolean;
  113193. /**
  113194. * Gets the perf counter used for physics time
  113195. */
  113196. readonly physicsTimeCounter: PerfCounter;
  113197. /**
  113198. * Gets the physics time capture status
  113199. */
  113200. /**
  113201. * Enable or disable the physics time capture
  113202. */
  113203. capturePhysicsTime: boolean;
  113204. /**
  113205. * Gets the perf counter used for animations time
  113206. */
  113207. readonly animationsTimeCounter: PerfCounter;
  113208. /**
  113209. * Gets the animations time capture status
  113210. */
  113211. /**
  113212. * Enable or disable the animations time capture
  113213. */
  113214. captureAnimationsTime: boolean;
  113215. /**
  113216. * Gets the perf counter used for frame time capture
  113217. */
  113218. readonly frameTimeCounter: PerfCounter;
  113219. /**
  113220. * Gets the frame time capture status
  113221. */
  113222. /**
  113223. * Enable or disable the frame time capture
  113224. */
  113225. captureFrameTime: boolean;
  113226. /**
  113227. * Gets the perf counter used for inter-frames time capture
  113228. */
  113229. readonly interFrameTimeCounter: PerfCounter;
  113230. /**
  113231. * Gets the inter-frames time capture status
  113232. */
  113233. /**
  113234. * Enable or disable the inter-frames time capture
  113235. */
  113236. captureInterFrameTime: boolean;
  113237. /**
  113238. * Gets the perf counter used for render time capture
  113239. */
  113240. readonly renderTimeCounter: PerfCounter;
  113241. /**
  113242. * Gets the render time capture status
  113243. */
  113244. /**
  113245. * Enable or disable the render time capture
  113246. */
  113247. captureRenderTime: boolean;
  113248. /**
  113249. * Gets the perf counter used for camera render time capture
  113250. */
  113251. readonly cameraRenderTimeCounter: PerfCounter;
  113252. /**
  113253. * Gets the camera render time capture status
  113254. */
  113255. /**
  113256. * Enable or disable the camera render time capture
  113257. */
  113258. captureCameraRenderTime: boolean;
  113259. /**
  113260. * Gets the perf counter used for draw calls
  113261. */
  113262. readonly drawCallsCounter: PerfCounter;
  113263. /**
  113264. * Instantiates a new scene instrumentation.
  113265. * This class can be used to get instrumentation data from a Babylon engine
  113266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113267. * @param scene Defines the scene to instrument
  113268. */
  113269. constructor(
  113270. /**
  113271. * Defines the scene to instrument
  113272. */
  113273. scene: Scene);
  113274. /**
  113275. * Dispose and release associated resources.
  113276. */
  113277. dispose(): void;
  113278. }
  113279. }
  113280. declare module BABYLON {
  113281. /** @hidden */
  113282. export var glowMapGenerationPixelShader: {
  113283. name: string;
  113284. shader: string;
  113285. };
  113286. }
  113287. declare module BABYLON {
  113288. /** @hidden */
  113289. export var glowMapGenerationVertexShader: {
  113290. name: string;
  113291. shader: string;
  113292. };
  113293. }
  113294. declare module BABYLON {
  113295. /**
  113296. * Effect layer options. This helps customizing the behaviour
  113297. * of the effect layer.
  113298. */
  113299. export interface IEffectLayerOptions {
  113300. /**
  113301. * Multiplication factor apply to the canvas size to compute the render target size
  113302. * used to generated the objects (the smaller the faster).
  113303. */
  113304. mainTextureRatio: number;
  113305. /**
  113306. * Enforces a fixed size texture to ensure effect stability across devices.
  113307. */
  113308. mainTextureFixedSize?: number;
  113309. /**
  113310. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  113311. */
  113312. alphaBlendingMode: number;
  113313. /**
  113314. * The camera attached to the layer.
  113315. */
  113316. camera: Nullable<Camera>;
  113317. /**
  113318. * The rendering group to draw the layer in.
  113319. */
  113320. renderingGroupId: number;
  113321. }
  113322. /**
  113323. * The effect layer Helps adding post process effect blended with the main pass.
  113324. *
  113325. * This can be for instance use to generate glow or higlight effects on the scene.
  113326. *
  113327. * The effect layer class can not be used directly and is intented to inherited from to be
  113328. * customized per effects.
  113329. */
  113330. export abstract class EffectLayer {
  113331. private _vertexBuffers;
  113332. private _indexBuffer;
  113333. private _cachedDefines;
  113334. private _effectLayerMapGenerationEffect;
  113335. private _effectLayerOptions;
  113336. private _mergeEffect;
  113337. protected _scene: Scene;
  113338. protected _engine: Engine;
  113339. protected _maxSize: number;
  113340. protected _mainTextureDesiredSize: ISize;
  113341. protected _mainTexture: RenderTargetTexture;
  113342. protected _shouldRender: boolean;
  113343. protected _postProcesses: PostProcess[];
  113344. protected _textures: BaseTexture[];
  113345. protected _emissiveTextureAndColor: {
  113346. texture: Nullable<BaseTexture>;
  113347. color: Color4;
  113348. };
  113349. /**
  113350. * The name of the layer
  113351. */
  113352. name: string;
  113353. /**
  113354. * The clear color of the texture used to generate the glow map.
  113355. */
  113356. neutralColor: Color4;
  113357. /**
  113358. * Specifies wether the highlight layer is enabled or not.
  113359. */
  113360. isEnabled: boolean;
  113361. /**
  113362. * Gets the camera attached to the layer.
  113363. */
  113364. readonly camera: Nullable<Camera>;
  113365. /**
  113366. * Gets the rendering group id the layer should render in.
  113367. */
  113368. renderingGroupId: number;
  113369. /**
  113370. * An event triggered when the effect layer has been disposed.
  113371. */
  113372. onDisposeObservable: Observable<EffectLayer>;
  113373. /**
  113374. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  113375. */
  113376. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  113377. /**
  113378. * An event triggered when the generated texture is being merged in the scene.
  113379. */
  113380. onBeforeComposeObservable: Observable<EffectLayer>;
  113381. /**
  113382. * An event triggered when the generated texture has been merged in the scene.
  113383. */
  113384. onAfterComposeObservable: Observable<EffectLayer>;
  113385. /**
  113386. * An event triggered when the efffect layer changes its size.
  113387. */
  113388. onSizeChangedObservable: Observable<EffectLayer>;
  113389. /** @hidden */
  113390. static _SceneComponentInitialization: (scene: Scene) => void;
  113391. /**
  113392. * Instantiates a new effect Layer and references it in the scene.
  113393. * @param name The name of the layer
  113394. * @param scene The scene to use the layer in
  113395. */
  113396. constructor(
  113397. /** The Friendly of the effect in the scene */
  113398. name: string, scene: Scene);
  113399. /**
  113400. * Get the effect name of the layer.
  113401. * @return The effect name
  113402. */
  113403. abstract getEffectName(): string;
  113404. /**
  113405. * Checks for the readiness of the element composing the layer.
  113406. * @param subMesh the mesh to check for
  113407. * @param useInstances specify wether or not to use instances to render the mesh
  113408. * @return true if ready otherwise, false
  113409. */
  113410. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113411. /**
  113412. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113413. * @returns true if the effect requires stencil during the main canvas render pass.
  113414. */
  113415. abstract needStencil(): boolean;
  113416. /**
  113417. * Create the merge effect. This is the shader use to blit the information back
  113418. * to the main canvas at the end of the scene rendering.
  113419. * @returns The effect containing the shader used to merge the effect on the main canvas
  113420. */
  113421. protected abstract _createMergeEffect(): Effect;
  113422. /**
  113423. * Creates the render target textures and post processes used in the effect layer.
  113424. */
  113425. protected abstract _createTextureAndPostProcesses(): void;
  113426. /**
  113427. * Implementation specific of rendering the generating effect on the main canvas.
  113428. * @param effect The effect used to render through
  113429. */
  113430. protected abstract _internalRender(effect: Effect): void;
  113431. /**
  113432. * Sets the required values for both the emissive texture and and the main color.
  113433. */
  113434. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113435. /**
  113436. * Free any resources and references associated to a mesh.
  113437. * Internal use
  113438. * @param mesh The mesh to free.
  113439. */
  113440. abstract _disposeMesh(mesh: Mesh): void;
  113441. /**
  113442. * Serializes this layer (Glow or Highlight for example)
  113443. * @returns a serialized layer object
  113444. */
  113445. abstract serialize?(): any;
  113446. /**
  113447. * Initializes the effect layer with the required options.
  113448. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  113449. */
  113450. protected _init(options: Partial<IEffectLayerOptions>): void;
  113451. /**
  113452. * Generates the index buffer of the full screen quad blending to the main canvas.
  113453. */
  113454. private _generateIndexBuffer;
  113455. /**
  113456. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  113457. */
  113458. private _generateVertexBuffer;
  113459. /**
  113460. * Sets the main texture desired size which is the closest power of two
  113461. * of the engine canvas size.
  113462. */
  113463. private _setMainTextureSize;
  113464. /**
  113465. * Creates the main texture for the effect layer.
  113466. */
  113467. protected _createMainTexture(): void;
  113468. /**
  113469. * Adds specific effects defines.
  113470. * @param defines The defines to add specifics to.
  113471. */
  113472. protected _addCustomEffectDefines(defines: string[]): void;
  113473. /**
  113474. * Checks for the readiness of the element composing the layer.
  113475. * @param subMesh the mesh to check for
  113476. * @param useInstances specify wether or not to use instances to render the mesh
  113477. * @param emissiveTexture the associated emissive texture used to generate the glow
  113478. * @return true if ready otherwise, false
  113479. */
  113480. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113481. /**
  113482. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113483. */
  113484. render(): void;
  113485. /**
  113486. * Determine if a given mesh will be used in the current effect.
  113487. * @param mesh mesh to test
  113488. * @returns true if the mesh will be used
  113489. */
  113490. hasMesh(mesh: AbstractMesh): boolean;
  113491. /**
  113492. * Returns true if the layer contains information to display, otherwise false.
  113493. * @returns true if the glow layer should be rendered
  113494. */
  113495. shouldRender(): boolean;
  113496. /**
  113497. * Returns true if the mesh should render, otherwise false.
  113498. * @param mesh The mesh to render
  113499. * @returns true if it should render otherwise false
  113500. */
  113501. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113502. /**
  113503. * Returns true if the mesh can be rendered, otherwise false.
  113504. * @param mesh The mesh to render
  113505. * @param material The material used on the mesh
  113506. * @returns true if it can be rendered otherwise false
  113507. */
  113508. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113509. /**
  113510. * Returns true if the mesh should render, otherwise false.
  113511. * @param mesh The mesh to render
  113512. * @returns true if it should render otherwise false
  113513. */
  113514. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113515. /**
  113516. * Renders the submesh passed in parameter to the generation map.
  113517. */
  113518. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113519. /**
  113520. * Rebuild the required buffers.
  113521. * @hidden Internal use only.
  113522. */
  113523. _rebuild(): void;
  113524. /**
  113525. * Dispose only the render target textures and post process.
  113526. */
  113527. private _disposeTextureAndPostProcesses;
  113528. /**
  113529. * Dispose the highlight layer and free resources.
  113530. */
  113531. dispose(): void;
  113532. /**
  113533. * Gets the class name of the effect layer
  113534. * @returns the string with the class name of the effect layer
  113535. */
  113536. getClassName(): string;
  113537. /**
  113538. * Creates an effect layer from parsed effect layer data
  113539. * @param parsedEffectLayer defines effect layer data
  113540. * @param scene defines the current scene
  113541. * @param rootUrl defines the root URL containing the effect layer information
  113542. * @returns a parsed effect Layer
  113543. */
  113544. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113545. }
  113546. }
  113547. declare module BABYLON {
  113548. interface AbstractScene {
  113549. /**
  113550. * The list of effect layers (highlights/glow) added to the scene
  113551. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113552. * @see http://doc.babylonjs.com/how_to/glow_layer
  113553. */
  113554. effectLayers: Array<EffectLayer>;
  113555. /**
  113556. * Removes the given effect layer from this scene.
  113557. * @param toRemove defines the effect layer to remove
  113558. * @returns the index of the removed effect layer
  113559. */
  113560. removeEffectLayer(toRemove: EffectLayer): number;
  113561. /**
  113562. * Adds the given effect layer to this scene
  113563. * @param newEffectLayer defines the effect layer to add
  113564. */
  113565. addEffectLayer(newEffectLayer: EffectLayer): void;
  113566. }
  113567. /**
  113568. * Defines the layer scene component responsible to manage any effect layers
  113569. * in a given scene.
  113570. */
  113571. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113572. /**
  113573. * The component name helpfull to identify the component in the list of scene components.
  113574. */
  113575. readonly name: string;
  113576. /**
  113577. * The scene the component belongs to.
  113578. */
  113579. scene: Scene;
  113580. private _engine;
  113581. private _renderEffects;
  113582. private _needStencil;
  113583. private _previousStencilState;
  113584. /**
  113585. * Creates a new instance of the component for the given scene
  113586. * @param scene Defines the scene to register the component in
  113587. */
  113588. constructor(scene: Scene);
  113589. /**
  113590. * Registers the component in a given scene
  113591. */
  113592. register(): void;
  113593. /**
  113594. * Rebuilds the elements related to this component in case of
  113595. * context lost for instance.
  113596. */
  113597. rebuild(): void;
  113598. /**
  113599. * Serializes the component data to the specified json object
  113600. * @param serializationObject The object to serialize to
  113601. */
  113602. serialize(serializationObject: any): void;
  113603. /**
  113604. * Adds all the elements from the container to the scene
  113605. * @param container the container holding the elements
  113606. */
  113607. addFromContainer(container: AbstractScene): void;
  113608. /**
  113609. * Removes all the elements in the container from the scene
  113610. * @param container contains the elements to remove
  113611. * @param dispose if the removed element should be disposed (default: false)
  113612. */
  113613. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113614. /**
  113615. * Disposes the component and the associated ressources.
  113616. */
  113617. dispose(): void;
  113618. private _isReadyForMesh;
  113619. private _renderMainTexture;
  113620. private _setStencil;
  113621. private _setStencilBack;
  113622. private _draw;
  113623. private _drawCamera;
  113624. private _drawRenderingGroup;
  113625. }
  113626. }
  113627. declare module BABYLON {
  113628. /** @hidden */
  113629. export var glowMapMergePixelShader: {
  113630. name: string;
  113631. shader: string;
  113632. };
  113633. }
  113634. declare module BABYLON {
  113635. /** @hidden */
  113636. export var glowMapMergeVertexShader: {
  113637. name: string;
  113638. shader: string;
  113639. };
  113640. }
  113641. declare module BABYLON {
  113642. interface AbstractScene {
  113643. /**
  113644. * Return a the first highlight layer of the scene with a given name.
  113645. * @param name The name of the highlight layer to look for.
  113646. * @return The highlight layer if found otherwise null.
  113647. */
  113648. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113649. }
  113650. /**
  113651. * Glow layer options. This helps customizing the behaviour
  113652. * of the glow layer.
  113653. */
  113654. export interface IGlowLayerOptions {
  113655. /**
  113656. * Multiplication factor apply to the canvas size to compute the render target size
  113657. * used to generated the glowing objects (the smaller the faster).
  113658. */
  113659. mainTextureRatio: number;
  113660. /**
  113661. * Enforces a fixed size texture to ensure resize independant blur.
  113662. */
  113663. mainTextureFixedSize?: number;
  113664. /**
  113665. * How big is the kernel of the blur texture.
  113666. */
  113667. blurKernelSize: number;
  113668. /**
  113669. * The camera attached to the layer.
  113670. */
  113671. camera: Nullable<Camera>;
  113672. /**
  113673. * Enable MSAA by chosing the number of samples.
  113674. */
  113675. mainTextureSamples?: number;
  113676. /**
  113677. * The rendering group to draw the layer in.
  113678. */
  113679. renderingGroupId: number;
  113680. }
  113681. /**
  113682. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113683. *
  113684. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113685. * glowy meshes to your scene.
  113686. *
  113687. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113688. */
  113689. export class GlowLayer extends EffectLayer {
  113690. /**
  113691. * Effect Name of the layer.
  113692. */
  113693. static readonly EffectName: string;
  113694. /**
  113695. * The default blur kernel size used for the glow.
  113696. */
  113697. static DefaultBlurKernelSize: number;
  113698. /**
  113699. * The default texture size ratio used for the glow.
  113700. */
  113701. static DefaultTextureRatio: number;
  113702. /**
  113703. * Sets the kernel size of the blur.
  113704. */
  113705. /**
  113706. * Gets the kernel size of the blur.
  113707. */
  113708. blurKernelSize: number;
  113709. /**
  113710. * Sets the glow intensity.
  113711. */
  113712. /**
  113713. * Gets the glow intensity.
  113714. */
  113715. intensity: number;
  113716. private _options;
  113717. private _intensity;
  113718. private _horizontalBlurPostprocess1;
  113719. private _verticalBlurPostprocess1;
  113720. private _horizontalBlurPostprocess2;
  113721. private _verticalBlurPostprocess2;
  113722. private _blurTexture1;
  113723. private _blurTexture2;
  113724. private _postProcesses1;
  113725. private _postProcesses2;
  113726. private _includedOnlyMeshes;
  113727. private _excludedMeshes;
  113728. /**
  113729. * Callback used to let the user override the color selection on a per mesh basis
  113730. */
  113731. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113732. /**
  113733. * Callback used to let the user override the texture selection on a per mesh basis
  113734. */
  113735. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113736. /**
  113737. * Instantiates a new glow Layer and references it to the scene.
  113738. * @param name The name of the layer
  113739. * @param scene The scene to use the layer in
  113740. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113741. */
  113742. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113743. /**
  113744. * Get the effect name of the layer.
  113745. * @return The effect name
  113746. */
  113747. getEffectName(): string;
  113748. /**
  113749. * Create the merge effect. This is the shader use to blit the information back
  113750. * to the main canvas at the end of the scene rendering.
  113751. */
  113752. protected _createMergeEffect(): Effect;
  113753. /**
  113754. * Creates the render target textures and post processes used in the glow layer.
  113755. */
  113756. protected _createTextureAndPostProcesses(): void;
  113757. /**
  113758. * Checks for the readiness of the element composing the layer.
  113759. * @param subMesh the mesh to check for
  113760. * @param useInstances specify wether or not to use instances to render the mesh
  113761. * @param emissiveTexture the associated emissive texture used to generate the glow
  113762. * @return true if ready otherwise, false
  113763. */
  113764. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113765. /**
  113766. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113767. */
  113768. needStencil(): boolean;
  113769. /**
  113770. * Returns true if the mesh can be rendered, otherwise false.
  113771. * @param mesh The mesh to render
  113772. * @param material The material used on the mesh
  113773. * @returns true if it can be rendered otherwise false
  113774. */
  113775. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113776. /**
  113777. * Implementation specific of rendering the generating effect on the main canvas.
  113778. * @param effect The effect used to render through
  113779. */
  113780. protected _internalRender(effect: Effect): void;
  113781. /**
  113782. * Sets the required values for both the emissive texture and and the main color.
  113783. */
  113784. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113785. /**
  113786. * Returns true if the mesh should render, otherwise false.
  113787. * @param mesh The mesh to render
  113788. * @returns true if it should render otherwise false
  113789. */
  113790. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113791. /**
  113792. * Adds specific effects defines.
  113793. * @param defines The defines to add specifics to.
  113794. */
  113795. protected _addCustomEffectDefines(defines: string[]): void;
  113796. /**
  113797. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113798. * @param mesh The mesh to exclude from the glow layer
  113799. */
  113800. addExcludedMesh(mesh: Mesh): void;
  113801. /**
  113802. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113803. * @param mesh The mesh to remove
  113804. */
  113805. removeExcludedMesh(mesh: Mesh): void;
  113806. /**
  113807. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113808. * @param mesh The mesh to include in the glow layer
  113809. */
  113810. addIncludedOnlyMesh(mesh: Mesh): void;
  113811. /**
  113812. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113813. * @param mesh The mesh to remove
  113814. */
  113815. removeIncludedOnlyMesh(mesh: Mesh): void;
  113816. /**
  113817. * Determine if a given mesh will be used in the glow layer
  113818. * @param mesh The mesh to test
  113819. * @returns true if the mesh will be highlighted by the current glow layer
  113820. */
  113821. hasMesh(mesh: AbstractMesh): boolean;
  113822. /**
  113823. * Free any resources and references associated to a mesh.
  113824. * Internal use
  113825. * @param mesh The mesh to free.
  113826. * @hidden
  113827. */
  113828. _disposeMesh(mesh: Mesh): void;
  113829. /**
  113830. * Gets the class name of the effect layer
  113831. * @returns the string with the class name of the effect layer
  113832. */
  113833. getClassName(): string;
  113834. /**
  113835. * Serializes this glow layer
  113836. * @returns a serialized glow layer object
  113837. */
  113838. serialize(): any;
  113839. /**
  113840. * Creates a Glow Layer from parsed glow layer data
  113841. * @param parsedGlowLayer defines glow layer data
  113842. * @param scene defines the current scene
  113843. * @param rootUrl defines the root URL containing the glow layer information
  113844. * @returns a parsed Glow Layer
  113845. */
  113846. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113847. }
  113848. }
  113849. declare module BABYLON {
  113850. /** @hidden */
  113851. export var glowBlurPostProcessPixelShader: {
  113852. name: string;
  113853. shader: string;
  113854. };
  113855. }
  113856. declare module BABYLON {
  113857. interface AbstractScene {
  113858. /**
  113859. * Return a the first highlight layer of the scene with a given name.
  113860. * @param name The name of the highlight layer to look for.
  113861. * @return The highlight layer if found otherwise null.
  113862. */
  113863. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113864. }
  113865. /**
  113866. * Highlight layer options. This helps customizing the behaviour
  113867. * of the highlight layer.
  113868. */
  113869. export interface IHighlightLayerOptions {
  113870. /**
  113871. * Multiplication factor apply to the canvas size to compute the render target size
  113872. * used to generated the glowing objects (the smaller the faster).
  113873. */
  113874. mainTextureRatio: number;
  113875. /**
  113876. * Enforces a fixed size texture to ensure resize independant blur.
  113877. */
  113878. mainTextureFixedSize?: number;
  113879. /**
  113880. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113881. * of the picture to blur (the smaller the faster).
  113882. */
  113883. blurTextureSizeRatio: number;
  113884. /**
  113885. * How big in texel of the blur texture is the vertical blur.
  113886. */
  113887. blurVerticalSize: number;
  113888. /**
  113889. * How big in texel of the blur texture is the horizontal blur.
  113890. */
  113891. blurHorizontalSize: number;
  113892. /**
  113893. * Alpha blending mode used to apply the blur. Default is combine.
  113894. */
  113895. alphaBlendingMode: number;
  113896. /**
  113897. * The camera attached to the layer.
  113898. */
  113899. camera: Nullable<Camera>;
  113900. /**
  113901. * Should we display highlight as a solid stroke?
  113902. */
  113903. isStroke?: boolean;
  113904. /**
  113905. * The rendering group to draw the layer in.
  113906. */
  113907. renderingGroupId: number;
  113908. }
  113909. /**
  113910. * The highlight layer Helps adding a glow effect around a mesh.
  113911. *
  113912. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113913. * glowy meshes to your scene.
  113914. *
  113915. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113916. */
  113917. export class HighlightLayer extends EffectLayer {
  113918. name: string;
  113919. /**
  113920. * Effect Name of the highlight layer.
  113921. */
  113922. static readonly EffectName: string;
  113923. /**
  113924. * The neutral color used during the preparation of the glow effect.
  113925. * This is black by default as the blend operation is a blend operation.
  113926. */
  113927. static NeutralColor: Color4;
  113928. /**
  113929. * Stencil value used for glowing meshes.
  113930. */
  113931. static GlowingMeshStencilReference: number;
  113932. /**
  113933. * Stencil value used for the other meshes in the scene.
  113934. */
  113935. static NormalMeshStencilReference: number;
  113936. /**
  113937. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113938. */
  113939. innerGlow: boolean;
  113940. /**
  113941. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113942. */
  113943. outerGlow: boolean;
  113944. /**
  113945. * Specifies the horizontal size of the blur.
  113946. */
  113947. /**
  113948. * Gets the horizontal size of the blur.
  113949. */
  113950. blurHorizontalSize: number;
  113951. /**
  113952. * Specifies the vertical size of the blur.
  113953. */
  113954. /**
  113955. * Gets the vertical size of the blur.
  113956. */
  113957. blurVerticalSize: number;
  113958. /**
  113959. * An event triggered when the highlight layer is being blurred.
  113960. */
  113961. onBeforeBlurObservable: Observable<HighlightLayer>;
  113962. /**
  113963. * An event triggered when the highlight layer has been blurred.
  113964. */
  113965. onAfterBlurObservable: Observable<HighlightLayer>;
  113966. private _instanceGlowingMeshStencilReference;
  113967. private _options;
  113968. private _downSamplePostprocess;
  113969. private _horizontalBlurPostprocess;
  113970. private _verticalBlurPostprocess;
  113971. private _blurTexture;
  113972. private _meshes;
  113973. private _excludedMeshes;
  113974. /**
  113975. * Instantiates a new highlight Layer and references it to the scene..
  113976. * @param name The name of the layer
  113977. * @param scene The scene to use the layer in
  113978. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113979. */
  113980. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113981. /**
  113982. * Get the effect name of the layer.
  113983. * @return The effect name
  113984. */
  113985. getEffectName(): string;
  113986. /**
  113987. * Create the merge effect. This is the shader use to blit the information back
  113988. * to the main canvas at the end of the scene rendering.
  113989. */
  113990. protected _createMergeEffect(): Effect;
  113991. /**
  113992. * Creates the render target textures and post processes used in the highlight layer.
  113993. */
  113994. protected _createTextureAndPostProcesses(): void;
  113995. /**
  113996. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113997. */
  113998. needStencil(): boolean;
  113999. /**
  114000. * Checks for the readiness of the element composing the layer.
  114001. * @param subMesh the mesh to check for
  114002. * @param useInstances specify wether or not to use instances to render the mesh
  114003. * @param emissiveTexture the associated emissive texture used to generate the glow
  114004. * @return true if ready otherwise, false
  114005. */
  114006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114007. /**
  114008. * Implementation specific of rendering the generating effect on the main canvas.
  114009. * @param effect The effect used to render through
  114010. */
  114011. protected _internalRender(effect: Effect): void;
  114012. /**
  114013. * Returns true if the layer contains information to display, otherwise false.
  114014. */
  114015. shouldRender(): boolean;
  114016. /**
  114017. * Returns true if the mesh should render, otherwise false.
  114018. * @param mesh The mesh to render
  114019. * @returns true if it should render otherwise false
  114020. */
  114021. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114022. /**
  114023. * Sets the required values for both the emissive texture and and the main color.
  114024. */
  114025. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114026. /**
  114027. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  114028. * @param mesh The mesh to exclude from the highlight layer
  114029. */
  114030. addExcludedMesh(mesh: Mesh): void;
  114031. /**
  114032. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  114033. * @param mesh The mesh to highlight
  114034. */
  114035. removeExcludedMesh(mesh: Mesh): void;
  114036. /**
  114037. * Determine if a given mesh will be highlighted by the current HighlightLayer
  114038. * @param mesh mesh to test
  114039. * @returns true if the mesh will be highlighted by the current HighlightLayer
  114040. */
  114041. hasMesh(mesh: AbstractMesh): boolean;
  114042. /**
  114043. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  114044. * @param mesh The mesh to highlight
  114045. * @param color The color of the highlight
  114046. * @param glowEmissiveOnly Extract the glow from the emissive texture
  114047. */
  114048. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  114049. /**
  114050. * Remove a mesh from the highlight layer in order to make it stop glowing.
  114051. * @param mesh The mesh to highlight
  114052. */
  114053. removeMesh(mesh: Mesh): void;
  114054. /**
  114055. * Force the stencil to the normal expected value for none glowing parts
  114056. */
  114057. private _defaultStencilReference;
  114058. /**
  114059. * Free any resources and references associated to a mesh.
  114060. * Internal use
  114061. * @param mesh The mesh to free.
  114062. * @hidden
  114063. */
  114064. _disposeMesh(mesh: Mesh): void;
  114065. /**
  114066. * Dispose the highlight layer and free resources.
  114067. */
  114068. dispose(): void;
  114069. /**
  114070. * Gets the class name of the effect layer
  114071. * @returns the string with the class name of the effect layer
  114072. */
  114073. getClassName(): string;
  114074. /**
  114075. * Serializes this Highlight layer
  114076. * @returns a serialized Highlight layer object
  114077. */
  114078. serialize(): any;
  114079. /**
  114080. * Creates a Highlight layer from parsed Highlight layer data
  114081. * @param parsedHightlightLayer defines the Highlight layer data
  114082. * @param scene defines the current scene
  114083. * @param rootUrl defines the root URL containing the Highlight layer information
  114084. * @returns a parsed Highlight layer
  114085. */
  114086. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  114087. }
  114088. }
  114089. declare module BABYLON {
  114090. interface AbstractScene {
  114091. /**
  114092. * The list of layers (background and foreground) of the scene
  114093. */
  114094. layers: Array<Layer>;
  114095. }
  114096. /**
  114097. * Defines the layer scene component responsible to manage any layers
  114098. * in a given scene.
  114099. */
  114100. export class LayerSceneComponent implements ISceneComponent {
  114101. /**
  114102. * The component name helpfull to identify the component in the list of scene components.
  114103. */
  114104. readonly name: string;
  114105. /**
  114106. * The scene the component belongs to.
  114107. */
  114108. scene: Scene;
  114109. private _engine;
  114110. /**
  114111. * Creates a new instance of the component for the given scene
  114112. * @param scene Defines the scene to register the component in
  114113. */
  114114. constructor(scene: Scene);
  114115. /**
  114116. * Registers the component in a given scene
  114117. */
  114118. register(): void;
  114119. /**
  114120. * Rebuilds the elements related to this component in case of
  114121. * context lost for instance.
  114122. */
  114123. rebuild(): void;
  114124. /**
  114125. * Disposes the component and the associated ressources.
  114126. */
  114127. dispose(): void;
  114128. private _draw;
  114129. private _drawCameraPredicate;
  114130. private _drawCameraBackground;
  114131. private _drawCameraForeground;
  114132. private _drawRenderTargetPredicate;
  114133. private _drawRenderTargetBackground;
  114134. private _drawRenderTargetForeground;
  114135. /**
  114136. * Adds all the elements from the container to the scene
  114137. * @param container the container holding the elements
  114138. */
  114139. addFromContainer(container: AbstractScene): void;
  114140. /**
  114141. * Removes all the elements in the container from the scene
  114142. * @param container contains the elements to remove
  114143. * @param dispose if the removed element should be disposed (default: false)
  114144. */
  114145. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114146. }
  114147. }
  114148. declare module BABYLON {
  114149. /** @hidden */
  114150. export var layerPixelShader: {
  114151. name: string;
  114152. shader: string;
  114153. };
  114154. }
  114155. declare module BABYLON {
  114156. /** @hidden */
  114157. export var layerVertexShader: {
  114158. name: string;
  114159. shader: string;
  114160. };
  114161. }
  114162. declare module BABYLON {
  114163. /**
  114164. * This represents a full screen 2d layer.
  114165. * This can be useful to display a picture in the background of your scene for instance.
  114166. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114167. */
  114168. export class Layer {
  114169. /**
  114170. * Define the name of the layer.
  114171. */
  114172. name: string;
  114173. /**
  114174. * Define the texture the layer should display.
  114175. */
  114176. texture: Nullable<Texture>;
  114177. /**
  114178. * Is the layer in background or foreground.
  114179. */
  114180. isBackground: boolean;
  114181. /**
  114182. * Define the color of the layer (instead of texture).
  114183. */
  114184. color: Color4;
  114185. /**
  114186. * Define the scale of the layer in order to zoom in out of the texture.
  114187. */
  114188. scale: Vector2;
  114189. /**
  114190. * Define an offset for the layer in order to shift the texture.
  114191. */
  114192. offset: Vector2;
  114193. /**
  114194. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  114195. */
  114196. alphaBlendingMode: number;
  114197. /**
  114198. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  114199. * Alpha test will not mix with the background color in case of transparency.
  114200. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  114201. */
  114202. alphaTest: boolean;
  114203. /**
  114204. * Define a mask to restrict the layer to only some of the scene cameras.
  114205. */
  114206. layerMask: number;
  114207. /**
  114208. * Define the list of render target the layer is visible into.
  114209. */
  114210. renderTargetTextures: RenderTargetTexture[];
  114211. /**
  114212. * Define if the layer is only used in renderTarget or if it also
  114213. * renders in the main frame buffer of the canvas.
  114214. */
  114215. renderOnlyInRenderTargetTextures: boolean;
  114216. private _scene;
  114217. private _vertexBuffers;
  114218. private _indexBuffer;
  114219. private _effect;
  114220. private _alphaTestEffect;
  114221. /**
  114222. * An event triggered when the layer is disposed.
  114223. */
  114224. onDisposeObservable: Observable<Layer>;
  114225. private _onDisposeObserver;
  114226. /**
  114227. * Back compatibility with callback before the onDisposeObservable existed.
  114228. * The set callback will be triggered when the layer has been disposed.
  114229. */
  114230. onDispose: () => void;
  114231. /**
  114232. * An event triggered before rendering the scene
  114233. */
  114234. onBeforeRenderObservable: Observable<Layer>;
  114235. private _onBeforeRenderObserver;
  114236. /**
  114237. * Back compatibility with callback before the onBeforeRenderObservable existed.
  114238. * The set callback will be triggered just before rendering the layer.
  114239. */
  114240. onBeforeRender: () => void;
  114241. /**
  114242. * An event triggered after rendering the scene
  114243. */
  114244. onAfterRenderObservable: Observable<Layer>;
  114245. private _onAfterRenderObserver;
  114246. /**
  114247. * Back compatibility with callback before the onAfterRenderObservable existed.
  114248. * The set callback will be triggered just after rendering the layer.
  114249. */
  114250. onAfterRender: () => void;
  114251. /**
  114252. * Instantiates a new layer.
  114253. * This represents a full screen 2d layer.
  114254. * This can be useful to display a picture in the background of your scene for instance.
  114255. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114256. * @param name Define the name of the layer in the scene
  114257. * @param imgUrl Define the url of the texture to display in the layer
  114258. * @param scene Define the scene the layer belongs to
  114259. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  114260. * @param color Defines a color for the layer
  114261. */
  114262. constructor(
  114263. /**
  114264. * Define the name of the layer.
  114265. */
  114266. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  114267. private _createIndexBuffer;
  114268. /** @hidden */
  114269. _rebuild(): void;
  114270. /**
  114271. * Renders the layer in the scene.
  114272. */
  114273. render(): void;
  114274. /**
  114275. * Disposes and releases the associated ressources.
  114276. */
  114277. dispose(): void;
  114278. }
  114279. }
  114280. declare module BABYLON {
  114281. /** @hidden */
  114282. export var lensFlarePixelShader: {
  114283. name: string;
  114284. shader: string;
  114285. };
  114286. }
  114287. declare module BABYLON {
  114288. /** @hidden */
  114289. export var lensFlareVertexShader: {
  114290. name: string;
  114291. shader: string;
  114292. };
  114293. }
  114294. declare module BABYLON {
  114295. /**
  114296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114297. * It is usually composed of several `lensFlare`.
  114298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114299. */
  114300. export class LensFlareSystem {
  114301. /**
  114302. * Define the name of the lens flare system
  114303. */
  114304. name: string;
  114305. /**
  114306. * List of lens flares used in this system.
  114307. */
  114308. lensFlares: LensFlare[];
  114309. /**
  114310. * Define a limit from the border the lens flare can be visible.
  114311. */
  114312. borderLimit: number;
  114313. /**
  114314. * Define a viewport border we do not want to see the lens flare in.
  114315. */
  114316. viewportBorder: number;
  114317. /**
  114318. * Define a predicate which could limit the list of meshes able to occlude the effect.
  114319. */
  114320. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114321. /**
  114322. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  114323. */
  114324. layerMask: number;
  114325. /**
  114326. * Define the id of the lens flare system in the scene.
  114327. * (equal to name by default)
  114328. */
  114329. id: string;
  114330. private _scene;
  114331. private _emitter;
  114332. private _vertexBuffers;
  114333. private _indexBuffer;
  114334. private _effect;
  114335. private _positionX;
  114336. private _positionY;
  114337. private _isEnabled;
  114338. /** @hidden */
  114339. static _SceneComponentInitialization: (scene: Scene) => void;
  114340. /**
  114341. * Instantiates a lens flare system.
  114342. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114343. * It is usually composed of several `lensFlare`.
  114344. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114345. * @param name Define the name of the lens flare system in the scene
  114346. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  114347. * @param scene Define the scene the lens flare system belongs to
  114348. */
  114349. constructor(
  114350. /**
  114351. * Define the name of the lens flare system
  114352. */
  114353. name: string, emitter: any, scene: Scene);
  114354. /**
  114355. * Define if the lens flare system is enabled.
  114356. */
  114357. isEnabled: boolean;
  114358. /**
  114359. * Get the scene the effects belongs to.
  114360. * @returns the scene holding the lens flare system
  114361. */
  114362. getScene(): Scene;
  114363. /**
  114364. * Get the emitter of the lens flare system.
  114365. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114366. * @returns the emitter of the lens flare system
  114367. */
  114368. getEmitter(): any;
  114369. /**
  114370. * Set the emitter of the lens flare system.
  114371. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114372. * @param newEmitter Define the new emitter of the system
  114373. */
  114374. setEmitter(newEmitter: any): void;
  114375. /**
  114376. * Get the lens flare system emitter position.
  114377. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  114378. * @returns the position
  114379. */
  114380. getEmitterPosition(): Vector3;
  114381. /**
  114382. * @hidden
  114383. */
  114384. computeEffectivePosition(globalViewport: Viewport): boolean;
  114385. /** @hidden */
  114386. _isVisible(): boolean;
  114387. /**
  114388. * @hidden
  114389. */
  114390. render(): boolean;
  114391. /**
  114392. * Dispose and release the lens flare with its associated resources.
  114393. */
  114394. dispose(): void;
  114395. /**
  114396. * Parse a lens flare system from a JSON repressentation
  114397. * @param parsedLensFlareSystem Define the JSON to parse
  114398. * @param scene Define the scene the parsed system should be instantiated in
  114399. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  114400. * @returns the parsed system
  114401. */
  114402. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  114403. /**
  114404. * Serialize the current Lens Flare System into a JSON representation.
  114405. * @returns the serialized JSON
  114406. */
  114407. serialize(): any;
  114408. }
  114409. }
  114410. declare module BABYLON {
  114411. /**
  114412. * This represents one of the lens effect in a `lensFlareSystem`.
  114413. * It controls one of the indiviual texture used in the effect.
  114414. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114415. */
  114416. export class LensFlare {
  114417. /**
  114418. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114419. */
  114420. size: number;
  114421. /**
  114422. * 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.
  114423. */
  114424. position: number;
  114425. /**
  114426. * Define the lens color.
  114427. */
  114428. color: Color3;
  114429. /**
  114430. * Define the lens texture.
  114431. */
  114432. texture: Nullable<Texture>;
  114433. /**
  114434. * Define the alpha mode to render this particular lens.
  114435. */
  114436. alphaMode: number;
  114437. private _system;
  114438. /**
  114439. * Creates a new Lens Flare.
  114440. * This represents one of the lens effect in a `lensFlareSystem`.
  114441. * It controls one of the indiviual texture used in the effect.
  114442. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114443. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  114444. * @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.
  114445. * @param color Define the lens color
  114446. * @param imgUrl Define the lens texture url
  114447. * @param system Define the `lensFlareSystem` this flare is part of
  114448. * @returns The newly created Lens Flare
  114449. */
  114450. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  114451. /**
  114452. * Instantiates a new Lens Flare.
  114453. * This represents one of the lens effect in a `lensFlareSystem`.
  114454. * It controls one of the indiviual texture used in the effect.
  114455. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114456. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  114457. * @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.
  114458. * @param color Define the lens color
  114459. * @param imgUrl Define the lens texture url
  114460. * @param system Define the `lensFlareSystem` this flare is part of
  114461. */
  114462. constructor(
  114463. /**
  114464. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114465. */
  114466. size: number,
  114467. /**
  114468. * 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.
  114469. */
  114470. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114471. /**
  114472. * Dispose and release the lens flare with its associated resources.
  114473. */
  114474. dispose(): void;
  114475. }
  114476. }
  114477. declare module BABYLON {
  114478. interface AbstractScene {
  114479. /**
  114480. * The list of lens flare system added to the scene
  114481. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114482. */
  114483. lensFlareSystems: Array<LensFlareSystem>;
  114484. /**
  114485. * Removes the given lens flare system from this scene.
  114486. * @param toRemove The lens flare system to remove
  114487. * @returns The index of the removed lens flare system
  114488. */
  114489. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114490. /**
  114491. * Adds the given lens flare system to this scene
  114492. * @param newLensFlareSystem The lens flare system to add
  114493. */
  114494. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114495. /**
  114496. * Gets a lens flare system using its name
  114497. * @param name defines the name to look for
  114498. * @returns the lens flare system or null if not found
  114499. */
  114500. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114501. /**
  114502. * Gets a lens flare system using its id
  114503. * @param id defines the id to look for
  114504. * @returns the lens flare system or null if not found
  114505. */
  114506. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114507. }
  114508. /**
  114509. * Defines the lens flare scene component responsible to manage any lens flares
  114510. * in a given scene.
  114511. */
  114512. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114513. /**
  114514. * The component name helpfull to identify the component in the list of scene components.
  114515. */
  114516. readonly name: string;
  114517. /**
  114518. * The scene the component belongs to.
  114519. */
  114520. scene: Scene;
  114521. /**
  114522. * Creates a new instance of the component for the given scene
  114523. * @param scene Defines the scene to register the component in
  114524. */
  114525. constructor(scene: Scene);
  114526. /**
  114527. * Registers the component in a given scene
  114528. */
  114529. register(): void;
  114530. /**
  114531. * Rebuilds the elements related to this component in case of
  114532. * context lost for instance.
  114533. */
  114534. rebuild(): void;
  114535. /**
  114536. * Adds all the elements from the container to the scene
  114537. * @param container the container holding the elements
  114538. */
  114539. addFromContainer(container: AbstractScene): void;
  114540. /**
  114541. * Removes all the elements in the container from the scene
  114542. * @param container contains the elements to remove
  114543. * @param dispose if the removed element should be disposed (default: false)
  114544. */
  114545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114546. /**
  114547. * Serializes the component data to the specified json object
  114548. * @param serializationObject The object to serialize to
  114549. */
  114550. serialize(serializationObject: any): void;
  114551. /**
  114552. * Disposes the component and the associated ressources.
  114553. */
  114554. dispose(): void;
  114555. private _draw;
  114556. }
  114557. }
  114558. declare module BABYLON {
  114559. /**
  114560. * Defines the shadow generator component responsible to manage any shadow generators
  114561. * in a given scene.
  114562. */
  114563. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114564. /**
  114565. * The component name helpfull to identify the component in the list of scene components.
  114566. */
  114567. readonly name: string;
  114568. /**
  114569. * The scene the component belongs to.
  114570. */
  114571. scene: Scene;
  114572. /**
  114573. * Creates a new instance of the component for the given scene
  114574. * @param scene Defines the scene to register the component in
  114575. */
  114576. constructor(scene: Scene);
  114577. /**
  114578. * Registers the component in a given scene
  114579. */
  114580. register(): void;
  114581. /**
  114582. * Rebuilds the elements related to this component in case of
  114583. * context lost for instance.
  114584. */
  114585. rebuild(): void;
  114586. /**
  114587. * Serializes the component data to the specified json object
  114588. * @param serializationObject The object to serialize to
  114589. */
  114590. serialize(serializationObject: any): void;
  114591. /**
  114592. * Adds all the elements from the container to the scene
  114593. * @param container the container holding the elements
  114594. */
  114595. addFromContainer(container: AbstractScene): void;
  114596. /**
  114597. * Removes all the elements in the container from the scene
  114598. * @param container contains the elements to remove
  114599. * @param dispose if the removed element should be disposed (default: false)
  114600. */
  114601. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114602. /**
  114603. * Rebuilds the elements related to this component in case of
  114604. * context lost for instance.
  114605. */
  114606. dispose(): void;
  114607. private _gatherRenderTargets;
  114608. }
  114609. }
  114610. declare module BABYLON {
  114611. /**
  114612. * A point light is a light defined by an unique point in world space.
  114613. * The light is emitted in every direction from this point.
  114614. * A good example of a point light is a standard light bulb.
  114615. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114616. */
  114617. export class PointLight extends ShadowLight {
  114618. private _shadowAngle;
  114619. /**
  114620. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114621. * This specifies what angle the shadow will use to be created.
  114622. *
  114623. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114624. */
  114625. /**
  114626. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114627. * This specifies what angle the shadow will use to be created.
  114628. *
  114629. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114630. */
  114631. shadowAngle: number;
  114632. /**
  114633. * Gets the direction if it has been set.
  114634. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114635. */
  114636. /**
  114637. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114638. */
  114639. direction: Vector3;
  114640. /**
  114641. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114642. * A PointLight emits the light in every direction.
  114643. * It can cast shadows.
  114644. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114645. * ```javascript
  114646. * var pointLight = new PointLight("pl", camera.position, scene);
  114647. * ```
  114648. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114649. * @param name The light friendly name
  114650. * @param position The position of the point light in the scene
  114651. * @param scene The scene the lights belongs to
  114652. */
  114653. constructor(name: string, position: Vector3, scene: Scene);
  114654. /**
  114655. * Returns the string "PointLight"
  114656. * @returns the class name
  114657. */
  114658. getClassName(): string;
  114659. /**
  114660. * Returns the integer 0.
  114661. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114662. */
  114663. getTypeID(): number;
  114664. /**
  114665. * Specifies wether or not the shadowmap should be a cube texture.
  114666. * @returns true if the shadowmap needs to be a cube texture.
  114667. */
  114668. needCube(): boolean;
  114669. /**
  114670. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114671. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114672. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114673. */
  114674. getShadowDirection(faceIndex?: number): Vector3;
  114675. /**
  114676. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114677. * - fov = PI / 2
  114678. * - aspect ratio : 1.0
  114679. * - z-near and far equal to the active camera minZ and maxZ.
  114680. * Returns the PointLight.
  114681. */
  114682. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114683. protected _buildUniformLayout(): void;
  114684. /**
  114685. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114686. * @param effect The effect to update
  114687. * @param lightIndex The index of the light in the effect to update
  114688. * @returns The point light
  114689. */
  114690. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114691. /**
  114692. * Prepares the list of defines specific to the light type.
  114693. * @param defines the list of defines
  114694. * @param lightIndex defines the index of the light for the effect
  114695. */
  114696. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114697. }
  114698. }
  114699. declare module BABYLON {
  114700. /**
  114701. * Header information of HDR texture files.
  114702. */
  114703. export interface HDRInfo {
  114704. /**
  114705. * The height of the texture in pixels.
  114706. */
  114707. height: number;
  114708. /**
  114709. * The width of the texture in pixels.
  114710. */
  114711. width: number;
  114712. /**
  114713. * The index of the beginning of the data in the binary file.
  114714. */
  114715. dataPosition: number;
  114716. }
  114717. /**
  114718. * This groups tools to convert HDR texture to native colors array.
  114719. */
  114720. export class HDRTools {
  114721. private static Ldexp;
  114722. private static Rgbe2float;
  114723. private static readStringLine;
  114724. /**
  114725. * Reads header information from an RGBE texture stored in a native array.
  114726. * More information on this format are available here:
  114727. * https://en.wikipedia.org/wiki/RGBE_image_format
  114728. *
  114729. * @param uint8array The binary file stored in native array.
  114730. * @return The header information.
  114731. */
  114732. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114733. /**
  114734. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114735. * This RGBE texture needs to store the information as a panorama.
  114736. *
  114737. * More information on this format are available here:
  114738. * https://en.wikipedia.org/wiki/RGBE_image_format
  114739. *
  114740. * @param buffer The binary file stored in an array buffer.
  114741. * @param size The expected size of the extracted cubemap.
  114742. * @return The Cube Map information.
  114743. */
  114744. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114745. /**
  114746. * Returns the pixels data extracted from an RGBE texture.
  114747. * This pixels will be stored left to right up to down in the R G B order in one array.
  114748. *
  114749. * More information on this format are available here:
  114750. * https://en.wikipedia.org/wiki/RGBE_image_format
  114751. *
  114752. * @param uint8array The binary file stored in an array buffer.
  114753. * @param hdrInfo The header information of the file.
  114754. * @return The pixels data in RGB right to left up to down order.
  114755. */
  114756. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114757. private static RGBE_ReadPixels_RLE;
  114758. }
  114759. }
  114760. declare module BABYLON {
  114761. /**
  114762. * This represents a texture coming from an HDR input.
  114763. *
  114764. * The only supported format is currently panorama picture stored in RGBE format.
  114765. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114766. */
  114767. export class HDRCubeTexture extends BaseTexture {
  114768. private static _facesMapping;
  114769. private _generateHarmonics;
  114770. private _noMipmap;
  114771. private _textureMatrix;
  114772. private _size;
  114773. private _onLoad;
  114774. private _onError;
  114775. /**
  114776. * The texture URL.
  114777. */
  114778. url: string;
  114779. /**
  114780. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114781. */
  114782. coordinatesMode: number;
  114783. protected _isBlocking: boolean;
  114784. /**
  114785. * Sets wether or not the texture is blocking during loading.
  114786. */
  114787. /**
  114788. * Gets wether or not the texture is blocking during loading.
  114789. */
  114790. isBlocking: boolean;
  114791. protected _rotationY: number;
  114792. /**
  114793. * Sets texture matrix rotation angle around Y axis in radians.
  114794. */
  114795. /**
  114796. * Gets texture matrix rotation angle around Y axis radians.
  114797. */
  114798. rotationY: number;
  114799. /**
  114800. * Gets or sets the center of the bounding box associated with the cube texture
  114801. * It must define where the camera used to render the texture was set
  114802. */
  114803. boundingBoxPosition: Vector3;
  114804. private _boundingBoxSize;
  114805. /**
  114806. * Gets or sets the size of the bounding box associated with the cube texture
  114807. * When defined, the cubemap will switch to local mode
  114808. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114809. * @example https://www.babylonjs-playground.com/#RNASML
  114810. */
  114811. boundingBoxSize: Vector3;
  114812. /**
  114813. * Instantiates an HDRTexture from the following parameters.
  114814. *
  114815. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114816. * @param scene The scene the texture will be used in
  114817. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114818. * @param noMipmap Forces to not generate the mipmap if true
  114819. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114820. * @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)
  114821. * @param reserved Reserved flag for internal use.
  114822. */
  114823. 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>);
  114824. /**
  114825. * Get the current class name of the texture useful for serialization or dynamic coding.
  114826. * @returns "HDRCubeTexture"
  114827. */
  114828. getClassName(): string;
  114829. /**
  114830. * Occurs when the file is raw .hdr file.
  114831. */
  114832. private loadTexture;
  114833. clone(): HDRCubeTexture;
  114834. delayLoad(): void;
  114835. /**
  114836. * Get the texture reflection matrix used to rotate/transform the reflection.
  114837. * @returns the reflection matrix
  114838. */
  114839. getReflectionTextureMatrix(): Matrix;
  114840. /**
  114841. * Set the texture reflection matrix used to rotate/transform the reflection.
  114842. * @param value Define the reflection matrix to set
  114843. */
  114844. setReflectionTextureMatrix(value: Matrix): void;
  114845. /**
  114846. * Parses a JSON representation of an HDR Texture in order to create the texture
  114847. * @param parsedTexture Define the JSON representation
  114848. * @param scene Define the scene the texture should be created in
  114849. * @param rootUrl Define the root url in case we need to load relative dependencies
  114850. * @returns the newly created texture after parsing
  114851. */
  114852. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114853. serialize(): any;
  114854. }
  114855. }
  114856. declare module BABYLON {
  114857. /**
  114858. * Class used to control physics engine
  114859. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114860. */
  114861. export class PhysicsEngine implements IPhysicsEngine {
  114862. private _physicsPlugin;
  114863. /**
  114864. * Global value used to control the smallest number supported by the simulation
  114865. */
  114866. static Epsilon: number;
  114867. private _impostors;
  114868. private _joints;
  114869. /**
  114870. * Gets the gravity vector used by the simulation
  114871. */
  114872. gravity: Vector3;
  114873. /**
  114874. * Factory used to create the default physics plugin.
  114875. * @returns The default physics plugin
  114876. */
  114877. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114878. /**
  114879. * Creates a new Physics Engine
  114880. * @param gravity defines the gravity vector used by the simulation
  114881. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114882. */
  114883. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114884. /**
  114885. * Sets the gravity vector used by the simulation
  114886. * @param gravity defines the gravity vector to use
  114887. */
  114888. setGravity(gravity: Vector3): void;
  114889. /**
  114890. * Set the time step of the physics engine.
  114891. * Default is 1/60.
  114892. * To slow it down, enter 1/600 for example.
  114893. * To speed it up, 1/30
  114894. * @param newTimeStep defines the new timestep to apply to this world.
  114895. */
  114896. setTimeStep(newTimeStep?: number): void;
  114897. /**
  114898. * Get the time step of the physics engine.
  114899. * @returns the current time step
  114900. */
  114901. getTimeStep(): number;
  114902. /**
  114903. * Release all resources
  114904. */
  114905. dispose(): void;
  114906. /**
  114907. * Gets the name of the current physics plugin
  114908. * @returns the name of the plugin
  114909. */
  114910. getPhysicsPluginName(): string;
  114911. /**
  114912. * Adding a new impostor for the impostor tracking.
  114913. * This will be done by the impostor itself.
  114914. * @param impostor the impostor to add
  114915. */
  114916. addImpostor(impostor: PhysicsImpostor): void;
  114917. /**
  114918. * Remove an impostor from the engine.
  114919. * This impostor and its mesh will not longer be updated by the physics engine.
  114920. * @param impostor the impostor to remove
  114921. */
  114922. removeImpostor(impostor: PhysicsImpostor): void;
  114923. /**
  114924. * Add a joint to the physics engine
  114925. * @param mainImpostor defines the main impostor to which the joint is added.
  114926. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114927. * @param joint defines the joint that will connect both impostors.
  114928. */
  114929. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114930. /**
  114931. * Removes a joint from the simulation
  114932. * @param mainImpostor defines the impostor used with the joint
  114933. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114934. * @param joint defines the joint to remove
  114935. */
  114936. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114937. /**
  114938. * Called by the scene. No need to call it.
  114939. * @param delta defines the timespam between frames
  114940. */
  114941. _step(delta: number): void;
  114942. /**
  114943. * Gets the current plugin used to run the simulation
  114944. * @returns current plugin
  114945. */
  114946. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114947. /**
  114948. * Gets the list of physic impostors
  114949. * @returns an array of PhysicsImpostor
  114950. */
  114951. getImpostors(): Array<PhysicsImpostor>;
  114952. /**
  114953. * Gets the impostor for a physics enabled object
  114954. * @param object defines the object impersonated by the impostor
  114955. * @returns the PhysicsImpostor or null if not found
  114956. */
  114957. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114958. /**
  114959. * Gets the impostor for a physics body object
  114960. * @param body defines physics body used by the impostor
  114961. * @returns the PhysicsImpostor or null if not found
  114962. */
  114963. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114964. /**
  114965. * Does a raycast in the physics world
  114966. * @param from when should the ray start?
  114967. * @param to when should the ray end?
  114968. * @returns PhysicsRaycastResult
  114969. */
  114970. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114971. }
  114972. }
  114973. declare module BABYLON {
  114974. /** @hidden */
  114975. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114976. private _useDeltaForWorldStep;
  114977. world: any;
  114978. name: string;
  114979. private _physicsMaterials;
  114980. private _fixedTimeStep;
  114981. private _cannonRaycastResult;
  114982. private _raycastResult;
  114983. private _physicsBodysToRemoveAfterStep;
  114984. BJSCANNON: any;
  114985. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114986. setGravity(gravity: Vector3): void;
  114987. setTimeStep(timeStep: number): void;
  114988. getTimeStep(): number;
  114989. executeStep(delta: number): void;
  114990. private _removeMarkedPhysicsBodiesFromWorld;
  114991. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114992. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114993. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114994. private _processChildMeshes;
  114995. removePhysicsBody(impostor: PhysicsImpostor): void;
  114996. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114997. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114998. private _addMaterial;
  114999. private _checkWithEpsilon;
  115000. private _createShape;
  115001. private _createHeightmap;
  115002. private _minus90X;
  115003. private _plus90X;
  115004. private _tmpPosition;
  115005. private _tmpDeltaPosition;
  115006. private _tmpUnityRotation;
  115007. private _updatePhysicsBodyTransformation;
  115008. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115009. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115010. isSupported(): boolean;
  115011. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115012. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115013. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115014. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115015. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115016. getBodyMass(impostor: PhysicsImpostor): number;
  115017. getBodyFriction(impostor: PhysicsImpostor): number;
  115018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115019. getBodyRestitution(impostor: PhysicsImpostor): number;
  115020. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115021. sleepBody(impostor: PhysicsImpostor): void;
  115022. wakeUpBody(impostor: PhysicsImpostor): void;
  115023. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  115024. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115025. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115026. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115027. getRadius(impostor: PhysicsImpostor): number;
  115028. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115029. dispose(): void;
  115030. private _extendNamespace;
  115031. /**
  115032. * Does a raycast in the physics world
  115033. * @param from when should the ray start?
  115034. * @param to when should the ray end?
  115035. * @returns PhysicsRaycastResult
  115036. */
  115037. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115038. }
  115039. }
  115040. declare module BABYLON {
  115041. /** @hidden */
  115042. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  115043. world: any;
  115044. name: string;
  115045. BJSOIMO: any;
  115046. private _raycastResult;
  115047. constructor(iterations?: number, oimoInjection?: any);
  115048. setGravity(gravity: Vector3): void;
  115049. setTimeStep(timeStep: number): void;
  115050. getTimeStep(): number;
  115051. private _tmpImpostorsArray;
  115052. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115053. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115054. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115055. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115056. private _tmpPositionVector;
  115057. removePhysicsBody(impostor: PhysicsImpostor): void;
  115058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115059. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115060. isSupported(): boolean;
  115061. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115062. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115063. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115064. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115065. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115066. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115067. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115068. getBodyMass(impostor: PhysicsImpostor): number;
  115069. getBodyFriction(impostor: PhysicsImpostor): number;
  115070. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115071. getBodyRestitution(impostor: PhysicsImpostor): number;
  115072. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115073. sleepBody(impostor: PhysicsImpostor): void;
  115074. wakeUpBody(impostor: PhysicsImpostor): void;
  115075. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115076. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  115077. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  115078. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115079. getRadius(impostor: PhysicsImpostor): number;
  115080. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115081. dispose(): void;
  115082. /**
  115083. * Does a raycast in the physics world
  115084. * @param from when should the ray start?
  115085. * @param to when should the ray end?
  115086. * @returns PhysicsRaycastResult
  115087. */
  115088. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115089. }
  115090. }
  115091. declare module BABYLON {
  115092. /**
  115093. * Class containing static functions to help procedurally build meshes
  115094. */
  115095. export class RibbonBuilder {
  115096. /**
  115097. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115098. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115099. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115100. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115101. * * 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
  115102. * * 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
  115103. * * 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
  115104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115106. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115107. * * 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
  115108. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115109. * * 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
  115110. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115112. * @param name defines the name of the mesh
  115113. * @param options defines the options used to create the mesh
  115114. * @param scene defines the hosting scene
  115115. * @returns the ribbon mesh
  115116. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115117. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115118. */
  115119. static CreateRibbon(name: string, options: {
  115120. pathArray: Vector3[][];
  115121. closeArray?: boolean;
  115122. closePath?: boolean;
  115123. offset?: number;
  115124. updatable?: boolean;
  115125. sideOrientation?: number;
  115126. frontUVs?: Vector4;
  115127. backUVs?: Vector4;
  115128. instance?: Mesh;
  115129. invertUV?: boolean;
  115130. uvs?: Vector2[];
  115131. colors?: Color4[];
  115132. }, scene?: Nullable<Scene>): Mesh;
  115133. }
  115134. }
  115135. declare module BABYLON {
  115136. /**
  115137. * Class containing static functions to help procedurally build meshes
  115138. */
  115139. export class ShapeBuilder {
  115140. /**
  115141. * 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.
  115142. * * 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.
  115143. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115144. * * 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.
  115145. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115146. * * 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
  115147. * * 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
  115148. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115153. * @param name defines the name of the mesh
  115154. * @param options defines the options used to create the mesh
  115155. * @param scene defines the hosting scene
  115156. * @returns the extruded shape mesh
  115157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115159. */
  115160. static ExtrudeShape(name: string, options: {
  115161. shape: Vector3[];
  115162. path: Vector3[];
  115163. scale?: number;
  115164. rotation?: number;
  115165. cap?: number;
  115166. updatable?: boolean;
  115167. sideOrientation?: number;
  115168. frontUVs?: Vector4;
  115169. backUVs?: Vector4;
  115170. instance?: Mesh;
  115171. invertUV?: boolean;
  115172. }, scene?: Nullable<Scene>): Mesh;
  115173. /**
  115174. * Creates an custom extruded shape mesh.
  115175. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115176. * * 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.
  115177. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115178. * * 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
  115179. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115180. * * 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
  115181. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115182. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115183. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115184. * * 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
  115185. * * 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
  115186. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115191. * @param name defines the name of the mesh
  115192. * @param options defines the options used to create the mesh
  115193. * @param scene defines the hosting scene
  115194. * @returns the custom extruded shape mesh
  115195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115198. */
  115199. static ExtrudeShapeCustom(name: string, options: {
  115200. shape: Vector3[];
  115201. path: Vector3[];
  115202. scaleFunction?: any;
  115203. rotationFunction?: any;
  115204. ribbonCloseArray?: boolean;
  115205. ribbonClosePath?: boolean;
  115206. cap?: number;
  115207. updatable?: boolean;
  115208. sideOrientation?: number;
  115209. frontUVs?: Vector4;
  115210. backUVs?: Vector4;
  115211. instance?: Mesh;
  115212. invertUV?: boolean;
  115213. }, scene?: Nullable<Scene>): Mesh;
  115214. private static _ExtrudeShapeGeneric;
  115215. }
  115216. }
  115217. declare module BABYLON {
  115218. /**
  115219. * AmmoJS Physics plugin
  115220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115221. * @see https://github.com/kripken/ammo.js/
  115222. */
  115223. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  115224. private _useDeltaForWorldStep;
  115225. /**
  115226. * Reference to the Ammo library
  115227. */
  115228. bjsAMMO: any;
  115229. /**
  115230. * Created ammoJS world which physics bodies are added to
  115231. */
  115232. world: any;
  115233. /**
  115234. * Name of the plugin
  115235. */
  115236. name: string;
  115237. private _timeStep;
  115238. private _fixedTimeStep;
  115239. private _maxSteps;
  115240. private _tmpQuaternion;
  115241. private _tmpAmmoTransform;
  115242. private _tmpAmmoQuaternion;
  115243. private _tmpAmmoConcreteContactResultCallback;
  115244. private _collisionConfiguration;
  115245. private _dispatcher;
  115246. private _overlappingPairCache;
  115247. private _solver;
  115248. private _softBodySolver;
  115249. private _tmpAmmoVectorA;
  115250. private _tmpAmmoVectorB;
  115251. private _tmpAmmoVectorC;
  115252. private _tmpAmmoVectorD;
  115253. private _tmpContactCallbackResult;
  115254. private _tmpAmmoVectorRCA;
  115255. private _tmpAmmoVectorRCB;
  115256. private _raycastResult;
  115257. private static readonly DISABLE_COLLISION_FLAG;
  115258. private static readonly KINEMATIC_FLAG;
  115259. private static readonly DISABLE_DEACTIVATION_FLAG;
  115260. /**
  115261. * Initializes the ammoJS plugin
  115262. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  115263. * @param ammoInjection can be used to inject your own ammo reference
  115264. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  115265. */
  115266. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  115267. /**
  115268. * Sets the gravity of the physics world (m/(s^2))
  115269. * @param gravity Gravity to set
  115270. */
  115271. setGravity(gravity: Vector3): void;
  115272. /**
  115273. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  115274. * @param timeStep timestep to use in seconds
  115275. */
  115276. setTimeStep(timeStep: number): void;
  115277. /**
  115278. * 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)
  115279. * @param fixedTimeStep fixedTimeStep to use in seconds
  115280. */
  115281. setFixedTimeStep(fixedTimeStep: number): void;
  115282. /**
  115283. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  115284. * @param maxSteps the maximum number of steps by the physics engine per frame
  115285. */
  115286. setMaxSteps(maxSteps: number): void;
  115287. /**
  115288. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  115289. * @returns the current timestep in seconds
  115290. */
  115291. getTimeStep(): number;
  115292. private _isImpostorInContact;
  115293. private _isImpostorPairInContact;
  115294. private _stepSimulation;
  115295. /**
  115296. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  115297. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  115298. * After the step the babylon meshes are set to the position of the physics imposters
  115299. * @param delta amount of time to step forward
  115300. * @param impostors array of imposters to update before/after the step
  115301. */
  115302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115303. /**
  115304. * Update babylon mesh to match physics world object
  115305. * @param impostor imposter to match
  115306. */
  115307. private _afterSoftStep;
  115308. /**
  115309. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115310. * @param impostor imposter to match
  115311. */
  115312. private _ropeStep;
  115313. /**
  115314. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115315. * @param impostor imposter to match
  115316. */
  115317. private _softbodyOrClothStep;
  115318. private _tmpVector;
  115319. private _tmpMatrix;
  115320. /**
  115321. * Applies an impulse on the imposter
  115322. * @param impostor imposter to apply impulse to
  115323. * @param force amount of force to be applied to the imposter
  115324. * @param contactPoint the location to apply the impulse on the imposter
  115325. */
  115326. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115327. /**
  115328. * Applies a force on the imposter
  115329. * @param impostor imposter to apply force
  115330. * @param force amount of force to be applied to the imposter
  115331. * @param contactPoint the location to apply the force on the imposter
  115332. */
  115333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115334. /**
  115335. * Creates a physics body using the plugin
  115336. * @param impostor the imposter to create the physics body on
  115337. */
  115338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115339. /**
  115340. * Removes the physics body from the imposter and disposes of the body's memory
  115341. * @param impostor imposter to remove the physics body from
  115342. */
  115343. removePhysicsBody(impostor: PhysicsImpostor): void;
  115344. /**
  115345. * Generates a joint
  115346. * @param impostorJoint the imposter joint to create the joint with
  115347. */
  115348. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115349. /**
  115350. * Removes a joint
  115351. * @param impostorJoint the imposter joint to remove the joint from
  115352. */
  115353. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115354. private _addMeshVerts;
  115355. /**
  115356. * Initialise the soft body vertices to match its object's (mesh) vertices
  115357. * Softbody vertices (nodes) are in world space and to match this
  115358. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  115359. * @param impostor to create the softbody for
  115360. */
  115361. private _softVertexData;
  115362. /**
  115363. * Create an impostor's soft body
  115364. * @param impostor to create the softbody for
  115365. */
  115366. private _createSoftbody;
  115367. /**
  115368. * Create cloth for an impostor
  115369. * @param impostor to create the softbody for
  115370. */
  115371. private _createCloth;
  115372. /**
  115373. * Create rope for an impostor
  115374. * @param impostor to create the softbody for
  115375. */
  115376. private _createRope;
  115377. private _addHullVerts;
  115378. private _createShape;
  115379. /**
  115380. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  115381. * @param impostor imposter containing the physics body and babylon object
  115382. */
  115383. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115384. /**
  115385. * Sets the babylon object's position/rotation from the physics body's position/rotation
  115386. * @param impostor imposter containing the physics body and babylon object
  115387. * @param newPosition new position
  115388. * @param newRotation new rotation
  115389. */
  115390. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115391. /**
  115392. * If this plugin is supported
  115393. * @returns true if its supported
  115394. */
  115395. isSupported(): boolean;
  115396. /**
  115397. * Sets the linear velocity of the physics body
  115398. * @param impostor imposter to set the velocity on
  115399. * @param velocity velocity to set
  115400. */
  115401. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115402. /**
  115403. * Sets the angular velocity of the physics body
  115404. * @param impostor imposter to set the velocity on
  115405. * @param velocity velocity to set
  115406. */
  115407. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115408. /**
  115409. * gets the linear velocity
  115410. * @param impostor imposter to get linear velocity from
  115411. * @returns linear velocity
  115412. */
  115413. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115414. /**
  115415. * gets the angular velocity
  115416. * @param impostor imposter to get angular velocity from
  115417. * @returns angular velocity
  115418. */
  115419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115420. /**
  115421. * Sets the mass of physics body
  115422. * @param impostor imposter to set the mass on
  115423. * @param mass mass to set
  115424. */
  115425. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115426. /**
  115427. * Gets the mass of the physics body
  115428. * @param impostor imposter to get the mass from
  115429. * @returns mass
  115430. */
  115431. getBodyMass(impostor: PhysicsImpostor): number;
  115432. /**
  115433. * Gets friction of the impostor
  115434. * @param impostor impostor to get friction from
  115435. * @returns friction value
  115436. */
  115437. getBodyFriction(impostor: PhysicsImpostor): number;
  115438. /**
  115439. * Sets friction of the impostor
  115440. * @param impostor impostor to set friction on
  115441. * @param friction friction value
  115442. */
  115443. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115444. /**
  115445. * Gets restitution of the impostor
  115446. * @param impostor impostor to get restitution from
  115447. * @returns restitution value
  115448. */
  115449. getBodyRestitution(impostor: PhysicsImpostor): number;
  115450. /**
  115451. * Sets resitution of the impostor
  115452. * @param impostor impostor to set resitution on
  115453. * @param restitution resitution value
  115454. */
  115455. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115456. /**
  115457. * Gets pressure inside the impostor
  115458. * @param impostor impostor to get pressure from
  115459. * @returns pressure value
  115460. */
  115461. getBodyPressure(impostor: PhysicsImpostor): number;
  115462. /**
  115463. * Sets pressure inside a soft body impostor
  115464. * Cloth and rope must remain 0 pressure
  115465. * @param impostor impostor to set pressure on
  115466. * @param pressure pressure value
  115467. */
  115468. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115469. /**
  115470. * Gets stiffness of the impostor
  115471. * @param impostor impostor to get stiffness from
  115472. * @returns pressure value
  115473. */
  115474. getBodyStiffness(impostor: PhysicsImpostor): number;
  115475. /**
  115476. * Sets stiffness of the impostor
  115477. * @param impostor impostor to set stiffness on
  115478. * @param stiffness stiffness value from 0 to 1
  115479. */
  115480. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115481. /**
  115482. * Gets velocityIterations of the impostor
  115483. * @param impostor impostor to get velocity iterations from
  115484. * @returns velocityIterations value
  115485. */
  115486. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115487. /**
  115488. * Sets velocityIterations of the impostor
  115489. * @param impostor impostor to set velocity iterations on
  115490. * @param velocityIterations velocityIterations value
  115491. */
  115492. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115493. /**
  115494. * Gets positionIterations of the impostor
  115495. * @param impostor impostor to get position iterations from
  115496. * @returns positionIterations value
  115497. */
  115498. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115499. /**
  115500. * Sets positionIterations of the impostor
  115501. * @param impostor impostor to set position on
  115502. * @param positionIterations positionIterations value
  115503. */
  115504. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115505. /**
  115506. * Append an anchor to a cloth object
  115507. * @param impostor is the cloth impostor to add anchor to
  115508. * @param otherImpostor is the rigid impostor to anchor to
  115509. * @param width ratio across width from 0 to 1
  115510. * @param height ratio up height from 0 to 1
  115511. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115512. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115513. */
  115514. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115515. /**
  115516. * Append an hook to a rope object
  115517. * @param impostor is the rope impostor to add hook to
  115518. * @param otherImpostor is the rigid impostor to hook to
  115519. * @param length ratio along the rope from 0 to 1
  115520. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115521. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115522. */
  115523. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115524. /**
  115525. * Sleeps the physics body and stops it from being active
  115526. * @param impostor impostor to sleep
  115527. */
  115528. sleepBody(impostor: PhysicsImpostor): void;
  115529. /**
  115530. * Activates the physics body
  115531. * @param impostor impostor to activate
  115532. */
  115533. wakeUpBody(impostor: PhysicsImpostor): void;
  115534. /**
  115535. * Updates the distance parameters of the joint
  115536. * @param joint joint to update
  115537. * @param maxDistance maximum distance of the joint
  115538. * @param minDistance minimum distance of the joint
  115539. */
  115540. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115541. /**
  115542. * Sets a motor on the joint
  115543. * @param joint joint to set motor on
  115544. * @param speed speed of the motor
  115545. * @param maxForce maximum force of the motor
  115546. * @param motorIndex index of the motor
  115547. */
  115548. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115549. /**
  115550. * Sets the motors limit
  115551. * @param joint joint to set limit on
  115552. * @param upperLimit upper limit
  115553. * @param lowerLimit lower limit
  115554. */
  115555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115556. /**
  115557. * Syncs the position and rotation of a mesh with the impostor
  115558. * @param mesh mesh to sync
  115559. * @param impostor impostor to update the mesh with
  115560. */
  115561. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115562. /**
  115563. * Gets the radius of the impostor
  115564. * @param impostor impostor to get radius from
  115565. * @returns the radius
  115566. */
  115567. getRadius(impostor: PhysicsImpostor): number;
  115568. /**
  115569. * Gets the box size of the impostor
  115570. * @param impostor impostor to get box size from
  115571. * @param result the resulting box size
  115572. */
  115573. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115574. /**
  115575. * Disposes of the impostor
  115576. */
  115577. dispose(): void;
  115578. /**
  115579. * Does a raycast in the physics world
  115580. * @param from when should the ray start?
  115581. * @param to when should the ray end?
  115582. * @returns PhysicsRaycastResult
  115583. */
  115584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115585. }
  115586. }
  115587. declare module BABYLON {
  115588. interface AbstractScene {
  115589. /**
  115590. * The list of reflection probes added to the scene
  115591. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115592. */
  115593. reflectionProbes: Array<ReflectionProbe>;
  115594. /**
  115595. * Removes the given reflection probe from this scene.
  115596. * @param toRemove The reflection probe to remove
  115597. * @returns The index of the removed reflection probe
  115598. */
  115599. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115600. /**
  115601. * Adds the given reflection probe to this scene.
  115602. * @param newReflectionProbe The reflection probe to add
  115603. */
  115604. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115605. }
  115606. /**
  115607. * Class used to generate realtime reflection / refraction cube textures
  115608. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115609. */
  115610. export class ReflectionProbe {
  115611. /** defines the name of the probe */
  115612. name: string;
  115613. private _scene;
  115614. private _renderTargetTexture;
  115615. private _projectionMatrix;
  115616. private _viewMatrix;
  115617. private _target;
  115618. private _add;
  115619. private _attachedMesh;
  115620. private _invertYAxis;
  115621. /** Gets or sets probe position (center of the cube map) */
  115622. position: Vector3;
  115623. /**
  115624. * Creates a new reflection probe
  115625. * @param name defines the name of the probe
  115626. * @param size defines the texture resolution (for each face)
  115627. * @param scene defines the hosting scene
  115628. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115629. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115630. */
  115631. constructor(
  115632. /** defines the name of the probe */
  115633. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115634. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115635. samples: number;
  115636. /** Gets or sets the refresh rate to use (on every frame by default) */
  115637. refreshRate: number;
  115638. /**
  115639. * Gets the hosting scene
  115640. * @returns a Scene
  115641. */
  115642. getScene(): Scene;
  115643. /** Gets the internal CubeTexture used to render to */
  115644. readonly cubeTexture: RenderTargetTexture;
  115645. /** Gets the list of meshes to render */
  115646. readonly renderList: Nullable<AbstractMesh[]>;
  115647. /**
  115648. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115649. * @param mesh defines the mesh to attach to
  115650. */
  115651. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115652. /**
  115653. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115654. * @param renderingGroupId The rendering group id corresponding to its index
  115655. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115656. */
  115657. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115658. /**
  115659. * Clean all associated resources
  115660. */
  115661. dispose(): void;
  115662. /**
  115663. * Converts the reflection probe information to a readable string for debug purpose.
  115664. * @param fullDetails Supports for multiple levels of logging within scene loading
  115665. * @returns the human readable reflection probe info
  115666. */
  115667. toString(fullDetails?: boolean): string;
  115668. /**
  115669. * Get the class name of the relfection probe.
  115670. * @returns "ReflectionProbe"
  115671. */
  115672. getClassName(): string;
  115673. /**
  115674. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115675. * @returns The JSON representation of the texture
  115676. */
  115677. serialize(): any;
  115678. /**
  115679. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115680. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115681. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115682. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115683. * @returns The parsed reflection probe if successful
  115684. */
  115685. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115686. }
  115687. }
  115688. declare module BABYLON {
  115689. /** @hidden */
  115690. export var _BabylonLoaderRegistered: boolean;
  115691. }
  115692. declare module BABYLON {
  115693. /**
  115694. * The Physically based simple base material of BJS.
  115695. *
  115696. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115697. * It is used as the base class for both the specGloss and metalRough conventions.
  115698. */
  115699. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115700. /**
  115701. * Number of Simultaneous lights allowed on the material.
  115702. */
  115703. maxSimultaneousLights: number;
  115704. /**
  115705. * If sets to true, disables all the lights affecting the material.
  115706. */
  115707. disableLighting: boolean;
  115708. /**
  115709. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115710. */
  115711. environmentTexture: BaseTexture;
  115712. /**
  115713. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115714. */
  115715. invertNormalMapX: boolean;
  115716. /**
  115717. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115718. */
  115719. invertNormalMapY: boolean;
  115720. /**
  115721. * Normal map used in the model.
  115722. */
  115723. normalTexture: BaseTexture;
  115724. /**
  115725. * Emissivie color used to self-illuminate the model.
  115726. */
  115727. emissiveColor: Color3;
  115728. /**
  115729. * Emissivie texture used to self-illuminate the model.
  115730. */
  115731. emissiveTexture: BaseTexture;
  115732. /**
  115733. * Occlusion Channel Strenght.
  115734. */
  115735. occlusionStrength: number;
  115736. /**
  115737. * Occlusion Texture of the material (adding extra occlusion effects).
  115738. */
  115739. occlusionTexture: BaseTexture;
  115740. /**
  115741. * Defines the alpha limits in alpha test mode.
  115742. */
  115743. alphaCutOff: number;
  115744. /**
  115745. * Gets the current double sided mode.
  115746. */
  115747. /**
  115748. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115749. */
  115750. doubleSided: boolean;
  115751. /**
  115752. * Stores the pre-calculated light information of a mesh in a texture.
  115753. */
  115754. lightmapTexture: BaseTexture;
  115755. /**
  115756. * If true, the light map contains occlusion information instead of lighting info.
  115757. */
  115758. useLightmapAsShadowmap: boolean;
  115759. /**
  115760. * Instantiates a new PBRMaterial instance.
  115761. *
  115762. * @param name The material name
  115763. * @param scene The scene the material will be use in.
  115764. */
  115765. constructor(name: string, scene: Scene);
  115766. getClassName(): string;
  115767. }
  115768. }
  115769. declare module BABYLON {
  115770. /**
  115771. * The PBR material of BJS following the metal roughness convention.
  115772. *
  115773. * This fits to the PBR convention in the GLTF definition:
  115774. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115775. */
  115776. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115777. /**
  115778. * The base color has two different interpretations depending on the value of metalness.
  115779. * When the material is a metal, the base color is the specific measured reflectance value
  115780. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115781. * of the material.
  115782. */
  115783. baseColor: Color3;
  115784. /**
  115785. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115786. * well as opacity information in the alpha channel.
  115787. */
  115788. baseTexture: BaseTexture;
  115789. /**
  115790. * Specifies the metallic scalar value of the material.
  115791. * Can also be used to scale the metalness values of the metallic texture.
  115792. */
  115793. metallic: number;
  115794. /**
  115795. * Specifies the roughness scalar value of the material.
  115796. * Can also be used to scale the roughness values of the metallic texture.
  115797. */
  115798. roughness: number;
  115799. /**
  115800. * Texture containing both the metallic value in the B channel and the
  115801. * roughness value in the G channel to keep better precision.
  115802. */
  115803. metallicRoughnessTexture: BaseTexture;
  115804. /**
  115805. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115806. *
  115807. * @param name The material name
  115808. * @param scene The scene the material will be use in.
  115809. */
  115810. constructor(name: string, scene: Scene);
  115811. /**
  115812. * Return the currrent class name of the material.
  115813. */
  115814. getClassName(): string;
  115815. /**
  115816. * Makes a duplicate of the current material.
  115817. * @param name - name to use for the new material.
  115818. */
  115819. clone(name: string): PBRMetallicRoughnessMaterial;
  115820. /**
  115821. * Serialize the material to a parsable JSON object.
  115822. */
  115823. serialize(): any;
  115824. /**
  115825. * Parses a JSON object correponding to the serialize function.
  115826. */
  115827. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115828. }
  115829. }
  115830. declare module BABYLON {
  115831. /**
  115832. * The PBR material of BJS following the specular glossiness convention.
  115833. *
  115834. * This fits to the PBR convention in the GLTF definition:
  115835. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115836. */
  115837. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115838. /**
  115839. * Specifies the diffuse color of the material.
  115840. */
  115841. diffuseColor: Color3;
  115842. /**
  115843. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115844. * channel.
  115845. */
  115846. diffuseTexture: BaseTexture;
  115847. /**
  115848. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115849. */
  115850. specularColor: Color3;
  115851. /**
  115852. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115853. */
  115854. glossiness: number;
  115855. /**
  115856. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115857. */
  115858. specularGlossinessTexture: BaseTexture;
  115859. /**
  115860. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115861. *
  115862. * @param name The material name
  115863. * @param scene The scene the material will be use in.
  115864. */
  115865. constructor(name: string, scene: Scene);
  115866. /**
  115867. * Return the currrent class name of the material.
  115868. */
  115869. getClassName(): string;
  115870. /**
  115871. * Makes a duplicate of the current material.
  115872. * @param name - name to use for the new material.
  115873. */
  115874. clone(name: string): PBRSpecularGlossinessMaterial;
  115875. /**
  115876. * Serialize the material to a parsable JSON object.
  115877. */
  115878. serialize(): any;
  115879. /**
  115880. * Parses a JSON object correponding to the serialize function.
  115881. */
  115882. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115883. }
  115884. }
  115885. declare module BABYLON {
  115886. /**
  115887. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115888. * It can help converting any input color in a desired output one. This can then be used to create effects
  115889. * from sepia, black and white to sixties or futuristic rendering...
  115890. *
  115891. * The only supported format is currently 3dl.
  115892. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115893. */
  115894. export class ColorGradingTexture extends BaseTexture {
  115895. /**
  115896. * The current texture matrix. (will always be identity in color grading texture)
  115897. */
  115898. private _textureMatrix;
  115899. /**
  115900. * The texture URL.
  115901. */
  115902. url: string;
  115903. /**
  115904. * Empty line regex stored for GC.
  115905. */
  115906. private static _noneEmptyLineRegex;
  115907. private _engine;
  115908. /**
  115909. * Instantiates a ColorGradingTexture from the following parameters.
  115910. *
  115911. * @param url The location of the color gradind data (currently only supporting 3dl)
  115912. * @param scene The scene the texture will be used in
  115913. */
  115914. constructor(url: string, scene: Scene);
  115915. /**
  115916. * Returns the texture matrix used in most of the material.
  115917. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115918. */
  115919. getTextureMatrix(): Matrix;
  115920. /**
  115921. * Occurs when the file being loaded is a .3dl LUT file.
  115922. */
  115923. private load3dlTexture;
  115924. /**
  115925. * Starts the loading process of the texture.
  115926. */
  115927. private loadTexture;
  115928. /**
  115929. * Clones the color gradind texture.
  115930. */
  115931. clone(): ColorGradingTexture;
  115932. /**
  115933. * Called during delayed load for textures.
  115934. */
  115935. delayLoad(): void;
  115936. /**
  115937. * Parses a color grading texture serialized by Babylon.
  115938. * @param parsedTexture The texture information being parsedTexture
  115939. * @param scene The scene to load the texture in
  115940. * @param rootUrl The root url of the data assets to load
  115941. * @return A color gradind texture
  115942. */
  115943. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115944. /**
  115945. * Serializes the LUT texture to json format.
  115946. */
  115947. serialize(): any;
  115948. }
  115949. }
  115950. declare module BABYLON {
  115951. /**
  115952. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115953. */
  115954. export class EquiRectangularCubeTexture extends BaseTexture {
  115955. /** The six faces of the cube. */
  115956. private static _FacesMapping;
  115957. private _noMipmap;
  115958. private _onLoad;
  115959. private _onError;
  115960. /** The size of the cubemap. */
  115961. private _size;
  115962. /** The buffer of the image. */
  115963. private _buffer;
  115964. /** The width of the input image. */
  115965. private _width;
  115966. /** The height of the input image. */
  115967. private _height;
  115968. /** The URL to the image. */
  115969. url: string;
  115970. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115971. coordinatesMode: number;
  115972. /**
  115973. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115974. * @param url The location of the image
  115975. * @param scene The scene the texture will be used in
  115976. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115977. * @param noMipmap Forces to not generate the mipmap if true
  115978. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115979. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115980. * @param onLoad — defines a callback called when texture is loaded
  115981. * @param onError — defines a callback called if there is an error
  115982. */
  115983. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115984. /**
  115985. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115986. */
  115987. private loadImage;
  115988. /**
  115989. * Convert the image buffer into a cubemap and create a CubeTexture.
  115990. */
  115991. private loadTexture;
  115992. /**
  115993. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115994. * @param buffer The ArrayBuffer that should be converted.
  115995. * @returns The buffer as Float32Array.
  115996. */
  115997. private getFloat32ArrayFromArrayBuffer;
  115998. /**
  115999. * Get the current class name of the texture useful for serialization or dynamic coding.
  116000. * @returns "EquiRectangularCubeTexture"
  116001. */
  116002. getClassName(): string;
  116003. /**
  116004. * Create a clone of the current EquiRectangularCubeTexture and return it.
  116005. * @returns A clone of the current EquiRectangularCubeTexture.
  116006. */
  116007. clone(): EquiRectangularCubeTexture;
  116008. }
  116009. }
  116010. declare module BABYLON {
  116011. /**
  116012. * Based on jsTGALoader - Javascript loader for TGA file
  116013. * By Vincent Thibault
  116014. * @see http://blog.robrowser.com/javascript-tga-loader.html
  116015. */
  116016. export class TGATools {
  116017. private static _TYPE_INDEXED;
  116018. private static _TYPE_RGB;
  116019. private static _TYPE_GREY;
  116020. private static _TYPE_RLE_INDEXED;
  116021. private static _TYPE_RLE_RGB;
  116022. private static _TYPE_RLE_GREY;
  116023. private static _ORIGIN_MASK;
  116024. private static _ORIGIN_SHIFT;
  116025. private static _ORIGIN_BL;
  116026. private static _ORIGIN_BR;
  116027. private static _ORIGIN_UL;
  116028. private static _ORIGIN_UR;
  116029. /**
  116030. * Gets the header of a TGA file
  116031. * @param data defines the TGA data
  116032. * @returns the header
  116033. */
  116034. static GetTGAHeader(data: Uint8Array): any;
  116035. /**
  116036. * Uploads TGA content to a Babylon Texture
  116037. * @hidden
  116038. */
  116039. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  116040. /** @hidden */
  116041. 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;
  116042. /** @hidden */
  116043. 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;
  116044. /** @hidden */
  116045. 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;
  116046. /** @hidden */
  116047. 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;
  116048. /** @hidden */
  116049. 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;
  116050. /** @hidden */
  116051. 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;
  116052. }
  116053. }
  116054. declare module BABYLON {
  116055. /**
  116056. * Implementation of the TGA Texture Loader.
  116057. * @hidden
  116058. */
  116059. export class _TGATextureLoader implements IInternalTextureLoader {
  116060. /**
  116061. * Defines wether the loader supports cascade loading the different faces.
  116062. */
  116063. readonly supportCascades: boolean;
  116064. /**
  116065. * This returns if the loader support the current file information.
  116066. * @param extension defines the file extension of the file being loaded
  116067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116068. * @param fallback defines the fallback internal texture if any
  116069. * @param isBase64 defines whether the texture is encoded as a base64
  116070. * @param isBuffer defines whether the texture data are stored as a buffer
  116071. * @returns true if the loader can load the specified file
  116072. */
  116073. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116074. /**
  116075. * Transform the url before loading if required.
  116076. * @param rootUrl the url of the texture
  116077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116078. * @returns the transformed texture
  116079. */
  116080. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116081. /**
  116082. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116083. * @param rootUrl the url of the texture
  116084. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116085. * @returns the fallback texture
  116086. */
  116087. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116088. /**
  116089. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116090. * @param data contains the texture data
  116091. * @param texture defines the BabylonJS internal texture
  116092. * @param createPolynomials will be true if polynomials have been requested
  116093. * @param onLoad defines the callback to trigger once the texture is ready
  116094. * @param onError defines the callback to trigger in case of error
  116095. */
  116096. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116097. /**
  116098. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116099. * @param data contains the texture data
  116100. * @param texture defines the BabylonJS internal texture
  116101. * @param callback defines the method to call once ready to upload
  116102. */
  116103. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116104. }
  116105. }
  116106. declare module BABYLON {
  116107. /**
  116108. * Info about the .basis files
  116109. */
  116110. class BasisFileInfo {
  116111. /**
  116112. * If the file has alpha
  116113. */
  116114. hasAlpha: boolean;
  116115. /**
  116116. * Info about each image of the basis file
  116117. */
  116118. images: Array<{
  116119. levels: Array<{
  116120. width: number;
  116121. height: number;
  116122. transcodedPixels: ArrayBufferView;
  116123. }>;
  116124. }>;
  116125. }
  116126. /**
  116127. * Result of transcoding a basis file
  116128. */
  116129. class TranscodeResult {
  116130. /**
  116131. * Info about the .basis file
  116132. */
  116133. fileInfo: BasisFileInfo;
  116134. /**
  116135. * Format to use when loading the file
  116136. */
  116137. format: number;
  116138. }
  116139. /**
  116140. * Configuration options for the Basis transcoder
  116141. */
  116142. export class BasisTranscodeConfiguration {
  116143. /**
  116144. * Supported compression formats used to determine the supported output format of the transcoder
  116145. */
  116146. supportedCompressionFormats?: {
  116147. /**
  116148. * etc1 compression format
  116149. */
  116150. etc1?: boolean;
  116151. /**
  116152. * s3tc compression format
  116153. */
  116154. s3tc?: boolean;
  116155. /**
  116156. * pvrtc compression format
  116157. */
  116158. pvrtc?: boolean;
  116159. /**
  116160. * etc2 compression format
  116161. */
  116162. etc2?: boolean;
  116163. };
  116164. /**
  116165. * If mipmap levels should be loaded for transcoded images (Default: true)
  116166. */
  116167. loadMipmapLevels?: boolean;
  116168. /**
  116169. * Index of a single image to load (Default: all images)
  116170. */
  116171. loadSingleImage?: number;
  116172. }
  116173. /**
  116174. * Used to load .Basis files
  116175. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  116176. */
  116177. export class BasisTools {
  116178. private static _IgnoreSupportedFormats;
  116179. /**
  116180. * URL to use when loading the basis transcoder
  116181. */
  116182. static JSModuleURL: string;
  116183. /**
  116184. * URL to use when loading the wasm module for the transcoder
  116185. */
  116186. static WasmModuleURL: string;
  116187. /**
  116188. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  116189. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  116190. * @returns internal format corresponding to the Basis format
  116191. */
  116192. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  116193. private static _WorkerPromise;
  116194. private static _Worker;
  116195. private static _actionId;
  116196. private static _CreateWorkerAsync;
  116197. /**
  116198. * Transcodes a loaded image file to compressed pixel data
  116199. * @param imageData image data to transcode
  116200. * @param config configuration options for the transcoding
  116201. * @returns a promise resulting in the transcoded image
  116202. */
  116203. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  116204. /**
  116205. * Loads a texture from the transcode result
  116206. * @param texture texture load to
  116207. * @param transcodeResult the result of transcoding the basis file to load from
  116208. */
  116209. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  116210. }
  116211. }
  116212. declare module BABYLON {
  116213. /**
  116214. * Loader for .basis file format
  116215. */
  116216. export class _BasisTextureLoader implements IInternalTextureLoader {
  116217. /**
  116218. * Defines whether the loader supports cascade loading the different faces.
  116219. */
  116220. readonly supportCascades: boolean;
  116221. /**
  116222. * This returns if the loader support the current file information.
  116223. * @param extension defines the file extension of the file being loaded
  116224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116225. * @param fallback defines the fallback internal texture if any
  116226. * @param isBase64 defines whether the texture is encoded as a base64
  116227. * @param isBuffer defines whether the texture data are stored as a buffer
  116228. * @returns true if the loader can load the specified file
  116229. */
  116230. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116231. /**
  116232. * Transform the url before loading if required.
  116233. * @param rootUrl the url of the texture
  116234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116235. * @returns the transformed texture
  116236. */
  116237. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116238. /**
  116239. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116240. * @param rootUrl the url of the texture
  116241. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116242. * @returns the fallback texture
  116243. */
  116244. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116245. /**
  116246. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  116247. * @param data contains the texture data
  116248. * @param texture defines the BabylonJS internal texture
  116249. * @param createPolynomials will be true if polynomials have been requested
  116250. * @param onLoad defines the callback to trigger once the texture is ready
  116251. * @param onError defines the callback to trigger in case of error
  116252. */
  116253. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116254. /**
  116255. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116256. * @param data contains the texture data
  116257. * @param texture defines the BabylonJS internal texture
  116258. * @param callback defines the method to call once ready to upload
  116259. */
  116260. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116261. }
  116262. }
  116263. declare module BABYLON {
  116264. /**
  116265. * 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.
  116266. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116267. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116268. */
  116269. export class CustomProceduralTexture extends ProceduralTexture {
  116270. private _animate;
  116271. private _time;
  116272. private _config;
  116273. private _texturePath;
  116274. /**
  116275. * Instantiates a new Custom Procedural Texture.
  116276. * 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.
  116277. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116278. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116279. * @param name Define the name of the texture
  116280. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  116281. * @param size Define the size of the texture to create
  116282. * @param scene Define the scene the texture belongs to
  116283. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  116284. * @param generateMipMaps Define if the texture should creates mip maps or not
  116285. */
  116286. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116287. private _loadJson;
  116288. /**
  116289. * Is the texture ready to be used ? (rendered at least once)
  116290. * @returns true if ready, otherwise, false.
  116291. */
  116292. isReady(): boolean;
  116293. /**
  116294. * Render the texture to its associated render target.
  116295. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  116296. */
  116297. render(useCameraPostProcess?: boolean): void;
  116298. /**
  116299. * Update the list of dependant textures samplers in the shader.
  116300. */
  116301. updateTextures(): void;
  116302. /**
  116303. * Update the uniform values of the procedural texture in the shader.
  116304. */
  116305. updateShaderUniforms(): void;
  116306. /**
  116307. * Define if the texture animates or not.
  116308. */
  116309. animate: boolean;
  116310. }
  116311. }
  116312. declare module BABYLON {
  116313. /** @hidden */
  116314. export var noisePixelShader: {
  116315. name: string;
  116316. shader: string;
  116317. };
  116318. }
  116319. declare module BABYLON {
  116320. /**
  116321. * Class used to generate noise procedural textures
  116322. */
  116323. export class NoiseProceduralTexture extends ProceduralTexture {
  116324. private _time;
  116325. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  116326. brightness: number;
  116327. /** Defines the number of octaves to process */
  116328. octaves: number;
  116329. /** Defines the level of persistence (0.8 by default) */
  116330. persistence: number;
  116331. /** Gets or sets animation speed factor (default is 1) */
  116332. animationSpeedFactor: number;
  116333. /**
  116334. * Creates a new NoiseProceduralTexture
  116335. * @param name defines the name fo the texture
  116336. * @param size defines the size of the texture (default is 256)
  116337. * @param scene defines the hosting scene
  116338. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  116339. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  116340. */
  116341. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116342. private _updateShaderUniforms;
  116343. protected _getDefines(): string;
  116344. /** Generate the current state of the procedural texture */
  116345. render(useCameraPostProcess?: boolean): void;
  116346. /**
  116347. * Serializes this noise procedural texture
  116348. * @returns a serialized noise procedural texture object
  116349. */
  116350. serialize(): any;
  116351. /**
  116352. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  116353. * @param parsedTexture defines parsed texture data
  116354. * @param scene defines the current scene
  116355. * @param rootUrl defines the root URL containing noise procedural texture information
  116356. * @returns a parsed NoiseProceduralTexture
  116357. */
  116358. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  116359. }
  116360. }
  116361. declare module BABYLON {
  116362. /**
  116363. * Raw cube texture where the raw buffers are passed in
  116364. */
  116365. export class RawCubeTexture extends CubeTexture {
  116366. /**
  116367. * Creates a cube texture where the raw buffers are passed in.
  116368. * @param scene defines the scene the texture is attached to
  116369. * @param data defines the array of data to use to create each face
  116370. * @param size defines the size of the textures
  116371. * @param format defines the format of the data
  116372. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  116373. * @param generateMipMaps defines if the engine should generate the mip levels
  116374. * @param invertY defines if data must be stored with Y axis inverted
  116375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  116376. * @param compression defines the compression used (null by default)
  116377. */
  116378. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  116379. /**
  116380. * Updates the raw cube texture.
  116381. * @param data defines the data to store
  116382. * @param format defines the data format
  116383. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  116384. * @param invertY defines if data must be stored with Y axis inverted
  116385. * @param compression defines the compression used (null by default)
  116386. * @param level defines which level of the texture to update
  116387. */
  116388. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  116389. /**
  116390. * Updates a raw cube texture with RGBD encoded data.
  116391. * @param data defines the array of data [mipmap][face] to use to create each face
  116392. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  116393. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  116394. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  116395. * @returns a promsie that resolves when the operation is complete
  116396. */
  116397. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  116398. /**
  116399. * Clones the raw cube texture.
  116400. * @return a new cube texture
  116401. */
  116402. clone(): CubeTexture;
  116403. /** @hidden */
  116404. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  116405. }
  116406. }
  116407. declare module BABYLON {
  116408. /**
  116409. * Class used to store 3D textures containing user data
  116410. */
  116411. export class RawTexture3D extends Texture {
  116412. /** Gets or sets the texture format to use */
  116413. format: number;
  116414. private _engine;
  116415. /**
  116416. * Create a new RawTexture3D
  116417. * @param data defines the data of the texture
  116418. * @param width defines the width of the texture
  116419. * @param height defines the height of the texture
  116420. * @param depth defines the depth of the texture
  116421. * @param format defines the texture format to use
  116422. * @param scene defines the hosting scene
  116423. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  116424. * @param invertY defines if texture must be stored with Y axis inverted
  116425. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  116426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  116427. */
  116428. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  116429. /** Gets or sets the texture format to use */
  116430. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  116431. /**
  116432. * Update the texture with new data
  116433. * @param data defines the data to store in the texture
  116434. */
  116435. update(data: ArrayBufferView): void;
  116436. }
  116437. }
  116438. declare module BABYLON {
  116439. /**
  116440. * Creates a refraction texture used by refraction channel of the standard material.
  116441. * It is like a mirror but to see through a material.
  116442. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116443. */
  116444. export class RefractionTexture extends RenderTargetTexture {
  116445. /**
  116446. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  116447. * 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.
  116448. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116449. */
  116450. refractionPlane: Plane;
  116451. /**
  116452. * Define how deep under the surface we should see.
  116453. */
  116454. depth: number;
  116455. /**
  116456. * Creates a refraction texture used by refraction channel of the standard material.
  116457. * It is like a mirror but to see through a material.
  116458. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116459. * @param name Define the texture name
  116460. * @param size Define the size of the underlying texture
  116461. * @param scene Define the scene the refraction belongs to
  116462. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116463. */
  116464. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116465. /**
  116466. * Clone the refraction texture.
  116467. * @returns the cloned texture
  116468. */
  116469. clone(): RefractionTexture;
  116470. /**
  116471. * Serialize the texture to a JSON representation you could use in Parse later on
  116472. * @returns the serialized JSON representation
  116473. */
  116474. serialize(): any;
  116475. }
  116476. }
  116477. declare module BABYLON {
  116478. /**
  116479. * Defines the options related to the creation of an HtmlElementTexture
  116480. */
  116481. export interface IHtmlElementTextureOptions {
  116482. /**
  116483. * Defines wether mip maps should be created or not.
  116484. */
  116485. generateMipMaps?: boolean;
  116486. /**
  116487. * Defines the sampling mode of the texture.
  116488. */
  116489. samplingMode?: number;
  116490. /**
  116491. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116492. */
  116493. engine: Nullable<Engine>;
  116494. /**
  116495. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116496. */
  116497. scene: Nullable<Scene>;
  116498. }
  116499. /**
  116500. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116501. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116502. * is automatically managed.
  116503. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116504. * in your application.
  116505. *
  116506. * As the update is not automatic, you need to call them manually.
  116507. */
  116508. export class HtmlElementTexture extends BaseTexture {
  116509. /**
  116510. * The texture URL.
  116511. */
  116512. element: HTMLVideoElement | HTMLCanvasElement;
  116513. private static readonly DefaultOptions;
  116514. private _textureMatrix;
  116515. private _engine;
  116516. private _isVideo;
  116517. private _generateMipMaps;
  116518. private _samplingMode;
  116519. /**
  116520. * Instantiates a HtmlElementTexture from the following parameters.
  116521. *
  116522. * @param name Defines the name of the texture
  116523. * @param element Defines the video or canvas the texture is filled with
  116524. * @param options Defines the other none mandatory texture creation options
  116525. */
  116526. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116527. private _createInternalTexture;
  116528. /**
  116529. * Returns the texture matrix used in most of the material.
  116530. */
  116531. getTextureMatrix(): Matrix;
  116532. /**
  116533. * Updates the content of the texture.
  116534. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116535. */
  116536. update(invertY?: Nullable<boolean>): void;
  116537. }
  116538. }
  116539. declare module BABYLON {
  116540. /**
  116541. * Enum used to define the target of a block
  116542. */
  116543. export enum NodeMaterialBlockTargets {
  116544. /** Vertex shader */
  116545. Vertex = 1,
  116546. /** Fragment shader */
  116547. Fragment = 2,
  116548. /** Neutral */
  116549. Neutral = 4,
  116550. /** Vertex and Fragment */
  116551. VertexAndFragment = 3
  116552. }
  116553. }
  116554. declare module BABYLON {
  116555. /**
  116556. * Defines the kind of connection point for node based material
  116557. */
  116558. export enum NodeMaterialBlockConnectionPointTypes {
  116559. /** Float */
  116560. Float = 1,
  116561. /** Int */
  116562. Int = 2,
  116563. /** Vector2 */
  116564. Vector2 = 4,
  116565. /** Vector3 */
  116566. Vector3 = 8,
  116567. /** Vector4 */
  116568. Vector4 = 16,
  116569. /** Color3 */
  116570. Color3 = 32,
  116571. /** Color4 */
  116572. Color4 = 64,
  116573. /** Matrix */
  116574. Matrix = 128,
  116575. /** Detect type based on connection */
  116576. AutoDetect = 1024,
  116577. /** Output type that will be defined by input type */
  116578. BasedOnInput = 2048,
  116579. /** Output type that will be defined by inverting input type (color <-> vector) */
  116580. InvertInput = 4096
  116581. }
  116582. }
  116583. declare module BABYLON {
  116584. /**
  116585. * Root class for all node material optimizers
  116586. */
  116587. export class NodeMaterialOptimizer {
  116588. /**
  116589. * Function used to optimize a NodeMaterial graph
  116590. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116591. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116592. */
  116593. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116594. }
  116595. }
  116596. declare module BABYLON {
  116597. /**
  116598. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116599. */
  116600. export class TransformBlock extends NodeMaterialBlock {
  116601. /**
  116602. * Defines the value to use to complement W value to transform it to a Vector4
  116603. */
  116604. complementW: number;
  116605. /**
  116606. * Defines the value to use to complement z value to transform it to a Vector4
  116607. */
  116608. complementZ: number;
  116609. /**
  116610. * Creates a new TransformBlock
  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 vector input
  116621. */
  116622. readonly vector: NodeMaterialConnectionPoint;
  116623. /**
  116624. * Gets the output component
  116625. */
  116626. readonly output: NodeMaterialConnectionPoint;
  116627. /**
  116628. * Gets the matrix transform input
  116629. */
  116630. readonly transform: NodeMaterialConnectionPoint;
  116631. protected _buildBlock(state: NodeMaterialBuildState): this;
  116632. serialize(): any;
  116633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116634. }
  116635. }
  116636. declare module BABYLON {
  116637. /**
  116638. * Block used to output the vertex position
  116639. */
  116640. export class VertexOutputBlock extends NodeMaterialBlock {
  116641. /**
  116642. * Creates a new VertexOutputBlock
  116643. * @param name defines the block name
  116644. */
  116645. constructor(name: string);
  116646. /**
  116647. * Gets the current class name
  116648. * @returns the class name
  116649. */
  116650. getClassName(): string;
  116651. /**
  116652. * Gets the vector input component
  116653. */
  116654. readonly vector: NodeMaterialConnectionPoint;
  116655. protected _buildBlock(state: NodeMaterialBuildState): this;
  116656. }
  116657. }
  116658. declare module BABYLON {
  116659. /**
  116660. * Block used to output the final color
  116661. */
  116662. export class FragmentOutputBlock extends NodeMaterialBlock {
  116663. /**
  116664. * Create a new FragmentOutputBlock
  116665. * @param name defines the block name
  116666. */
  116667. constructor(name: string);
  116668. /**
  116669. * Gets the current class name
  116670. * @returns the class name
  116671. */
  116672. getClassName(): string;
  116673. /**
  116674. * Gets the rgba input component
  116675. */
  116676. readonly rgba: NodeMaterialConnectionPoint;
  116677. /**
  116678. * Gets the rgb input component
  116679. */
  116680. readonly rgb: NodeMaterialConnectionPoint;
  116681. /**
  116682. * Gets the a input component
  116683. */
  116684. readonly a: NodeMaterialConnectionPoint;
  116685. protected _buildBlock(state: NodeMaterialBuildState): this;
  116686. }
  116687. }
  116688. declare module BABYLON {
  116689. /**
  116690. * Enum used to define well known values e.g. values automatically provided by the system
  116691. */
  116692. export enum NodeMaterialWellKnownValues {
  116693. /** World */
  116694. World = 1,
  116695. /** View */
  116696. View = 2,
  116697. /** Projection */
  116698. Projection = 3,
  116699. /** ViewProjection */
  116700. ViewProjection = 4,
  116701. /** WorldView */
  116702. WorldView = 5,
  116703. /** WorldViewProjection */
  116704. WorldViewProjection = 6,
  116705. /** CameraPosition */
  116706. CameraPosition = 7,
  116707. /** Fog Color */
  116708. FogColor = 8
  116709. }
  116710. }
  116711. declare module BABYLON {
  116712. /**
  116713. * Block used to read a reflection texture from a sampler
  116714. */
  116715. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116716. private _define3DName;
  116717. private _defineCubicName;
  116718. private _defineExplicitName;
  116719. private _defineProjectionName;
  116720. private _defineLocalCubicName;
  116721. private _defineSphericalName;
  116722. private _definePlanarName;
  116723. private _defineEquirectangularName;
  116724. private _defineMirroredEquirectangularFixedName;
  116725. private _defineEquirectangularFixedName;
  116726. private _defineSkyboxName;
  116727. private _cubeSamplerName;
  116728. private _2DSamplerName;
  116729. private _positionUVWName;
  116730. private _directionWName;
  116731. private _reflectionCoordsName;
  116732. private _reflection2DCoordsName;
  116733. private _reflectionColorName;
  116734. private _reflectionMatrixName;
  116735. /**
  116736. * Gets or sets the texture associated with the node
  116737. */
  116738. texture: Nullable<BaseTexture>;
  116739. /**
  116740. * Create a new TextureBlock
  116741. * @param name defines the block name
  116742. */
  116743. constructor(name: string);
  116744. /**
  116745. * Gets the current class name
  116746. * @returns the class name
  116747. */
  116748. getClassName(): string;
  116749. /**
  116750. * Gets the world position input component
  116751. */
  116752. readonly position: NodeMaterialConnectionPoint;
  116753. /**
  116754. * Gets the world position input component
  116755. */
  116756. readonly worldPosition: NodeMaterialConnectionPoint;
  116757. /**
  116758. * Gets the world normal input component
  116759. */
  116760. readonly worldNormal: NodeMaterialConnectionPoint;
  116761. /**
  116762. * Gets the world input component
  116763. */
  116764. readonly world: NodeMaterialConnectionPoint;
  116765. /**
  116766. * Gets the camera (or eye) position component
  116767. */
  116768. readonly cameraPosition: NodeMaterialConnectionPoint;
  116769. /**
  116770. * Gets the view input component
  116771. */
  116772. readonly view: NodeMaterialConnectionPoint;
  116773. /**
  116774. * Gets the rgb output component
  116775. */
  116776. readonly rgb: NodeMaterialConnectionPoint;
  116777. /**
  116778. * Gets the r output component
  116779. */
  116780. readonly r: NodeMaterialConnectionPoint;
  116781. /**
  116782. * Gets the g output component
  116783. */
  116784. readonly g: NodeMaterialConnectionPoint;
  116785. /**
  116786. * Gets the b output component
  116787. */
  116788. readonly b: NodeMaterialConnectionPoint;
  116789. autoConfigure(): void;
  116790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116791. isReady(): boolean;
  116792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116793. private _injectVertexCode;
  116794. private _writeOutput;
  116795. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116796. serialize(): any;
  116797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116798. }
  116799. }
  116800. declare module BABYLON {
  116801. /**
  116802. * Interface used to configure the node material editor
  116803. */
  116804. export interface INodeMaterialEditorOptions {
  116805. /** Define the URl to load node editor script */
  116806. editorURL?: string;
  116807. }
  116808. /** @hidden */
  116809. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116810. /** BONES */
  116811. NUM_BONE_INFLUENCERS: number;
  116812. BonesPerMesh: number;
  116813. BONETEXTURE: boolean;
  116814. /** MORPH TARGETS */
  116815. MORPHTARGETS: boolean;
  116816. MORPHTARGETS_NORMAL: boolean;
  116817. MORPHTARGETS_TANGENT: boolean;
  116818. MORPHTARGETS_UV: boolean;
  116819. NUM_MORPH_INFLUENCERS: number;
  116820. /** IMAGE PROCESSING */
  116821. IMAGEPROCESSING: boolean;
  116822. VIGNETTE: boolean;
  116823. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116824. VIGNETTEBLENDMODEOPAQUE: boolean;
  116825. TONEMAPPING: boolean;
  116826. TONEMAPPING_ACES: boolean;
  116827. CONTRAST: boolean;
  116828. EXPOSURE: boolean;
  116829. COLORCURVES: boolean;
  116830. COLORGRADING: boolean;
  116831. COLORGRADING3D: boolean;
  116832. SAMPLER3DGREENDEPTH: boolean;
  116833. SAMPLER3DBGRMAP: boolean;
  116834. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116835. constructor();
  116836. setValue(name: string, value: boolean): void;
  116837. }
  116838. /**
  116839. * Class used to configure NodeMaterial
  116840. */
  116841. export interface INodeMaterialOptions {
  116842. /**
  116843. * Defines if blocks should emit comments
  116844. */
  116845. emitComments: boolean;
  116846. }
  116847. /**
  116848. * Class used to create a node based material built by assembling shader blocks
  116849. */
  116850. export class NodeMaterial extends PushMaterial {
  116851. private static _BuildIdGenerator;
  116852. private _options;
  116853. private _vertexCompilationState;
  116854. private _fragmentCompilationState;
  116855. private _sharedData;
  116856. private _buildId;
  116857. private _buildWasSuccessful;
  116858. private _cachedWorldViewMatrix;
  116859. private _cachedWorldViewProjectionMatrix;
  116860. private _optimizers;
  116861. private _animationFrame;
  116862. /** Define the URl to load node editor script */
  116863. static EditorURL: string;
  116864. private BJSNODEMATERIALEDITOR;
  116865. /** Get the inspector from bundle or global */
  116866. private _getGlobalNodeMaterialEditor;
  116867. /**
  116868. * 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)
  116869. */
  116870. ignoreAlpha: boolean;
  116871. /**
  116872. * Defines the maximum number of lights that can be used in the material
  116873. */
  116874. maxSimultaneousLights: number;
  116875. /**
  116876. * Observable raised when the material is built
  116877. */
  116878. onBuildObservable: Observable<NodeMaterial>;
  116879. /**
  116880. * Gets or sets the root nodes of the material vertex shader
  116881. */
  116882. _vertexOutputNodes: NodeMaterialBlock[];
  116883. /**
  116884. * Gets or sets the root nodes of the material fragment (pixel) shader
  116885. */
  116886. _fragmentOutputNodes: NodeMaterialBlock[];
  116887. /** Gets or sets options to control the node material overall behavior */
  116888. options: INodeMaterialOptions;
  116889. /**
  116890. * Default configuration related to image processing available in the standard Material.
  116891. */
  116892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116893. /**
  116894. * Gets the image processing configuration used either in this material.
  116895. */
  116896. /**
  116897. * Sets the Default image processing configuration used either in the this material.
  116898. *
  116899. * If sets to null, the scene one is in use.
  116900. */
  116901. imageProcessingConfiguration: ImageProcessingConfiguration;
  116902. /**
  116903. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116904. */
  116905. attachedBlocks: NodeMaterialBlock[];
  116906. /**
  116907. * Create a new node based material
  116908. * @param name defines the material name
  116909. * @param scene defines the hosting scene
  116910. * @param options defines creation option
  116911. */
  116912. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  116913. /**
  116914. * Gets the current class name of the material e.g. "NodeMaterial"
  116915. * @returns the class name
  116916. */
  116917. getClassName(): string;
  116918. /**
  116919. * Keep track of the image processing observer to allow dispose and replace.
  116920. */
  116921. private _imageProcessingObserver;
  116922. /**
  116923. * Attaches a new image processing configuration to the Standard Material.
  116924. * @param configuration
  116925. */
  116926. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116927. /**
  116928. * Get a block by its name
  116929. * @param name defines the name of the block to retrieve
  116930. * @returns the required block or null if not found
  116931. */
  116932. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  116933. /**
  116934. * Gets the list of input blocks attached to this material
  116935. * @returns an array of InputBlocks
  116936. */
  116937. getInputBlocks(): InputBlock[];
  116938. /**
  116939. * Adds a new optimizer to the list of optimizers
  116940. * @param optimizer defines the optimizers to add
  116941. * @returns the current material
  116942. */
  116943. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116944. /**
  116945. * Remove an optimizer from the list of optimizers
  116946. * @param optimizer defines the optimizers to remove
  116947. * @returns the current material
  116948. */
  116949. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116950. /**
  116951. * Add a new block to the list of output nodes
  116952. * @param node defines the node to add
  116953. * @returns the current material
  116954. */
  116955. addOutputNode(node: NodeMaterialBlock): this;
  116956. /**
  116957. * Remove a block from the list of root nodes
  116958. * @param node defines the node to remove
  116959. * @returns the current material
  116960. */
  116961. removeOutputNode(node: NodeMaterialBlock): this;
  116962. private _addVertexOutputNode;
  116963. private _removeVertexOutputNode;
  116964. private _addFragmentOutputNode;
  116965. private _removeFragmentOutputNode;
  116966. /**
  116967. * Specifies if the material will require alpha blending
  116968. * @returns a boolean specifying if alpha blending is needed
  116969. */
  116970. needAlphaBlending(): boolean;
  116971. /**
  116972. * Specifies if this material should be rendered in alpha test mode
  116973. * @returns a boolean specifying if an alpha test is needed.
  116974. */
  116975. needAlphaTesting(): boolean;
  116976. private _initializeBlock;
  116977. private _resetDualBlocks;
  116978. /**
  116979. * Build the material and generates the inner effect
  116980. * @param verbose defines if the build should log activity
  116981. */
  116982. build(verbose?: boolean): void;
  116983. /**
  116984. * Runs an otpimization phase to try to improve the shader code
  116985. */
  116986. optimize(): void;
  116987. private _prepareDefinesForAttributes;
  116988. /**
  116989. * Get if the submesh is ready to be used and all its information available.
  116990. * Child classes can use it to update shaders
  116991. * @param mesh defines the mesh to check
  116992. * @param subMesh defines which submesh to check
  116993. * @param useInstances specifies that instances should be used
  116994. * @returns a boolean indicating that the submesh is ready or not
  116995. */
  116996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116997. /**
  116998. * Get a string representing the shaders built by the current node graph
  116999. */
  117000. readonly compiledShaders: string;
  117001. /**
  117002. * Binds the world matrix to the material
  117003. * @param world defines the world transformation matrix
  117004. */
  117005. bindOnlyWorldMatrix(world: Matrix): void;
  117006. /**
  117007. * Binds the submesh to this material by preparing the effect and shader to draw
  117008. * @param world defines the world transformation matrix
  117009. * @param mesh defines the mesh containing the submesh
  117010. * @param subMesh defines the submesh to bind the material to
  117011. */
  117012. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117013. /**
  117014. * Gets the active textures from the material
  117015. * @returns an array of textures
  117016. */
  117017. getActiveTextures(): BaseTexture[];
  117018. /**
  117019. * Gets the list of texture blocks
  117020. * @returns an array of texture blocks
  117021. */
  117022. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  117023. /**
  117024. * Specifies if the material uses a texture
  117025. * @param texture defines the texture to check against the material
  117026. * @returns a boolean specifying if the material uses the texture
  117027. */
  117028. hasTexture(texture: BaseTexture): boolean;
  117029. /**
  117030. * Disposes the material
  117031. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  117032. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  117033. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  117034. */
  117035. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  117036. /** Creates the node editor window. */
  117037. private _createNodeEditor;
  117038. /**
  117039. * Launch the node material editor
  117040. * @param config Define the configuration of the editor
  117041. * @return a promise fulfilled when the node editor is visible
  117042. */
  117043. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  117044. /**
  117045. * Clear the current material
  117046. */
  117047. clear(): void;
  117048. /**
  117049. * Clear the current material and set it to a default state
  117050. */
  117051. setToDefault(): void;
  117052. /**
  117053. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  117054. * @param url defines the url to load from
  117055. * @returns a promise that will fullfil when the material is fully loaded
  117056. */
  117057. loadAsync(url: string): Promise<unknown>;
  117058. private _gatherBlocks;
  117059. /**
  117060. * Generate a string containing the code declaration required to create an equivalent of this material
  117061. * @returns a string
  117062. */
  117063. generateCode(): string;
  117064. /**
  117065. * Serializes this material in a JSON representation
  117066. * @returns the serialized material object
  117067. */
  117068. serialize(): any;
  117069. private _restoreConnections;
  117070. /**
  117071. * Clear the current graph and load a new one from a serialization object
  117072. * @param source defines the JSON representation of the material
  117073. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117074. */
  117075. loadFromSerialization(source: any, rootUrl?: string): void;
  117076. /**
  117077. * Creates a node material from parsed material data
  117078. * @param source defines the JSON representation of the material
  117079. * @param scene defines the hosting scene
  117080. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117081. * @returns a new node material
  117082. */
  117083. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  117084. /**
  117085. * Creates a new node material set to default basic configuration
  117086. * @param name defines the name of the material
  117087. * @param scene defines the hosting scene
  117088. * @returns a new NodeMaterial
  117089. */
  117090. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  117091. }
  117092. }
  117093. declare module BABYLON {
  117094. /**
  117095. * Block used to read a texture from a sampler
  117096. */
  117097. export class TextureBlock extends NodeMaterialBlock {
  117098. private _defineName;
  117099. private _samplerName;
  117100. private _transformedUVName;
  117101. private _textureTransformName;
  117102. private _textureInfoName;
  117103. private _mainUVName;
  117104. private _mainUVDefineName;
  117105. /**
  117106. * Gets or sets the texture associated with the node
  117107. */
  117108. texture: Nullable<BaseTexture>;
  117109. /**
  117110. * Create a new TextureBlock
  117111. * @param name defines the block name
  117112. */
  117113. constructor(name: string);
  117114. /**
  117115. * Gets the current class name
  117116. * @returns the class name
  117117. */
  117118. getClassName(): string;
  117119. /**
  117120. * Gets the uv input component
  117121. */
  117122. readonly uv: NodeMaterialConnectionPoint;
  117123. /**
  117124. * Gets the rgba output component
  117125. */
  117126. readonly rgba: NodeMaterialConnectionPoint;
  117127. /**
  117128. * Gets the rgb output component
  117129. */
  117130. readonly rgb: NodeMaterialConnectionPoint;
  117131. /**
  117132. * Gets the r output component
  117133. */
  117134. readonly r: NodeMaterialConnectionPoint;
  117135. /**
  117136. * Gets the g output component
  117137. */
  117138. readonly g: NodeMaterialConnectionPoint;
  117139. /**
  117140. * Gets the b output component
  117141. */
  117142. readonly b: NodeMaterialConnectionPoint;
  117143. /**
  117144. * Gets the a output component
  117145. */
  117146. readonly a: NodeMaterialConnectionPoint;
  117147. autoConfigure(): void;
  117148. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117149. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117150. isReady(): boolean;
  117151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117152. private _injectVertexCode;
  117153. private _writeOutput;
  117154. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117155. serialize(): any;
  117156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117157. }
  117158. }
  117159. declare module BABYLON {
  117160. /**
  117161. * Class used to store shared data between 2 NodeMaterialBuildState
  117162. */
  117163. export class NodeMaterialBuildStateSharedData {
  117164. /**
  117165. * Gets the list of emitted varyings
  117166. */
  117167. temps: string[];
  117168. /**
  117169. * Gets the list of emitted varyings
  117170. */
  117171. varyings: string[];
  117172. /**
  117173. * Gets the varying declaration string
  117174. */
  117175. varyingDeclaration: string;
  117176. /**
  117177. * Input blocks
  117178. */
  117179. inputBlocks: InputBlock[];
  117180. /**
  117181. * Input blocks
  117182. */
  117183. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  117184. /**
  117185. * Bindable blocks (Blocks that need to set data to the effect)
  117186. */
  117187. bindableBlocks: NodeMaterialBlock[];
  117188. /**
  117189. * List of blocks that can provide a compilation fallback
  117190. */
  117191. blocksWithFallbacks: NodeMaterialBlock[];
  117192. /**
  117193. * List of blocks that can provide a define update
  117194. */
  117195. blocksWithDefines: NodeMaterialBlock[];
  117196. /**
  117197. * List of blocks that can provide a repeatable content
  117198. */
  117199. repeatableContentBlocks: NodeMaterialBlock[];
  117200. /**
  117201. * List of blocks that can provide a dynamic list of uniforms
  117202. */
  117203. dynamicUniformBlocks: NodeMaterialBlock[];
  117204. /**
  117205. * List of blocks that can block the isReady function for the material
  117206. */
  117207. blockingBlocks: NodeMaterialBlock[];
  117208. /**
  117209. * Gets the list of animated inputs
  117210. */
  117211. animatedInputs: InputBlock[];
  117212. /**
  117213. * Build Id used to avoid multiple recompilations
  117214. */
  117215. buildId: number;
  117216. /** List of emitted variables */
  117217. variableNames: {
  117218. [key: string]: number;
  117219. };
  117220. /** List of emitted defines */
  117221. defineNames: {
  117222. [key: string]: number;
  117223. };
  117224. /** Should emit comments? */
  117225. emitComments: boolean;
  117226. /** Emit build activity */
  117227. verbose: boolean;
  117228. /**
  117229. * Gets the compilation hints emitted at compilation time
  117230. */
  117231. hints: {
  117232. needWorldViewMatrix: boolean;
  117233. needWorldViewProjectionMatrix: boolean;
  117234. needAlphaBlending: boolean;
  117235. needAlphaTesting: boolean;
  117236. };
  117237. /**
  117238. * List of compilation checks
  117239. */
  117240. checks: {
  117241. emitVertex: boolean;
  117242. emitFragment: boolean;
  117243. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  117244. };
  117245. /** Creates a new shared data */
  117246. constructor();
  117247. /**
  117248. * Emits console errors and exceptions if there is a failing check
  117249. */
  117250. emitErrors(): void;
  117251. }
  117252. }
  117253. declare module BABYLON {
  117254. /**
  117255. * Class used to store node based material build state
  117256. */
  117257. export class NodeMaterialBuildState {
  117258. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  117259. supportUniformBuffers: boolean;
  117260. /**
  117261. * Gets the list of emitted attributes
  117262. */
  117263. attributes: string[];
  117264. /**
  117265. * Gets the list of emitted uniforms
  117266. */
  117267. uniforms: string[];
  117268. /**
  117269. * Gets the list of emitted uniform buffers
  117270. */
  117271. uniformBuffers: string[];
  117272. /**
  117273. * Gets the list of emitted samplers
  117274. */
  117275. samplers: string[];
  117276. /**
  117277. * Gets the list of emitted functions
  117278. */
  117279. functions: {
  117280. [key: string]: string;
  117281. };
  117282. /**
  117283. * Gets the target of the compilation state
  117284. */
  117285. target: NodeMaterialBlockTargets;
  117286. /**
  117287. * Gets the list of emitted counters
  117288. */
  117289. counters: {
  117290. [key: string]: number;
  117291. };
  117292. /**
  117293. * Shared data between multiple NodeMaterialBuildState instances
  117294. */
  117295. sharedData: NodeMaterialBuildStateSharedData;
  117296. /** @hidden */
  117297. _vertexState: NodeMaterialBuildState;
  117298. /** @hidden */
  117299. _attributeDeclaration: string;
  117300. /** @hidden */
  117301. _uniformDeclaration: string;
  117302. /** @hidden */
  117303. _samplerDeclaration: string;
  117304. /** @hidden */
  117305. _varyingTransfer: string;
  117306. private _repeatableContentAnchorIndex;
  117307. /** @hidden */
  117308. _builtCompilationString: string;
  117309. /**
  117310. * Gets the emitted compilation strings
  117311. */
  117312. compilationString: string;
  117313. /**
  117314. * Finalize the compilation strings
  117315. * @param state defines the current compilation state
  117316. */
  117317. finalize(state: NodeMaterialBuildState): void;
  117318. /** @hidden */
  117319. readonly _repeatableContentAnchor: string;
  117320. /** @hidden */
  117321. _getFreeVariableName(prefix: string): string;
  117322. /** @hidden */
  117323. _getFreeDefineName(prefix: string): string;
  117324. /** @hidden */
  117325. _excludeVariableName(name: string): void;
  117326. /** @hidden */
  117327. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  117328. /** @hidden */
  117329. _emitFunction(name: string, code: string, comments: string): void;
  117330. /** @hidden */
  117331. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  117332. replaceStrings?: {
  117333. search: RegExp;
  117334. replace: string;
  117335. }[];
  117336. repeatKey?: string;
  117337. }): string;
  117338. /** @hidden */
  117339. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  117340. repeatKey?: string;
  117341. removeAttributes?: boolean;
  117342. removeUniforms?: boolean;
  117343. removeVaryings?: boolean;
  117344. removeIfDef?: boolean;
  117345. replaceStrings?: {
  117346. search: RegExp;
  117347. replace: string;
  117348. }[];
  117349. }, storeKey?: string): void;
  117350. /** @hidden */
  117351. _registerTempVariable(name: string): boolean;
  117352. /** @hidden */
  117353. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  117354. /** @hidden */
  117355. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  117356. }
  117357. }
  117358. declare module BABYLON {
  117359. /**
  117360. * Defines a block that can be used inside a node based material
  117361. */
  117362. export class NodeMaterialBlock {
  117363. private _buildId;
  117364. private _buildTarget;
  117365. private _target;
  117366. private _isFinalMerger;
  117367. private _isInput;
  117368. protected _codeVariableName: string;
  117369. /** @hidden */
  117370. _inputs: NodeMaterialConnectionPoint[];
  117371. /** @hidden */
  117372. _outputs: NodeMaterialConnectionPoint[];
  117373. /**
  117374. * Gets or sets the name of the block
  117375. */
  117376. name: string;
  117377. /**
  117378. * Gets or sets the unique id of the node
  117379. */
  117380. uniqueId: number;
  117381. /**
  117382. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  117383. */
  117384. readonly isFinalMerger: boolean;
  117385. /**
  117386. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  117387. */
  117388. readonly isInput: boolean;
  117389. /**
  117390. * Gets or sets the build Id
  117391. */
  117392. buildId: number;
  117393. /**
  117394. * Gets or sets the target of the block
  117395. */
  117396. target: NodeMaterialBlockTargets;
  117397. /**
  117398. * Gets the list of input points
  117399. */
  117400. readonly inputs: NodeMaterialConnectionPoint[];
  117401. /** Gets the list of output points */
  117402. readonly outputs: NodeMaterialConnectionPoint[];
  117403. /**
  117404. * Find an input by its name
  117405. * @param name defines the name of the input to look for
  117406. * @returns the input or null if not found
  117407. */
  117408. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117409. /**
  117410. * Find an output by its name
  117411. * @param name defines the name of the outputto look for
  117412. * @returns the output or null if not found
  117413. */
  117414. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117415. /**
  117416. * Creates a new NodeMaterialBlock
  117417. * @param name defines the block name
  117418. * @param target defines the target of that block (Vertex by default)
  117419. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  117420. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  117421. */
  117422. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  117423. /**
  117424. * Initialize the block and prepare the context for build
  117425. * @param state defines the state that will be used for the build
  117426. */
  117427. initialize(state: NodeMaterialBuildState): void;
  117428. /**
  117429. * Bind data to effect. Will only be called for blocks with isBindable === true
  117430. * @param effect defines the effect to bind data to
  117431. * @param nodeMaterial defines the hosting NodeMaterial
  117432. * @param mesh defines the mesh that will be rendered
  117433. */
  117434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117435. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  117436. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  117437. protected _writeFloat(value: number): string;
  117438. /**
  117439. * Gets the current class name e.g. "NodeMaterialBlock"
  117440. * @returns the class name
  117441. */
  117442. getClassName(): string;
  117443. /**
  117444. * Register a new input. Must be called inside a block constructor
  117445. * @param name defines the connection point name
  117446. * @param type defines the connection point type
  117447. * @param isOptional defines a boolean indicating that this input can be omitted
  117448. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  117449. * @returns the current block
  117450. */
  117451. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  117452. /**
  117453. * Register a new output. Must be called inside a block constructor
  117454. * @param name defines the connection point name
  117455. * @param type defines the connection point type
  117456. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  117457. * @returns the current block
  117458. */
  117459. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  117460. /**
  117461. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  117462. * @param forOutput defines an optional connection point to check compatibility with
  117463. * @returns the first available input or null
  117464. */
  117465. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  117466. /**
  117467. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  117468. * @param forBlock defines an optional block to check compatibility with
  117469. * @returns the first available input or null
  117470. */
  117471. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  117472. /**
  117473. * Gets the sibling of the given output
  117474. * @param current defines the current output
  117475. * @returns the next output in the list or null
  117476. */
  117477. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  117478. /**
  117479. * Connect current block with another block
  117480. * @param other defines the block to connect with
  117481. * @param options define the various options to help pick the right connections
  117482. * @returns the current block
  117483. */
  117484. connectTo(other: NodeMaterialBlock, options?: {
  117485. input?: string;
  117486. output?: string;
  117487. outputSwizzle?: string;
  117488. }): this | undefined;
  117489. protected _buildBlock(state: NodeMaterialBuildState): void;
  117490. /**
  117491. * Add uniforms, samplers and uniform buffers at compilation time
  117492. * @param state defines the state to update
  117493. * @param nodeMaterial defines the node material requesting the update
  117494. * @param defines defines the material defines to update
  117495. */
  117496. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117497. /**
  117498. * Add potential fallbacks if shader compilation fails
  117499. * @param mesh defines the mesh to be rendered
  117500. * @param fallbacks defines the current prioritized list of fallbacks
  117501. */
  117502. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117503. /**
  117504. * Update defines for shader compilation
  117505. * @param mesh defines the mesh to be rendered
  117506. * @param nodeMaterial defines the node material requesting the update
  117507. * @param defines defines the material defines to update
  117508. * @param useInstances specifies that instances should be used
  117509. */
  117510. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117511. /**
  117512. * Initialize defines for shader compilation
  117513. * @param mesh defines the mesh to be rendered
  117514. * @param nodeMaterial defines the node material requesting the update
  117515. * @param defines defines the material defines to be prepared
  117516. * @param useInstances specifies that instances should be used
  117517. */
  117518. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117519. /**
  117520. * Lets the block try to connect some inputs automatically
  117521. * @param material defines the hosting NodeMaterial
  117522. */
  117523. autoConfigure(material: NodeMaterial): void;
  117524. /**
  117525. * Function called when a block is declared as repeatable content generator
  117526. * @param vertexShaderState defines the current compilation state for the vertex shader
  117527. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117528. * @param mesh defines the mesh to be rendered
  117529. * @param defines defines the material defines to update
  117530. */
  117531. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117532. /**
  117533. * Checks if the block is ready
  117534. * @param mesh defines the mesh to be rendered
  117535. * @param nodeMaterial defines the node material requesting the update
  117536. * @param defines defines the material defines to update
  117537. * @param useInstances specifies that instances should be used
  117538. * @returns true if the block is ready
  117539. */
  117540. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117541. private _processBuild;
  117542. /**
  117543. * Compile the current node and generate the shader code
  117544. * @param state defines the current compilation state (uniforms, samplers, current string)
  117545. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  117546. * @returns true if already built
  117547. */
  117548. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  117549. protected _inputRename(name: string): string;
  117550. protected _outputRename(name: string): string;
  117551. protected _dumpPropertiesCode(): string;
  117552. /** @hidden */
  117553. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  117554. /**
  117555. * Clone the current block to a new identical block
  117556. * @param scene defines the hosting scene
  117557. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117558. * @returns a copy of the current block
  117559. */
  117560. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  117561. /**
  117562. * Serializes this block in a JSON representation
  117563. * @returns the serialized block object
  117564. */
  117565. serialize(): any;
  117566. /** @hidden */
  117567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117568. }
  117569. }
  117570. declare module BABYLON {
  117571. /**
  117572. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117573. */
  117574. export enum NodeMaterialBlockConnectionPointMode {
  117575. /** Value is an uniform */
  117576. Uniform = 0,
  117577. /** Value is a mesh attribute */
  117578. Attribute = 1,
  117579. /** Value is a varying between vertex and fragment shaders */
  117580. Varying = 2,
  117581. /** Mode is undefined */
  117582. Undefined = 3
  117583. }
  117584. }
  117585. declare module BABYLON {
  117586. /**
  117587. * Enum defining the type of animations supported by InputBlock
  117588. */
  117589. export enum AnimatedInputBlockTypes {
  117590. /** No animation */
  117591. None = 0,
  117592. /** Time based animation. Will only work for floats */
  117593. Time = 1
  117594. }
  117595. }
  117596. declare module BABYLON {
  117597. /**
  117598. * Block used to expose an input value
  117599. */
  117600. export class InputBlock extends NodeMaterialBlock {
  117601. private _mode;
  117602. private _associatedVariableName;
  117603. private _storedValue;
  117604. private _valueCallback;
  117605. private _type;
  117606. private _animationType;
  117607. /** @hidden */
  117608. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117609. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  117610. visibleInInspector: boolean;
  117611. /**
  117612. * Gets or sets the connection point type (default is float)
  117613. */
  117614. readonly type: NodeMaterialBlockConnectionPointTypes;
  117615. /**
  117616. * Creates a new InputBlock
  117617. * @param name defines the block name
  117618. * @param target defines the target of that block (Vertex by default)
  117619. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117620. */
  117621. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117622. /**
  117623. * Gets the output component
  117624. */
  117625. readonly output: NodeMaterialConnectionPoint;
  117626. /**
  117627. * Set the source of this connection point to a vertex attribute
  117628. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117629. * @returns the current connection point
  117630. */
  117631. setAsAttribute(attributeName?: string): InputBlock;
  117632. /**
  117633. * Set the source of this connection point to a well known value
  117634. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117635. * @returns the current connection point
  117636. */
  117637. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117638. /**
  117639. * Gets or sets the value of that point.
  117640. * Please note that this value will be ignored if valueCallback is defined
  117641. */
  117642. value: any;
  117643. /**
  117644. * Gets or sets a callback used to get the value of that point.
  117645. * Please note that setting this value will force the connection point to ignore the value property
  117646. */
  117647. valueCallback: () => any;
  117648. /**
  117649. * Gets or sets the associated variable name in the shader
  117650. */
  117651. associatedVariableName: string;
  117652. /** Gets or sets the type of animation applied to the input */
  117653. animationType: AnimatedInputBlockTypes;
  117654. /**
  117655. * Gets a boolean indicating that this connection point not defined yet
  117656. */
  117657. readonly isUndefined: boolean;
  117658. /**
  117659. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117660. * In this case the connection point name must be the name of the uniform to use.
  117661. * Can only be set on inputs
  117662. */
  117663. isUniform: boolean;
  117664. /**
  117665. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117666. * In this case the connection point name must be the name of the attribute to use
  117667. * Can only be set on inputs
  117668. */
  117669. isAttribute: boolean;
  117670. /**
  117671. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117672. * Can only be set on exit points
  117673. */
  117674. isVarying: boolean;
  117675. /**
  117676. * Gets a boolean indicating that the current connection point is a well known value
  117677. */
  117678. readonly isWellKnownValue: boolean;
  117679. /**
  117680. * Gets or sets the current well known value or null if not defined as well know value
  117681. */
  117682. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117683. /**
  117684. * Gets the current class name
  117685. * @returns the class name
  117686. */
  117687. getClassName(): string;
  117688. /**
  117689. * Animate the input if animationType !== None
  117690. * @param scene defines the rendering scene
  117691. */
  117692. animate(scene: Scene): void;
  117693. private _emitDefine;
  117694. /**
  117695. * Set the input block to its default value (based on its type)
  117696. */
  117697. setDefaultValue(): void;
  117698. protected _dumpPropertiesCode(): string;
  117699. private _emit;
  117700. /** @hidden */
  117701. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117702. /** @hidden */
  117703. _transmit(effect: Effect, scene: Scene): void;
  117704. protected _buildBlock(state: NodeMaterialBuildState): void;
  117705. serialize(): any;
  117706. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117707. }
  117708. }
  117709. declare module BABYLON {
  117710. /**
  117711. * Defines a connection point for a block
  117712. */
  117713. export class NodeMaterialConnectionPoint {
  117714. /** @hidden */
  117715. _ownerBlock: NodeMaterialBlock;
  117716. /** @hidden */
  117717. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117718. private _endpoints;
  117719. private _associatedVariableName;
  117720. /** @hidden */
  117721. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117722. private _type;
  117723. /** @hidden */
  117724. _enforceAssociatedVariableName: boolean;
  117725. /**
  117726. * Gets or sets the additional types supported byt this connection point
  117727. */
  117728. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117729. /**
  117730. * Gets or sets the associated variable name in the shader
  117731. */
  117732. associatedVariableName: string;
  117733. /**
  117734. * Gets or sets the connection point type (default is float)
  117735. */
  117736. type: NodeMaterialBlockConnectionPointTypes;
  117737. /**
  117738. * Gets or sets the connection point name
  117739. */
  117740. name: string;
  117741. /**
  117742. * Gets or sets a boolean indicating that this connection point can be omitted
  117743. */
  117744. isOptional: boolean;
  117745. /**
  117746. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117747. */
  117748. define: string;
  117749. /** Gets or sets the target of that connection point */
  117750. target: NodeMaterialBlockTargets;
  117751. /**
  117752. * Gets a boolean indicating that the current point is connected
  117753. */
  117754. readonly isConnected: boolean;
  117755. /**
  117756. * Gets a boolean indicating that the current point is connected to an input block
  117757. */
  117758. readonly isConnectedToInputBlock: boolean;
  117759. /**
  117760. * Gets a the connected input block (if any)
  117761. */
  117762. readonly connectInputBlock: Nullable<InputBlock>;
  117763. /** Get the other side of the connection (if any) */
  117764. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117765. /** Get the block that owns this connection point */
  117766. readonly ownerBlock: NodeMaterialBlock;
  117767. /** Get the block connected on the other side of this connection (if any) */
  117768. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117769. /** Get the block connected on the endpoints of this connection (if any) */
  117770. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117771. /** Gets the list of connected endpoints */
  117772. readonly endpoints: NodeMaterialConnectionPoint[];
  117773. /** Gets a boolean indicating if that output point is connected to at least one input */
  117774. readonly hasEndpoints: boolean;
  117775. /**
  117776. * Creates a new connection point
  117777. * @param name defines the connection point name
  117778. * @param ownerBlock defines the block hosting this connection point
  117779. */
  117780. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117781. /**
  117782. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117783. * @returns the class name
  117784. */
  117785. getClassName(): string;
  117786. /**
  117787. * Gets an boolean indicating if the current point can be connected to another point
  117788. * @param connectionPoint defines the other connection point
  117789. * @returns true if the connection is possible
  117790. */
  117791. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117792. /**
  117793. * Connect this point to another connection point
  117794. * @param connectionPoint defines the other connection point
  117795. * @returns the current connection point
  117796. */
  117797. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117798. /**
  117799. * Disconnect this point from one of his endpoint
  117800. * @param endpoint defines the other connection point
  117801. * @returns the current connection point
  117802. */
  117803. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117804. /**
  117805. * Serializes this point in a JSON representation
  117806. * @returns the serialized point object
  117807. */
  117808. serialize(): any;
  117809. }
  117810. }
  117811. declare module BABYLON {
  117812. /**
  117813. * Block used to add support for vertex skinning (bones)
  117814. */
  117815. export class BonesBlock extends NodeMaterialBlock {
  117816. /**
  117817. * Creates a new BonesBlock
  117818. * @param name defines the block name
  117819. */
  117820. constructor(name: string);
  117821. /**
  117822. * Initialize the block and prepare the context for build
  117823. * @param state defines the state that will be used for the build
  117824. */
  117825. initialize(state: NodeMaterialBuildState): void;
  117826. /**
  117827. * Gets the current class name
  117828. * @returns the class name
  117829. */
  117830. getClassName(): string;
  117831. /**
  117832. * Gets the matrix indices input component
  117833. */
  117834. readonly matricesIndices: NodeMaterialConnectionPoint;
  117835. /**
  117836. * Gets the matrix weights input component
  117837. */
  117838. readonly matricesWeights: NodeMaterialConnectionPoint;
  117839. /**
  117840. * Gets the extra matrix indices input component
  117841. */
  117842. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117843. /**
  117844. * Gets the extra matrix weights input component
  117845. */
  117846. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117847. /**
  117848. * Gets the world input component
  117849. */
  117850. readonly world: NodeMaterialConnectionPoint;
  117851. /**
  117852. * Gets the output component
  117853. */
  117854. readonly output: NodeMaterialConnectionPoint;
  117855. autoConfigure(): void;
  117856. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117858. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117859. protected _buildBlock(state: NodeMaterialBuildState): this;
  117860. }
  117861. }
  117862. declare module BABYLON {
  117863. /**
  117864. * Block used to add support for instances
  117865. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117866. */
  117867. export class InstancesBlock extends NodeMaterialBlock {
  117868. /**
  117869. * Creates a new InstancesBlock
  117870. * @param name defines the block name
  117871. */
  117872. constructor(name: string);
  117873. /**
  117874. * Gets the current class name
  117875. * @returns the class name
  117876. */
  117877. getClassName(): string;
  117878. /**
  117879. * Gets the first world row input component
  117880. */
  117881. readonly world0: NodeMaterialConnectionPoint;
  117882. /**
  117883. * Gets the second world row input component
  117884. */
  117885. readonly world1: NodeMaterialConnectionPoint;
  117886. /**
  117887. * Gets the third world row input component
  117888. */
  117889. readonly world2: NodeMaterialConnectionPoint;
  117890. /**
  117891. * Gets the forth world row input component
  117892. */
  117893. readonly world3: NodeMaterialConnectionPoint;
  117894. /**
  117895. * Gets the world input component
  117896. */
  117897. readonly world: NodeMaterialConnectionPoint;
  117898. /**
  117899. * Gets the output component
  117900. */
  117901. readonly output: NodeMaterialConnectionPoint;
  117902. autoConfigure(): void;
  117903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117904. protected _buildBlock(state: NodeMaterialBuildState): this;
  117905. }
  117906. }
  117907. declare module BABYLON {
  117908. /**
  117909. * Block used to add morph targets support to vertex shader
  117910. */
  117911. export class MorphTargetsBlock extends NodeMaterialBlock {
  117912. private _repeatableContentAnchor;
  117913. private _repeatebleContentGenerated;
  117914. /**
  117915. * Create a new MorphTargetsBlock
  117916. * @param name defines the block name
  117917. */
  117918. constructor(name: string);
  117919. /**
  117920. * Gets the current class name
  117921. * @returns the class name
  117922. */
  117923. getClassName(): string;
  117924. /**
  117925. * Gets the position input component
  117926. */
  117927. readonly position: NodeMaterialConnectionPoint;
  117928. /**
  117929. * Gets the normal input component
  117930. */
  117931. readonly normal: NodeMaterialConnectionPoint;
  117932. /**
  117933. * Gets the tangent input component
  117934. */
  117935. readonly tangent: NodeMaterialConnectionPoint;
  117936. /**
  117937. * Gets the tangent input component
  117938. */
  117939. readonly uv: NodeMaterialConnectionPoint;
  117940. /**
  117941. * Gets the position output component
  117942. */
  117943. readonly positionOutput: NodeMaterialConnectionPoint;
  117944. /**
  117945. * Gets the normal output component
  117946. */
  117947. readonly normalOutput: NodeMaterialConnectionPoint;
  117948. /**
  117949. * Gets the tangent output component
  117950. */
  117951. readonly tangentOutput: NodeMaterialConnectionPoint;
  117952. /**
  117953. * Gets the tangent output component
  117954. */
  117955. readonly uvOutput: NodeMaterialConnectionPoint;
  117956. initialize(state: NodeMaterialBuildState): void;
  117957. autoConfigure(): void;
  117958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117960. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117961. protected _buildBlock(state: NodeMaterialBuildState): this;
  117962. }
  117963. }
  117964. declare module BABYLON {
  117965. /**
  117966. * Block used to add an alpha test in the fragment shader
  117967. */
  117968. export class AlphaTestBlock extends NodeMaterialBlock {
  117969. /**
  117970. * Gets or sets the alpha value where alpha testing happens
  117971. */
  117972. alphaCutOff: number;
  117973. /**
  117974. * Create a new AlphaTestBlock
  117975. * @param name defines the block name
  117976. */
  117977. constructor(name: string);
  117978. /**
  117979. * Gets the current class name
  117980. * @returns the class name
  117981. */
  117982. getClassName(): string;
  117983. /**
  117984. * Gets the color input component
  117985. */
  117986. readonly color: NodeMaterialConnectionPoint;
  117987. /**
  117988. * Gets the alpha input component
  117989. */
  117990. readonly alpha: NodeMaterialConnectionPoint;
  117991. protected _buildBlock(state: NodeMaterialBuildState): this;
  117992. }
  117993. }
  117994. declare module BABYLON {
  117995. /**
  117996. * Block used to compute fresnel value
  117997. */
  117998. export class FresnelBlock extends NodeMaterialBlock {
  117999. /**
  118000. * Create a new FresnelBlock
  118001. * @param name defines the block name
  118002. */
  118003. constructor(name: string);
  118004. /**
  118005. * Gets the current class name
  118006. * @returns the class name
  118007. */
  118008. getClassName(): string;
  118009. /**
  118010. * Gets the world position input component
  118011. */
  118012. readonly worldPosition: NodeMaterialConnectionPoint;
  118013. /**
  118014. * Gets the world normal input component
  118015. */
  118016. readonly worldNormal: NodeMaterialConnectionPoint;
  118017. /**
  118018. * Gets the camera (or eye) position component
  118019. */
  118020. readonly cameraPosition: NodeMaterialConnectionPoint;
  118021. /**
  118022. * Gets the bias input component
  118023. */
  118024. readonly bias: NodeMaterialConnectionPoint;
  118025. /**
  118026. * Gets the camera (or eye) position component
  118027. */
  118028. readonly power: NodeMaterialConnectionPoint;
  118029. /**
  118030. * Gets the fresnel output component
  118031. */
  118032. readonly fresnel: NodeMaterialConnectionPoint;
  118033. autoConfigure(material: NodeMaterial): void;
  118034. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118035. }
  118036. }
  118037. declare module BABYLON {
  118038. /**
  118039. * Block used to add image processing support to fragment shader
  118040. */
  118041. export class ImageProcessingBlock extends NodeMaterialBlock {
  118042. /**
  118043. * Create a new ImageProcessingBlock
  118044. * @param name defines the block name
  118045. */
  118046. constructor(name: string);
  118047. /**
  118048. * Gets the current class name
  118049. * @returns the class name
  118050. */
  118051. getClassName(): string;
  118052. /**
  118053. * Gets the color input component
  118054. */
  118055. readonly color: NodeMaterialConnectionPoint;
  118056. /**
  118057. * Gets the output component
  118058. */
  118059. readonly output: NodeMaterialConnectionPoint;
  118060. /**
  118061. * Initialize the block and prepare the context for build
  118062. * @param state defines the state that will be used for the build
  118063. */
  118064. initialize(state: NodeMaterialBuildState): void;
  118065. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  118066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118068. protected _buildBlock(state: NodeMaterialBuildState): this;
  118069. }
  118070. }
  118071. declare module BABYLON {
  118072. /**
  118073. * Block used to add support for scene fog
  118074. */
  118075. export class FogBlock extends NodeMaterialBlock {
  118076. private _fogDistanceName;
  118077. private _fogParameters;
  118078. /**
  118079. * Create a new FogBlock
  118080. * @param name defines the block name
  118081. */
  118082. constructor(name: string);
  118083. /**
  118084. * Gets the current class name
  118085. * @returns the class name
  118086. */
  118087. getClassName(): string;
  118088. /**
  118089. * Gets the world position input component
  118090. */
  118091. readonly worldPosition: NodeMaterialConnectionPoint;
  118092. /**
  118093. * Gets the view input component
  118094. */
  118095. readonly view: NodeMaterialConnectionPoint;
  118096. /**
  118097. * Gets the color input component
  118098. */
  118099. readonly color: NodeMaterialConnectionPoint;
  118100. /**
  118101. * Gets the fog color input component
  118102. */
  118103. readonly fogColor: NodeMaterialConnectionPoint;
  118104. /**
  118105. * Gets the output component
  118106. */
  118107. readonly output: NodeMaterialConnectionPoint;
  118108. autoConfigure(): void;
  118109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118111. protected _buildBlock(state: NodeMaterialBuildState): this;
  118112. }
  118113. }
  118114. declare module BABYLON {
  118115. /**
  118116. * Block used to add light in the fragment shader
  118117. */
  118118. export class LightBlock extends NodeMaterialBlock {
  118119. private _lightId;
  118120. /**
  118121. * Gets or sets the light associated with this block
  118122. */
  118123. light: Nullable<Light>;
  118124. /**
  118125. * Create a new LightBlock
  118126. * @param name defines the block name
  118127. */
  118128. constructor(name: string);
  118129. /**
  118130. * Gets the current class name
  118131. * @returns the class name
  118132. */
  118133. getClassName(): string;
  118134. /**
  118135. * Gets the world position input component
  118136. */
  118137. readonly worldPosition: NodeMaterialConnectionPoint;
  118138. /**
  118139. * Gets the world normal input component
  118140. */
  118141. readonly worldNormal: NodeMaterialConnectionPoint;
  118142. /**
  118143. * Gets the camera (or eye) position component
  118144. */
  118145. readonly cameraPosition: NodeMaterialConnectionPoint;
  118146. /**
  118147. * Gets the diffuse output component
  118148. */
  118149. readonly diffuseOutput: NodeMaterialConnectionPoint;
  118150. /**
  118151. * Gets the specular output component
  118152. */
  118153. readonly specularOutput: NodeMaterialConnectionPoint;
  118154. autoConfigure(): void;
  118155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118156. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118158. private _injectVertexCode;
  118159. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118160. serialize(): any;
  118161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118162. }
  118163. }
  118164. declare module BABYLON {
  118165. /**
  118166. * Block used to multiply 2 values
  118167. */
  118168. export class MultiplyBlock extends NodeMaterialBlock {
  118169. /**
  118170. * Creates a new MultiplyBlock
  118171. * @param name defines the block name
  118172. */
  118173. constructor(name: string);
  118174. /**
  118175. * Gets the current class name
  118176. * @returns the class name
  118177. */
  118178. getClassName(): string;
  118179. /**
  118180. * Gets the left operand input component
  118181. */
  118182. readonly left: NodeMaterialConnectionPoint;
  118183. /**
  118184. * Gets the right operand input component
  118185. */
  118186. readonly right: NodeMaterialConnectionPoint;
  118187. /**
  118188. * Gets the output component
  118189. */
  118190. readonly output: NodeMaterialConnectionPoint;
  118191. protected _buildBlock(state: NodeMaterialBuildState): this;
  118192. }
  118193. }
  118194. declare module BABYLON {
  118195. /**
  118196. * Block used to add 2 vectors
  118197. */
  118198. export class AddBlock extends NodeMaterialBlock {
  118199. /**
  118200. * Creates a new AddBlock
  118201. * @param name defines the block name
  118202. */
  118203. constructor(name: string);
  118204. /**
  118205. * Gets the current class name
  118206. * @returns the class name
  118207. */
  118208. getClassName(): string;
  118209. /**
  118210. * Gets the left operand input component
  118211. */
  118212. readonly left: NodeMaterialConnectionPoint;
  118213. /**
  118214. * Gets the right operand input component
  118215. */
  118216. readonly right: NodeMaterialConnectionPoint;
  118217. /**
  118218. * Gets the output component
  118219. */
  118220. readonly output: NodeMaterialConnectionPoint;
  118221. protected _buildBlock(state: NodeMaterialBuildState): this;
  118222. }
  118223. }
  118224. declare module BABYLON {
  118225. /**
  118226. * Block used to scale a vector by a float
  118227. */
  118228. export class ScaleBlock extends NodeMaterialBlock {
  118229. /**
  118230. * Creates a new ScaleBlock
  118231. * @param name defines the block name
  118232. */
  118233. constructor(name: string);
  118234. /**
  118235. * Gets the current class name
  118236. * @returns the class name
  118237. */
  118238. getClassName(): string;
  118239. /**
  118240. * Gets the input component
  118241. */
  118242. readonly input: NodeMaterialConnectionPoint;
  118243. /**
  118244. * Gets the factor input component
  118245. */
  118246. readonly factor: NodeMaterialConnectionPoint;
  118247. /**
  118248. * Gets the output component
  118249. */
  118250. readonly output: NodeMaterialConnectionPoint;
  118251. protected _buildBlock(state: NodeMaterialBuildState): this;
  118252. }
  118253. }
  118254. declare module BABYLON {
  118255. /**
  118256. * Block used to clamp a float
  118257. */
  118258. export class ClampBlock extends NodeMaterialBlock {
  118259. /** Gets or sets the minimum range */
  118260. minimum: number;
  118261. /** Gets or sets the maximum range */
  118262. maximum: number;
  118263. /**
  118264. * Creates a new ClampBlock
  118265. * @param name defines the block name
  118266. */
  118267. constructor(name: string);
  118268. /**
  118269. * Gets the current class name
  118270. * @returns the class name
  118271. */
  118272. getClassName(): string;
  118273. /**
  118274. * Gets the value input component
  118275. */
  118276. readonly value: NodeMaterialConnectionPoint;
  118277. /**
  118278. * Gets the output component
  118279. */
  118280. readonly output: NodeMaterialConnectionPoint;
  118281. protected _buildBlock(state: NodeMaterialBuildState): this;
  118282. }
  118283. }
  118284. declare module BABYLON {
  118285. /**
  118286. * Block used to apply a cross product between 2 vectors
  118287. */
  118288. export class CrossBlock extends NodeMaterialBlock {
  118289. /**
  118290. * Creates a new CrossBlock
  118291. * @param name defines the block name
  118292. */
  118293. constructor(name: string);
  118294. /**
  118295. * Gets the current class name
  118296. * @returns the class name
  118297. */
  118298. getClassName(): string;
  118299. /**
  118300. * Gets the left operand input component
  118301. */
  118302. readonly left: NodeMaterialConnectionPoint;
  118303. /**
  118304. * Gets the right operand input component
  118305. */
  118306. readonly right: NodeMaterialConnectionPoint;
  118307. /**
  118308. * Gets the output component
  118309. */
  118310. readonly output: NodeMaterialConnectionPoint;
  118311. protected _buildBlock(state: NodeMaterialBuildState): this;
  118312. }
  118313. }
  118314. declare module BABYLON {
  118315. /**
  118316. * Block used to apply a dot product between 2 vectors
  118317. */
  118318. export class DotBlock extends NodeMaterialBlock {
  118319. /**
  118320. * Creates a new DotBlock
  118321. * @param name defines the block name
  118322. */
  118323. constructor(name: string);
  118324. /**
  118325. * Gets the current class name
  118326. * @returns the class name
  118327. */
  118328. getClassName(): string;
  118329. /**
  118330. * Gets the left operand input component
  118331. */
  118332. readonly left: NodeMaterialConnectionPoint;
  118333. /**
  118334. * Gets the right operand input component
  118335. */
  118336. readonly right: NodeMaterialConnectionPoint;
  118337. /**
  118338. * Gets the output component
  118339. */
  118340. readonly output: NodeMaterialConnectionPoint;
  118341. protected _buildBlock(state: NodeMaterialBuildState): this;
  118342. }
  118343. }
  118344. declare module BABYLON {
  118345. /**
  118346. * Block used to remap a float from a range to a new one
  118347. */
  118348. export class RemapBlock extends NodeMaterialBlock {
  118349. /**
  118350. * Gets or sets the source range
  118351. */
  118352. sourceRange: Vector2;
  118353. /**
  118354. * Gets or sets the target range
  118355. */
  118356. targetRange: Vector2;
  118357. /**
  118358. * Creates a new RemapBlock
  118359. * @param name defines the block name
  118360. */
  118361. constructor(name: string);
  118362. /**
  118363. * Gets the current class name
  118364. * @returns the class name
  118365. */
  118366. getClassName(): string;
  118367. /**
  118368. * Gets the input component
  118369. */
  118370. readonly input: NodeMaterialConnectionPoint;
  118371. /**
  118372. * Gets the output component
  118373. */
  118374. readonly output: NodeMaterialConnectionPoint;
  118375. protected _buildBlock(state: NodeMaterialBuildState): this;
  118376. }
  118377. }
  118378. declare module BABYLON {
  118379. /**
  118380. * Block used to normalize a vector
  118381. */
  118382. export class NormalizeBlock extends NodeMaterialBlock {
  118383. /**
  118384. * Creates a new NormalizeBlock
  118385. * @param name defines the block name
  118386. */
  118387. constructor(name: string);
  118388. /**
  118389. * Gets the current class name
  118390. * @returns the class name
  118391. */
  118392. getClassName(): string;
  118393. /**
  118394. * Gets the input component
  118395. */
  118396. readonly input: NodeMaterialConnectionPoint;
  118397. /**
  118398. * Gets the output component
  118399. */
  118400. readonly output: NodeMaterialConnectionPoint;
  118401. protected _buildBlock(state: NodeMaterialBuildState): this;
  118402. }
  118403. }
  118404. declare module BABYLON {
  118405. /**
  118406. * Operations supported by the Trigonometry block
  118407. */
  118408. export enum TrigonometryBlockOperations {
  118409. /** Cos */
  118410. Cos = 0,
  118411. /** Sin */
  118412. Sin = 1,
  118413. /** Abs */
  118414. Abs = 2,
  118415. /** Exp */
  118416. Exp = 3,
  118417. /** Exp2 */
  118418. Exp2 = 4
  118419. }
  118420. /**
  118421. * Block used to apply trigonometry operation to floats
  118422. */
  118423. export class TrigonometryBlock extends NodeMaterialBlock {
  118424. /**
  118425. * Gets or sets the operation applied by the block
  118426. */
  118427. operation: TrigonometryBlockOperations;
  118428. /**
  118429. * Creates a new TrigonometryBlock
  118430. * @param name defines the block name
  118431. */
  118432. constructor(name: string);
  118433. /**
  118434. * Gets the current class name
  118435. * @returns the class name
  118436. */
  118437. getClassName(): string;
  118438. /**
  118439. * Gets the input component
  118440. */
  118441. readonly input: NodeMaterialConnectionPoint;
  118442. /**
  118443. * Gets the output component
  118444. */
  118445. readonly output: NodeMaterialConnectionPoint;
  118446. protected _buildBlock(state: NodeMaterialBuildState): this;
  118447. }
  118448. }
  118449. declare module BABYLON {
  118450. /**
  118451. * Block used to create a Color3/4 out of individual inputs (one for each component)
  118452. */
  118453. export class ColorMergerBlock extends NodeMaterialBlock {
  118454. /**
  118455. * Create a new ColorMergerBlock
  118456. * @param name defines the block name
  118457. */
  118458. constructor(name: string);
  118459. /**
  118460. * Gets the current class name
  118461. * @returns the class name
  118462. */
  118463. getClassName(): string;
  118464. /**
  118465. * Gets the r component (input)
  118466. */
  118467. readonly r: NodeMaterialConnectionPoint;
  118468. /**
  118469. * Gets the g component (input)
  118470. */
  118471. readonly g: NodeMaterialConnectionPoint;
  118472. /**
  118473. * Gets the b component (input)
  118474. */
  118475. readonly b: NodeMaterialConnectionPoint;
  118476. /**
  118477. * Gets the a component (input)
  118478. */
  118479. readonly a: NodeMaterialConnectionPoint;
  118480. /**
  118481. * Gets the rgba component (output)
  118482. */
  118483. readonly rgba: NodeMaterialConnectionPoint;
  118484. /**
  118485. * Gets the rgb component (output)
  118486. */
  118487. readonly rgb: NodeMaterialConnectionPoint;
  118488. protected _buildBlock(state: NodeMaterialBuildState): this;
  118489. }
  118490. }
  118491. declare module BABYLON {
  118492. /**
  118493. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  118494. */
  118495. export class VectorMergerBlock extends NodeMaterialBlock {
  118496. /**
  118497. * Create a new VectorMergerBlock
  118498. * @param name defines the block name
  118499. */
  118500. constructor(name: string);
  118501. /**
  118502. * Gets the current class name
  118503. * @returns the class name
  118504. */
  118505. getClassName(): string;
  118506. /**
  118507. * Gets the x component (input)
  118508. */
  118509. readonly x: NodeMaterialConnectionPoint;
  118510. /**
  118511. * Gets the y component (input)
  118512. */
  118513. readonly y: NodeMaterialConnectionPoint;
  118514. /**
  118515. * Gets the z component (input)
  118516. */
  118517. readonly z: NodeMaterialConnectionPoint;
  118518. /**
  118519. * Gets the w component (input)
  118520. */
  118521. readonly w: NodeMaterialConnectionPoint;
  118522. /**
  118523. * Gets the xyzw component (output)
  118524. */
  118525. readonly xyzw: NodeMaterialConnectionPoint;
  118526. /**
  118527. * Gets the xyz component (output)
  118528. */
  118529. readonly xyz: NodeMaterialConnectionPoint;
  118530. /**
  118531. * Gets the xy component (output)
  118532. */
  118533. readonly xy: NodeMaterialConnectionPoint;
  118534. protected _buildBlock(state: NodeMaterialBuildState): this;
  118535. }
  118536. }
  118537. declare module BABYLON {
  118538. /**
  118539. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  118540. */
  118541. export class ColorSplitterBlock extends NodeMaterialBlock {
  118542. /**
  118543. * Create a new ColorSplitterBlock
  118544. * @param name defines the block name
  118545. */
  118546. constructor(name: string);
  118547. /**
  118548. * Gets the current class name
  118549. * @returns the class name
  118550. */
  118551. getClassName(): string;
  118552. /**
  118553. * Gets the rgba component (input)
  118554. */
  118555. readonly rgba: NodeMaterialConnectionPoint;
  118556. /**
  118557. * Gets the rgb component (input)
  118558. */
  118559. readonly rgbIn: NodeMaterialConnectionPoint;
  118560. /**
  118561. * Gets the rgb component (output)
  118562. */
  118563. readonly rgbOut: NodeMaterialConnectionPoint;
  118564. /**
  118565. * Gets the r component (output)
  118566. */
  118567. readonly r: NodeMaterialConnectionPoint;
  118568. /**
  118569. * Gets the g component (output)
  118570. */
  118571. readonly g: NodeMaterialConnectionPoint;
  118572. /**
  118573. * Gets the b component (output)
  118574. */
  118575. readonly b: NodeMaterialConnectionPoint;
  118576. /**
  118577. * Gets the a component (output)
  118578. */
  118579. readonly a: NodeMaterialConnectionPoint;
  118580. protected _inputRename(name: string): string;
  118581. protected _outputRename(name: string): string;
  118582. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118583. }
  118584. }
  118585. declare module BABYLON {
  118586. /**
  118587. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  118588. */
  118589. export class VectorSplitterBlock extends NodeMaterialBlock {
  118590. /**
  118591. * Create a new VectorSplitterBlock
  118592. * @param name defines the block name
  118593. */
  118594. constructor(name: string);
  118595. /**
  118596. * Gets the current class name
  118597. * @returns the class name
  118598. */
  118599. getClassName(): string;
  118600. /**
  118601. * Gets the xyzw component (input)
  118602. */
  118603. readonly xyzw: NodeMaterialConnectionPoint;
  118604. /**
  118605. * Gets the xyz component (input)
  118606. */
  118607. readonly xyzIn: NodeMaterialConnectionPoint;
  118608. /**
  118609. * Gets the xy component (input)
  118610. */
  118611. readonly xyIn: NodeMaterialConnectionPoint;
  118612. /**
  118613. * Gets the xyz component (output)
  118614. */
  118615. readonly xyzOut: NodeMaterialConnectionPoint;
  118616. /**
  118617. * Gets the xy component (output)
  118618. */
  118619. readonly xyOut: NodeMaterialConnectionPoint;
  118620. /**
  118621. * Gets the x component (output)
  118622. */
  118623. readonly x: NodeMaterialConnectionPoint;
  118624. /**
  118625. * Gets the y component (output)
  118626. */
  118627. readonly y: NodeMaterialConnectionPoint;
  118628. /**
  118629. * Gets the z component (output)
  118630. */
  118631. readonly z: NodeMaterialConnectionPoint;
  118632. /**
  118633. * Gets the w component (output)
  118634. */
  118635. readonly w: NodeMaterialConnectionPoint;
  118636. protected _inputRename(name: string): string;
  118637. protected _outputRename(name: string): string;
  118638. protected _buildBlock(state: NodeMaterialBuildState): this;
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /**
  118643. * Block used to lerp 2 values
  118644. */
  118645. export class LerpBlock extends NodeMaterialBlock {
  118646. /**
  118647. * Creates a new LerpBlock
  118648. * @param name defines the block name
  118649. */
  118650. constructor(name: string);
  118651. /**
  118652. * Gets the current class name
  118653. * @returns the class name
  118654. */
  118655. getClassName(): string;
  118656. /**
  118657. * Gets the left operand input component
  118658. */
  118659. readonly left: NodeMaterialConnectionPoint;
  118660. /**
  118661. * Gets the right operand input component
  118662. */
  118663. readonly right: NodeMaterialConnectionPoint;
  118664. /**
  118665. * Gets the gradient operand input component
  118666. */
  118667. readonly gradient: NodeMaterialConnectionPoint;
  118668. /**
  118669. * Gets the output component
  118670. */
  118671. readonly output: NodeMaterialConnectionPoint;
  118672. protected _buildBlock(state: NodeMaterialBuildState): this;
  118673. }
  118674. }
  118675. declare module BABYLON {
  118676. /**
  118677. * Block used to divide 2 vectors
  118678. */
  118679. export class DivideBlock extends NodeMaterialBlock {
  118680. /**
  118681. * Creates a new DivideBlock
  118682. * @param name defines the block name
  118683. */
  118684. constructor(name: string);
  118685. /**
  118686. * Gets the current class name
  118687. * @returns the class name
  118688. */
  118689. getClassName(): string;
  118690. /**
  118691. * Gets the left operand input component
  118692. */
  118693. readonly left: NodeMaterialConnectionPoint;
  118694. /**
  118695. * Gets the right operand input component
  118696. */
  118697. readonly right: NodeMaterialConnectionPoint;
  118698. /**
  118699. * Gets the output component
  118700. */
  118701. readonly output: NodeMaterialConnectionPoint;
  118702. protected _buildBlock(state: NodeMaterialBuildState): this;
  118703. }
  118704. }
  118705. declare module BABYLON {
  118706. /**
  118707. * Block used to subtract 2 vectors
  118708. */
  118709. export class SubtractBlock extends NodeMaterialBlock {
  118710. /**
  118711. * Creates a new SubtractBlock
  118712. * @param name defines the block name
  118713. */
  118714. constructor(name: string);
  118715. /**
  118716. * Gets the current class name
  118717. * @returns the class name
  118718. */
  118719. getClassName(): string;
  118720. /**
  118721. * Gets the left operand input component
  118722. */
  118723. readonly left: NodeMaterialConnectionPoint;
  118724. /**
  118725. * Gets the right operand input component
  118726. */
  118727. readonly right: NodeMaterialConnectionPoint;
  118728. /**
  118729. * Gets the output component
  118730. */
  118731. readonly output: NodeMaterialConnectionPoint;
  118732. protected _buildBlock(state: NodeMaterialBuildState): this;
  118733. }
  118734. }
  118735. declare module BABYLON {
  118736. /**
  118737. * Block used to step a value
  118738. */
  118739. export class StepBlock extends NodeMaterialBlock {
  118740. /**
  118741. * Creates a new AddBlock
  118742. * @param name defines the block name
  118743. */
  118744. constructor(name: string);
  118745. /**
  118746. * Gets the current class name
  118747. * @returns the class name
  118748. */
  118749. getClassName(): string;
  118750. /**
  118751. * Gets the value operand input component
  118752. */
  118753. readonly value: NodeMaterialConnectionPoint;
  118754. /**
  118755. * Gets the edge operand input component
  118756. */
  118757. readonly edge: NodeMaterialConnectionPoint;
  118758. /**
  118759. * Gets the output component
  118760. */
  118761. readonly output: NodeMaterialConnectionPoint;
  118762. protected _buildBlock(state: NodeMaterialBuildState): this;
  118763. }
  118764. }
  118765. declare module BABYLON {
  118766. /**
  118767. * Block used to convert color to vector and vice versa
  118768. */
  118769. export class TypeConverterBlock extends NodeMaterialBlock {
  118770. /**
  118771. * Creates a new TypeConverterBlock
  118772. * @param name defines the block name
  118773. */
  118774. constructor(name: string);
  118775. /**
  118776. * Gets the current class name
  118777. * @returns the class name
  118778. */
  118779. getClassName(): string;
  118780. /**
  118781. * Gets the input component
  118782. */
  118783. readonly input: NodeMaterialConnectionPoint;
  118784. /**
  118785. * Gets the output component
  118786. */
  118787. readonly output: NodeMaterialConnectionPoint;
  118788. protected _buildBlock(state: NodeMaterialBuildState): this;
  118789. }
  118790. }
  118791. declare module BABYLON {
  118792. /**
  118793. * Effect Render Options
  118794. */
  118795. export interface IEffectRendererOptions {
  118796. /**
  118797. * Defines the vertices positions.
  118798. */
  118799. positions?: number[];
  118800. /**
  118801. * Defines the indices.
  118802. */
  118803. indices?: number[];
  118804. }
  118805. /**
  118806. * Helper class to render one or more effects
  118807. */
  118808. export class EffectRenderer {
  118809. private engine;
  118810. private static _DefaultOptions;
  118811. private _vertexBuffers;
  118812. private _indexBuffer;
  118813. private _ringBufferIndex;
  118814. private _ringScreenBuffer;
  118815. private _fullscreenViewport;
  118816. private _getNextFrameBuffer;
  118817. /**
  118818. * Creates an effect renderer
  118819. * @param engine the engine to use for rendering
  118820. * @param options defines the options of the effect renderer
  118821. */
  118822. constructor(engine: Engine, options?: IEffectRendererOptions);
  118823. /**
  118824. * Sets the current viewport in normalized coordinates 0-1
  118825. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  118826. */
  118827. setViewport(viewport?: Viewport): void;
  118828. /**
  118829. * Sets the current effect wrapper to use during draw.
  118830. * The effect needs to be ready before calling this api.
  118831. * This also sets the default full screen position attribute.
  118832. * @param effectWrapper Defines the effect to draw with
  118833. */
  118834. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  118835. /**
  118836. * Draws a full screen quad.
  118837. */
  118838. draw(): void;
  118839. /**
  118840. * renders one or more effects to a specified texture
  118841. * @param effectWrappers list of effects to renderer
  118842. * @param outputTexture texture to draw to, if null it will render to the screen
  118843. */
  118844. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  118845. /**
  118846. * Disposes of the effect renderer
  118847. */
  118848. dispose(): void;
  118849. }
  118850. /**
  118851. * Options to create an EffectWrapper
  118852. */
  118853. interface EffectWrapperCreationOptions {
  118854. /**
  118855. * Engine to use to create the effect
  118856. */
  118857. engine: Engine;
  118858. /**
  118859. * Fragment shader for the effect
  118860. */
  118861. fragmentShader: string;
  118862. /**
  118863. * Vertex shader for the effect
  118864. */
  118865. vertexShader?: string;
  118866. /**
  118867. * Attributes to use in the shader
  118868. */
  118869. attributeNames?: Array<string>;
  118870. /**
  118871. * Uniforms to use in the shader
  118872. */
  118873. uniformNames?: Array<string>;
  118874. /**
  118875. * Texture sampler names to use in the shader
  118876. */
  118877. samplerNames?: Array<string>;
  118878. /**
  118879. * The friendly name of the effect displayed in Spector.
  118880. */
  118881. name?: string;
  118882. }
  118883. /**
  118884. * Wraps an effect to be used for rendering
  118885. */
  118886. export class EffectWrapper {
  118887. /**
  118888. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  118889. */
  118890. onApplyObservable: Observable<{}>;
  118891. /**
  118892. * The underlying effect
  118893. */
  118894. effect: Effect;
  118895. /**
  118896. * Creates an effect to be renderer
  118897. * @param creationOptions options to create the effect
  118898. */
  118899. constructor(creationOptions: EffectWrapperCreationOptions);
  118900. /**
  118901. * Disposes of the effect wrapper
  118902. */
  118903. dispose(): void;
  118904. }
  118905. }
  118906. declare module BABYLON {
  118907. /**
  118908. * Helper class to push actions to a pool of workers.
  118909. */
  118910. export class WorkerPool implements IDisposable {
  118911. private _workerInfos;
  118912. private _pendingActions;
  118913. /**
  118914. * Constructor
  118915. * @param workers Array of workers to use for actions
  118916. */
  118917. constructor(workers: Array<Worker>);
  118918. /**
  118919. * Terminates all workers and clears any pending actions.
  118920. */
  118921. dispose(): void;
  118922. /**
  118923. * Pushes an action to the worker pool. If all the workers are active, the action will be
  118924. * pended until a worker has completed its action.
  118925. * @param action The action to perform. Call onComplete when the action is complete.
  118926. */
  118927. push(action: (worker: Worker, onComplete: () => void) => void): void;
  118928. private _execute;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /**
  118933. * Configuration for Draco compression
  118934. */
  118935. export interface IDracoCompressionConfiguration {
  118936. /**
  118937. * Configuration for the decoder.
  118938. */
  118939. decoder: {
  118940. /**
  118941. * The url to the WebAssembly module.
  118942. */
  118943. wasmUrl?: string;
  118944. /**
  118945. * The url to the WebAssembly binary.
  118946. */
  118947. wasmBinaryUrl?: string;
  118948. /**
  118949. * The url to the fallback JavaScript module.
  118950. */
  118951. fallbackUrl?: string;
  118952. };
  118953. }
  118954. /**
  118955. * Draco compression (https://google.github.io/draco/)
  118956. *
  118957. * This class wraps the Draco module.
  118958. *
  118959. * **Encoder**
  118960. *
  118961. * The encoder is not currently implemented.
  118962. *
  118963. * **Decoder**
  118964. *
  118965. * 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.
  118966. *
  118967. * To update the configuration, use the following code:
  118968. * ```javascript
  118969. * DracoCompression.Configuration = {
  118970. * decoder: {
  118971. * wasmUrl: "<url to the WebAssembly library>",
  118972. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  118973. * fallbackUrl: "<url to the fallback JavaScript library>",
  118974. * }
  118975. * };
  118976. * ```
  118977. *
  118978. * 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.
  118979. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  118980. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  118981. *
  118982. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  118983. * ```javascript
  118984. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  118985. * ```
  118986. *
  118987. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  118988. */
  118989. export class DracoCompression implements IDisposable {
  118990. private _workerPoolPromise?;
  118991. private _decoderModulePromise?;
  118992. /**
  118993. * The configuration. Defaults to the following urls:
  118994. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  118995. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  118996. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  118997. */
  118998. static Configuration: IDracoCompressionConfiguration;
  118999. /**
  119000. * Returns true if the decoder configuration is available.
  119001. */
  119002. static readonly DecoderAvailable: boolean;
  119003. /**
  119004. * Default number of workers to create when creating the draco compression object.
  119005. */
  119006. static DefaultNumWorkers: number;
  119007. private static GetDefaultNumWorkers;
  119008. private static _Default;
  119009. /**
  119010. * Default instance for the draco compression object.
  119011. */
  119012. static readonly Default: DracoCompression;
  119013. /**
  119014. * Constructor
  119015. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  119016. */
  119017. constructor(numWorkers?: number);
  119018. /**
  119019. * Stop all async operations and release resources.
  119020. */
  119021. dispose(): void;
  119022. /**
  119023. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  119024. * @returns a promise that resolves when ready
  119025. */
  119026. whenReadyAsync(): Promise<void>;
  119027. /**
  119028. * Decode Draco compressed mesh data to vertex data.
  119029. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  119030. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  119031. * @returns A promise that resolves with the decoded vertex data
  119032. */
  119033. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  119034. [kind: string]: number;
  119035. }): Promise<VertexData>;
  119036. }
  119037. }
  119038. declare module BABYLON {
  119039. /**
  119040. * Class for building Constructive Solid Geometry
  119041. */
  119042. export class CSG {
  119043. private polygons;
  119044. /**
  119045. * The world matrix
  119046. */
  119047. matrix: Matrix;
  119048. /**
  119049. * Stores the position
  119050. */
  119051. position: Vector3;
  119052. /**
  119053. * Stores the rotation
  119054. */
  119055. rotation: Vector3;
  119056. /**
  119057. * Stores the rotation quaternion
  119058. */
  119059. rotationQuaternion: Nullable<Quaternion>;
  119060. /**
  119061. * Stores the scaling vector
  119062. */
  119063. scaling: Vector3;
  119064. /**
  119065. * Convert the Mesh to CSG
  119066. * @param mesh The Mesh to convert to CSG
  119067. * @returns A new CSG from the Mesh
  119068. */
  119069. static FromMesh(mesh: Mesh): CSG;
  119070. /**
  119071. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  119072. * @param polygons Polygons used to construct a CSG solid
  119073. */
  119074. private static FromPolygons;
  119075. /**
  119076. * Clones, or makes a deep copy, of the CSG
  119077. * @returns A new CSG
  119078. */
  119079. clone(): CSG;
  119080. /**
  119081. * Unions this CSG with another CSG
  119082. * @param csg The CSG to union against this CSG
  119083. * @returns The unioned CSG
  119084. */
  119085. union(csg: CSG): CSG;
  119086. /**
  119087. * Unions this CSG with another CSG in place
  119088. * @param csg The CSG to union against this CSG
  119089. */
  119090. unionInPlace(csg: CSG): void;
  119091. /**
  119092. * Subtracts this CSG with another CSG
  119093. * @param csg The CSG to subtract against this CSG
  119094. * @returns A new CSG
  119095. */
  119096. subtract(csg: CSG): CSG;
  119097. /**
  119098. * Subtracts this CSG with another CSG in place
  119099. * @param csg The CSG to subtact against this CSG
  119100. */
  119101. subtractInPlace(csg: CSG): void;
  119102. /**
  119103. * Intersect this CSG with another CSG
  119104. * @param csg The CSG to intersect against this CSG
  119105. * @returns A new CSG
  119106. */
  119107. intersect(csg: CSG): CSG;
  119108. /**
  119109. * Intersects this CSG with another CSG in place
  119110. * @param csg The CSG to intersect against this CSG
  119111. */
  119112. intersectInPlace(csg: CSG): void;
  119113. /**
  119114. * Return a new CSG solid with solid and empty space switched. This solid is
  119115. * not modified.
  119116. * @returns A new CSG solid with solid and empty space switched
  119117. */
  119118. inverse(): CSG;
  119119. /**
  119120. * Inverses the CSG in place
  119121. */
  119122. inverseInPlace(): void;
  119123. /**
  119124. * This is used to keep meshes transformations so they can be restored
  119125. * when we build back a Babylon Mesh
  119126. * NB : All CSG operations are performed in world coordinates
  119127. * @param csg The CSG to copy the transform attributes from
  119128. * @returns This CSG
  119129. */
  119130. copyTransformAttributes(csg: CSG): CSG;
  119131. /**
  119132. * Build Raw mesh from CSG
  119133. * Coordinates here are in world space
  119134. * @param name The name of the mesh geometry
  119135. * @param scene The Scene
  119136. * @param keepSubMeshes Specifies if the submeshes should be kept
  119137. * @returns A new Mesh
  119138. */
  119139. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119140. /**
  119141. * Build Mesh from CSG taking material and transforms into account
  119142. * @param name The name of the Mesh
  119143. * @param material The material of the Mesh
  119144. * @param scene The Scene
  119145. * @param keepSubMeshes Specifies if submeshes should be kept
  119146. * @returns The new Mesh
  119147. */
  119148. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119149. }
  119150. }
  119151. declare module BABYLON {
  119152. /**
  119153. * Class used to create a trail following a mesh
  119154. */
  119155. export class TrailMesh extends Mesh {
  119156. private _generator;
  119157. private _autoStart;
  119158. private _running;
  119159. private _diameter;
  119160. private _length;
  119161. private _sectionPolygonPointsCount;
  119162. private _sectionVectors;
  119163. private _sectionNormalVectors;
  119164. private _beforeRenderObserver;
  119165. /**
  119166. * @constructor
  119167. * @param name The value used by scene.getMeshByName() to do a lookup.
  119168. * @param generator The mesh to generate a trail.
  119169. * @param scene The scene to add this mesh to.
  119170. * @param diameter Diameter of trailing mesh. Default is 1.
  119171. * @param length Length of trailing mesh. Default is 60.
  119172. * @param autoStart Automatically start trailing mesh. Default true.
  119173. */
  119174. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  119175. /**
  119176. * "TrailMesh"
  119177. * @returns "TrailMesh"
  119178. */
  119179. getClassName(): string;
  119180. private _createMesh;
  119181. /**
  119182. * Start trailing mesh.
  119183. */
  119184. start(): void;
  119185. /**
  119186. * Stop trailing mesh.
  119187. */
  119188. stop(): void;
  119189. /**
  119190. * Update trailing mesh geometry.
  119191. */
  119192. update(): void;
  119193. /**
  119194. * Returns a new TrailMesh object.
  119195. * @param name is a string, the name given to the new mesh
  119196. * @param newGenerator use new generator object for cloned trail mesh
  119197. * @returns a new mesh
  119198. */
  119199. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  119200. /**
  119201. * Serializes this trail mesh
  119202. * @param serializationObject object to write serialization to
  119203. */
  119204. serialize(serializationObject: any): void;
  119205. /**
  119206. * Parses a serialized trail mesh
  119207. * @param parsedMesh the serialized mesh
  119208. * @param scene the scene to create the trail mesh in
  119209. * @returns the created trail mesh
  119210. */
  119211. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  119212. }
  119213. }
  119214. declare module BABYLON {
  119215. /**
  119216. * Class containing static functions to help procedurally build meshes
  119217. */
  119218. export class TiledBoxBuilder {
  119219. /**
  119220. * Creates a box mesh
  119221. * 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)
  119222. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119226. * @param name defines the name of the mesh
  119227. * @param options defines the options used to create the mesh
  119228. * @param scene defines the hosting scene
  119229. * @returns the box mesh
  119230. */
  119231. static CreateTiledBox(name: string, options: {
  119232. pattern?: number;
  119233. width?: number;
  119234. height?: number;
  119235. depth?: number;
  119236. tileSize?: number;
  119237. tileWidth?: number;
  119238. tileHeight?: number;
  119239. alignHorizontal?: number;
  119240. alignVertical?: number;
  119241. faceUV?: Vector4[];
  119242. faceColors?: Color4[];
  119243. sideOrientation?: number;
  119244. updatable?: boolean;
  119245. }, scene?: Nullable<Scene>): Mesh;
  119246. }
  119247. }
  119248. declare module BABYLON {
  119249. /**
  119250. * Class containing static functions to help procedurally build meshes
  119251. */
  119252. export class TorusKnotBuilder {
  119253. /**
  119254. * Creates a torus knot mesh
  119255. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119256. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119257. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119258. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119262. * @param name defines the name of the mesh
  119263. * @param options defines the options used to create the mesh
  119264. * @param scene defines the hosting scene
  119265. * @returns the torus knot mesh
  119266. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119267. */
  119268. static CreateTorusKnot(name: string, options: {
  119269. radius?: number;
  119270. tube?: number;
  119271. radialSegments?: number;
  119272. tubularSegments?: number;
  119273. p?: number;
  119274. q?: number;
  119275. updatable?: boolean;
  119276. sideOrientation?: number;
  119277. frontUVs?: Vector4;
  119278. backUVs?: Vector4;
  119279. }, scene: any): Mesh;
  119280. }
  119281. }
  119282. declare module BABYLON {
  119283. /**
  119284. * Polygon
  119285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  119286. */
  119287. export class Polygon {
  119288. /**
  119289. * Creates a rectangle
  119290. * @param xmin bottom X coord
  119291. * @param ymin bottom Y coord
  119292. * @param xmax top X coord
  119293. * @param ymax top Y coord
  119294. * @returns points that make the resulting rectation
  119295. */
  119296. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  119297. /**
  119298. * Creates a circle
  119299. * @param radius radius of circle
  119300. * @param cx scale in x
  119301. * @param cy scale in y
  119302. * @param numberOfSides number of sides that make up the circle
  119303. * @returns points that make the resulting circle
  119304. */
  119305. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  119306. /**
  119307. * Creates a polygon from input string
  119308. * @param input Input polygon data
  119309. * @returns the parsed points
  119310. */
  119311. static Parse(input: string): Vector2[];
  119312. /**
  119313. * Starts building a polygon from x and y coordinates
  119314. * @param x x coordinate
  119315. * @param y y coordinate
  119316. * @returns the started path2
  119317. */
  119318. static StartingAt(x: number, y: number): Path2;
  119319. }
  119320. /**
  119321. * Builds a polygon
  119322. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  119323. */
  119324. export class PolygonMeshBuilder {
  119325. private _points;
  119326. private _outlinepoints;
  119327. private _holes;
  119328. private _name;
  119329. private _scene;
  119330. private _epoints;
  119331. private _eholes;
  119332. private _addToepoint;
  119333. /**
  119334. * Babylon reference to the earcut plugin.
  119335. */
  119336. bjsEarcut: any;
  119337. /**
  119338. * Creates a PolygonMeshBuilder
  119339. * @param name name of the builder
  119340. * @param contours Path of the polygon
  119341. * @param scene scene to add to when creating the mesh
  119342. * @param earcutInjection can be used to inject your own earcut reference
  119343. */
  119344. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  119345. /**
  119346. * Adds a whole within the polygon
  119347. * @param hole Array of points defining the hole
  119348. * @returns this
  119349. */
  119350. addHole(hole: Vector2[]): PolygonMeshBuilder;
  119351. /**
  119352. * Creates the polygon
  119353. * @param updatable If the mesh should be updatable
  119354. * @param depth The depth of the mesh created
  119355. * @returns the created mesh
  119356. */
  119357. build(updatable?: boolean, depth?: number): Mesh;
  119358. /**
  119359. * Creates the polygon
  119360. * @param depth The depth of the mesh created
  119361. * @returns the created VertexData
  119362. */
  119363. buildVertexData(depth?: number): VertexData;
  119364. /**
  119365. * Adds a side to the polygon
  119366. * @param positions points that make the polygon
  119367. * @param normals normals of the polygon
  119368. * @param uvs uvs of the polygon
  119369. * @param indices indices of the polygon
  119370. * @param bounds bounds of the polygon
  119371. * @param points points of the polygon
  119372. * @param depth depth of the polygon
  119373. * @param flip flip of the polygon
  119374. */
  119375. private addSide;
  119376. }
  119377. }
  119378. declare module BABYLON {
  119379. /**
  119380. * Class containing static functions to help procedurally build meshes
  119381. */
  119382. export class PolygonBuilder {
  119383. /**
  119384. * Creates a polygon mesh
  119385. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119386. * * 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
  119387. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119390. * * Remember you can only change the shape positions, not their number when updating a polygon
  119391. * @param name defines the name of the mesh
  119392. * @param options defines the options used to create the mesh
  119393. * @param scene defines the hosting scene
  119394. * @param earcutInjection can be used to inject your own earcut reference
  119395. * @returns the polygon mesh
  119396. */
  119397. static CreatePolygon(name: string, options: {
  119398. shape: Vector3[];
  119399. holes?: Vector3[][];
  119400. depth?: number;
  119401. faceUV?: Vector4[];
  119402. faceColors?: Color4[];
  119403. updatable?: boolean;
  119404. sideOrientation?: number;
  119405. frontUVs?: Vector4;
  119406. backUVs?: Vector4;
  119407. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119408. /**
  119409. * Creates an extruded polygon mesh, with depth in the Y direction.
  119410. * * 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)
  119411. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119412. * @param name defines the name of the mesh
  119413. * @param options defines the options used to create the mesh
  119414. * @param scene defines the hosting scene
  119415. * @param earcutInjection can be used to inject your own earcut reference
  119416. * @returns the polygon mesh
  119417. */
  119418. static ExtrudePolygon(name: string, options: {
  119419. shape: Vector3[];
  119420. holes?: Vector3[][];
  119421. depth?: number;
  119422. faceUV?: Vector4[];
  119423. faceColors?: Color4[];
  119424. updatable?: boolean;
  119425. sideOrientation?: number;
  119426. frontUVs?: Vector4;
  119427. backUVs?: Vector4;
  119428. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119429. }
  119430. }
  119431. declare module BABYLON {
  119432. /**
  119433. * Class containing static functions to help procedurally build meshes
  119434. */
  119435. export class LatheBuilder {
  119436. /**
  119437. * Creates lathe mesh.
  119438. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119439. * * 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
  119440. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119441. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119442. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119443. * * 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
  119444. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119445. * * 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
  119446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119450. * @param name defines the name of the mesh
  119451. * @param options defines the options used to create the mesh
  119452. * @param scene defines the hosting scene
  119453. * @returns the lathe mesh
  119454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119455. */
  119456. static CreateLathe(name: string, options: {
  119457. shape: Vector3[];
  119458. radius?: number;
  119459. tessellation?: number;
  119460. clip?: number;
  119461. arc?: number;
  119462. closed?: boolean;
  119463. updatable?: boolean;
  119464. sideOrientation?: number;
  119465. frontUVs?: Vector4;
  119466. backUVs?: Vector4;
  119467. cap?: number;
  119468. invertUV?: boolean;
  119469. }, scene?: Nullable<Scene>): Mesh;
  119470. }
  119471. }
  119472. declare module BABYLON {
  119473. /**
  119474. * Class containing static functions to help procedurally build meshes
  119475. */
  119476. export class TiledPlaneBuilder {
  119477. /**
  119478. * Creates a tiled plane mesh
  119479. * * The parameter `pattern` will, depending on value, do nothing or
  119480. * * * flip (reflect about central vertical) alternate tiles across and up
  119481. * * * flip every tile on alternate rows
  119482. * * * rotate (180 degs) alternate tiles across and up
  119483. * * * rotate every tile on alternate rows
  119484. * * * flip and rotate alternate tiles across and up
  119485. * * * flip and rotate every tile on alternate rows
  119486. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  119487. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  119488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119490. * * 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)
  119491. * * 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)
  119492. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119493. * @param name defines the name of the mesh
  119494. * @param options defines the options used to create the mesh
  119495. * @param scene defines the hosting scene
  119496. * @returns the box mesh
  119497. */
  119498. static CreateTiledPlane(name: string, options: {
  119499. pattern?: number;
  119500. tileSize?: number;
  119501. tileWidth?: number;
  119502. tileHeight?: number;
  119503. size?: number;
  119504. width?: number;
  119505. height?: number;
  119506. alignHorizontal?: number;
  119507. alignVertical?: number;
  119508. sideOrientation?: number;
  119509. frontUVs?: Vector4;
  119510. backUVs?: Vector4;
  119511. updatable?: boolean;
  119512. }, scene?: Nullable<Scene>): Mesh;
  119513. }
  119514. }
  119515. declare module BABYLON {
  119516. /**
  119517. * Class containing static functions to help procedurally build meshes
  119518. */
  119519. export class TubeBuilder {
  119520. /**
  119521. * Creates a tube mesh.
  119522. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119523. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119524. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119525. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119526. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119527. * * 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)
  119528. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119529. * * 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
  119530. * * 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
  119531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119535. * @param name defines the name of the mesh
  119536. * @param options defines the options used to create the mesh
  119537. * @param scene defines the hosting scene
  119538. * @returns the tube mesh
  119539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119540. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119541. */
  119542. static CreateTube(name: string, options: {
  119543. path: Vector3[];
  119544. radius?: number;
  119545. tessellation?: number;
  119546. radiusFunction?: {
  119547. (i: number, distance: number): number;
  119548. };
  119549. cap?: number;
  119550. arc?: number;
  119551. updatable?: boolean;
  119552. sideOrientation?: number;
  119553. frontUVs?: Vector4;
  119554. backUVs?: Vector4;
  119555. instance?: Mesh;
  119556. invertUV?: boolean;
  119557. }, scene?: Nullable<Scene>): Mesh;
  119558. }
  119559. }
  119560. declare module BABYLON {
  119561. /**
  119562. * Class containing static functions to help procedurally build meshes
  119563. */
  119564. export class IcoSphereBuilder {
  119565. /**
  119566. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119567. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119568. * * 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`)
  119569. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119570. * * 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
  119571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119574. * @param name defines the name of the mesh
  119575. * @param options defines the options used to create the mesh
  119576. * @param scene defines the hosting scene
  119577. * @returns the icosahedron mesh
  119578. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119579. */
  119580. static CreateIcoSphere(name: string, options: {
  119581. radius?: number;
  119582. radiusX?: number;
  119583. radiusY?: number;
  119584. radiusZ?: number;
  119585. flat?: boolean;
  119586. subdivisions?: number;
  119587. sideOrientation?: number;
  119588. frontUVs?: Vector4;
  119589. backUVs?: Vector4;
  119590. updatable?: boolean;
  119591. }, scene?: Nullable<Scene>): Mesh;
  119592. }
  119593. }
  119594. declare module BABYLON {
  119595. /**
  119596. * Class containing static functions to help procedurally build meshes
  119597. */
  119598. export class DecalBuilder {
  119599. /**
  119600. * Creates a decal mesh.
  119601. * 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
  119602. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119603. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119604. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119605. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119606. * @param name defines the name of the mesh
  119607. * @param sourceMesh defines the mesh where the decal must be applied
  119608. * @param options defines the options used to create the mesh
  119609. * @param scene defines the hosting scene
  119610. * @returns the decal mesh
  119611. * @see https://doc.babylonjs.com/how_to/decals
  119612. */
  119613. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119614. position?: Vector3;
  119615. normal?: Vector3;
  119616. size?: Vector3;
  119617. angle?: number;
  119618. }): Mesh;
  119619. }
  119620. }
  119621. declare module BABYLON {
  119622. /**
  119623. * Class containing static functions to help procedurally build meshes
  119624. */
  119625. export class MeshBuilder {
  119626. /**
  119627. * Creates a box mesh
  119628. * * The parameter `size` sets the size (float) of each box side (default 1)
  119629. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119630. * * 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)
  119631. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119635. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119636. * @param name defines the name of the mesh
  119637. * @param options defines the options used to create the mesh
  119638. * @param scene defines the hosting scene
  119639. * @returns the box mesh
  119640. */
  119641. static CreateBox(name: string, options: {
  119642. size?: number;
  119643. width?: number;
  119644. height?: number;
  119645. depth?: number;
  119646. faceUV?: Vector4[];
  119647. faceColors?: Color4[];
  119648. sideOrientation?: number;
  119649. frontUVs?: Vector4;
  119650. backUVs?: Vector4;
  119651. updatable?: boolean;
  119652. }, scene?: Nullable<Scene>): Mesh;
  119653. /**
  119654. * Creates a tiled box mesh
  119655. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119657. * @param name defines the name of the mesh
  119658. * @param options defines the options used to create the mesh
  119659. * @param scene defines the hosting scene
  119660. * @returns the tiled box mesh
  119661. */
  119662. static CreateTiledBox(name: string, options: {
  119663. pattern?: number;
  119664. size?: number;
  119665. width?: number;
  119666. height?: number;
  119667. depth: number;
  119668. tileSize?: number;
  119669. tileWidth?: number;
  119670. tileHeight?: number;
  119671. faceUV?: Vector4[];
  119672. faceColors?: Color4[];
  119673. alignHorizontal?: number;
  119674. alignVertical?: number;
  119675. sideOrientation?: number;
  119676. updatable?: boolean;
  119677. }, scene?: Nullable<Scene>): Mesh;
  119678. /**
  119679. * Creates a sphere mesh
  119680. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119681. * * 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`)
  119682. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119683. * * 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
  119684. * * 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)
  119685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119688. * @param name defines the name of the mesh
  119689. * @param options defines the options used to create the mesh
  119690. * @param scene defines the hosting scene
  119691. * @returns the sphere mesh
  119692. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119693. */
  119694. static CreateSphere(name: string, options: {
  119695. segments?: number;
  119696. diameter?: number;
  119697. diameterX?: number;
  119698. diameterY?: number;
  119699. diameterZ?: number;
  119700. arc?: number;
  119701. slice?: number;
  119702. sideOrientation?: number;
  119703. frontUVs?: Vector4;
  119704. backUVs?: Vector4;
  119705. updatable?: boolean;
  119706. }, scene?: Nullable<Scene>): Mesh;
  119707. /**
  119708. * Creates a plane polygonal mesh. By default, this is a disc
  119709. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119710. * * 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
  119711. * * 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
  119712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119715. * @param name defines the name of the mesh
  119716. * @param options defines the options used to create the mesh
  119717. * @param scene defines the hosting scene
  119718. * @returns the plane polygonal mesh
  119719. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119720. */
  119721. static CreateDisc(name: string, options: {
  119722. radius?: number;
  119723. tessellation?: number;
  119724. arc?: number;
  119725. updatable?: boolean;
  119726. sideOrientation?: number;
  119727. frontUVs?: Vector4;
  119728. backUVs?: Vector4;
  119729. }, scene?: Nullable<Scene>): Mesh;
  119730. /**
  119731. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119732. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119733. * * 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`)
  119734. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119735. * * 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
  119736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119739. * @param name defines the name of the mesh
  119740. * @param options defines the options used to create the mesh
  119741. * @param scene defines the hosting scene
  119742. * @returns the icosahedron mesh
  119743. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119744. */
  119745. static CreateIcoSphere(name: string, options: {
  119746. radius?: number;
  119747. radiusX?: number;
  119748. radiusY?: number;
  119749. radiusZ?: number;
  119750. flat?: boolean;
  119751. subdivisions?: number;
  119752. sideOrientation?: number;
  119753. frontUVs?: Vector4;
  119754. backUVs?: Vector4;
  119755. updatable?: boolean;
  119756. }, scene?: Nullable<Scene>): Mesh;
  119757. /**
  119758. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119759. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119760. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119761. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119762. * * 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
  119763. * * 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
  119764. * * 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
  119765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119768. * * 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
  119769. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119770. * * 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
  119771. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119773. * @param name defines the name of the mesh
  119774. * @param options defines the options used to create the mesh
  119775. * @param scene defines the hosting scene
  119776. * @returns the ribbon mesh
  119777. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119778. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119779. */
  119780. static CreateRibbon(name: string, options: {
  119781. pathArray: Vector3[][];
  119782. closeArray?: boolean;
  119783. closePath?: boolean;
  119784. offset?: number;
  119785. updatable?: boolean;
  119786. sideOrientation?: number;
  119787. frontUVs?: Vector4;
  119788. backUVs?: Vector4;
  119789. instance?: Mesh;
  119790. invertUV?: boolean;
  119791. uvs?: Vector2[];
  119792. colors?: Color4[];
  119793. }, scene?: Nullable<Scene>): Mesh;
  119794. /**
  119795. * Creates a cylinder or a cone mesh
  119796. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119797. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119798. * * 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.
  119799. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119800. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119801. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119802. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119803. * * 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).
  119804. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119805. * * 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).
  119806. * * 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
  119807. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119808. * * 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
  119809. * * 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.
  119810. * * If `enclose` is false, a ring surface is one element.
  119811. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119812. * * 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
  119813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119816. * @param name defines the name of the mesh
  119817. * @param options defines the options used to create the mesh
  119818. * @param scene defines the hosting scene
  119819. * @returns the cylinder mesh
  119820. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119821. */
  119822. static CreateCylinder(name: string, options: {
  119823. height?: number;
  119824. diameterTop?: number;
  119825. diameterBottom?: number;
  119826. diameter?: number;
  119827. tessellation?: number;
  119828. subdivisions?: number;
  119829. arc?: number;
  119830. faceColors?: Color4[];
  119831. faceUV?: Vector4[];
  119832. updatable?: boolean;
  119833. hasRings?: boolean;
  119834. enclose?: boolean;
  119835. cap?: number;
  119836. sideOrientation?: number;
  119837. frontUVs?: Vector4;
  119838. backUVs?: Vector4;
  119839. }, scene?: Nullable<Scene>): Mesh;
  119840. /**
  119841. * Creates a torus mesh
  119842. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119843. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119844. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119848. * @param name defines the name of the mesh
  119849. * @param options defines the options used to create the mesh
  119850. * @param scene defines the hosting scene
  119851. * @returns the torus mesh
  119852. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119853. */
  119854. static CreateTorus(name: string, options: {
  119855. diameter?: number;
  119856. thickness?: number;
  119857. tessellation?: number;
  119858. updatable?: boolean;
  119859. sideOrientation?: number;
  119860. frontUVs?: Vector4;
  119861. backUVs?: Vector4;
  119862. }, scene?: Nullable<Scene>): Mesh;
  119863. /**
  119864. * Creates a torus knot mesh
  119865. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119866. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119867. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119868. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119872. * @param name defines the name of the mesh
  119873. * @param options defines the options used to create the mesh
  119874. * @param scene defines the hosting scene
  119875. * @returns the torus knot mesh
  119876. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119877. */
  119878. static CreateTorusKnot(name: string, options: {
  119879. radius?: number;
  119880. tube?: number;
  119881. radialSegments?: number;
  119882. tubularSegments?: number;
  119883. p?: number;
  119884. q?: number;
  119885. updatable?: boolean;
  119886. sideOrientation?: number;
  119887. frontUVs?: Vector4;
  119888. backUVs?: Vector4;
  119889. }, scene?: Nullable<Scene>): Mesh;
  119890. /**
  119891. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119892. * * 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
  119893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119894. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119895. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119896. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119898. * * 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
  119899. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119902. * @param name defines the name of the new line system
  119903. * @param options defines the options used to create the line system
  119904. * @param scene defines the hosting scene
  119905. * @returns a new line system mesh
  119906. */
  119907. static CreateLineSystem(name: string, options: {
  119908. lines: Vector3[][];
  119909. updatable?: boolean;
  119910. instance?: Nullable<LinesMesh>;
  119911. colors?: Nullable<Color4[][]>;
  119912. useVertexAlpha?: boolean;
  119913. }, scene: Nullable<Scene>): LinesMesh;
  119914. /**
  119915. * Creates a line mesh
  119916. * 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
  119917. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119918. * * The parameter `points` is an array successive Vector3
  119919. * * 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
  119920. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119921. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119922. * * When updating an instance, remember that only point positions can change, not the number of points
  119923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119925. * @param name defines the name of the new line system
  119926. * @param options defines the options used to create the line system
  119927. * @param scene defines the hosting scene
  119928. * @returns a new line mesh
  119929. */
  119930. static CreateLines(name: string, options: {
  119931. points: Vector3[];
  119932. updatable?: boolean;
  119933. instance?: Nullable<LinesMesh>;
  119934. colors?: Color4[];
  119935. useVertexAlpha?: boolean;
  119936. }, scene?: Nullable<Scene>): LinesMesh;
  119937. /**
  119938. * Creates a dashed line mesh
  119939. * * 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
  119940. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119941. * * The parameter `points` is an array successive Vector3
  119942. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119943. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119944. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119945. * * 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
  119946. * * When updating an instance, remember that only point positions can change, not the number of points
  119947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119948. * @param name defines the name of the mesh
  119949. * @param options defines the options used to create the mesh
  119950. * @param scene defines the hosting scene
  119951. * @returns the dashed line mesh
  119952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119953. */
  119954. static CreateDashedLines(name: string, options: {
  119955. points: Vector3[];
  119956. dashSize?: number;
  119957. gapSize?: number;
  119958. dashNb?: number;
  119959. updatable?: boolean;
  119960. instance?: LinesMesh;
  119961. }, scene?: Nullable<Scene>): LinesMesh;
  119962. /**
  119963. * 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.
  119964. * * 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.
  119965. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119966. * * 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.
  119967. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119968. * * 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
  119969. * * 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
  119970. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119975. * @param name defines the name of the mesh
  119976. * @param options defines the options used to create the mesh
  119977. * @param scene defines the hosting scene
  119978. * @returns the extruded shape mesh
  119979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119981. */
  119982. static ExtrudeShape(name: string, options: {
  119983. shape: Vector3[];
  119984. path: Vector3[];
  119985. scale?: number;
  119986. rotation?: number;
  119987. cap?: number;
  119988. updatable?: boolean;
  119989. sideOrientation?: number;
  119990. frontUVs?: Vector4;
  119991. backUVs?: Vector4;
  119992. instance?: Mesh;
  119993. invertUV?: boolean;
  119994. }, scene?: Nullable<Scene>): Mesh;
  119995. /**
  119996. * Creates an custom extruded shape mesh.
  119997. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119998. * * 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.
  119999. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120000. * * 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
  120001. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120002. * * 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
  120003. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120004. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120005. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120006. * * 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
  120007. * * 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
  120008. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120013. * @param name defines the name of the mesh
  120014. * @param options defines the options used to create the mesh
  120015. * @param scene defines the hosting scene
  120016. * @returns the custom extruded shape mesh
  120017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120020. */
  120021. static ExtrudeShapeCustom(name: string, options: {
  120022. shape: Vector3[];
  120023. path: Vector3[];
  120024. scaleFunction?: any;
  120025. rotationFunction?: any;
  120026. ribbonCloseArray?: boolean;
  120027. ribbonClosePath?: boolean;
  120028. cap?: number;
  120029. updatable?: boolean;
  120030. sideOrientation?: number;
  120031. frontUVs?: Vector4;
  120032. backUVs?: Vector4;
  120033. instance?: Mesh;
  120034. invertUV?: boolean;
  120035. }, scene?: Nullable<Scene>): Mesh;
  120036. /**
  120037. * Creates lathe mesh.
  120038. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120039. * * 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
  120040. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120041. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120042. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120043. * * 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
  120044. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120045. * * 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
  120046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120050. * @param name defines the name of the mesh
  120051. * @param options defines the options used to create the mesh
  120052. * @param scene defines the hosting scene
  120053. * @returns the lathe mesh
  120054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120055. */
  120056. static CreateLathe(name: string, options: {
  120057. shape: Vector3[];
  120058. radius?: number;
  120059. tessellation?: number;
  120060. clip?: number;
  120061. arc?: number;
  120062. closed?: boolean;
  120063. updatable?: boolean;
  120064. sideOrientation?: number;
  120065. frontUVs?: Vector4;
  120066. backUVs?: Vector4;
  120067. cap?: number;
  120068. invertUV?: boolean;
  120069. }, scene?: Nullable<Scene>): Mesh;
  120070. /**
  120071. * Creates a tiled plane mesh
  120072. * * You can set a limited pattern arrangement with the tiles
  120073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120076. * @param name defines the name of the mesh
  120077. * @param options defines the options used to create the mesh
  120078. * @param scene defines the hosting scene
  120079. * @returns the plane mesh
  120080. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120081. */
  120082. static CreateTiledPlane(name: string, options: {
  120083. pattern?: number;
  120084. tileSize?: number;
  120085. tileWidth?: number;
  120086. tileHeight?: number;
  120087. size?: number;
  120088. width?: number;
  120089. height?: number;
  120090. alignHorizontal?: number;
  120091. alignVertical?: number;
  120092. sideOrientation?: number;
  120093. frontUVs?: Vector4;
  120094. backUVs?: Vector4;
  120095. updatable?: boolean;
  120096. }, scene?: Nullable<Scene>): Mesh;
  120097. /**
  120098. * Creates a plane mesh
  120099. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120100. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120101. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120105. * @param name defines the name of the mesh
  120106. * @param options defines the options used to create the mesh
  120107. * @param scene defines the hosting scene
  120108. * @returns the plane mesh
  120109. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120110. */
  120111. static CreatePlane(name: string, options: {
  120112. size?: number;
  120113. width?: number;
  120114. height?: number;
  120115. sideOrientation?: number;
  120116. frontUVs?: Vector4;
  120117. backUVs?: Vector4;
  120118. updatable?: boolean;
  120119. sourcePlane?: Plane;
  120120. }, scene?: Nullable<Scene>): Mesh;
  120121. /**
  120122. * Creates a ground mesh
  120123. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  120124. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  120125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120126. * @param name defines the name of the mesh
  120127. * @param options defines the options used to create the mesh
  120128. * @param scene defines the hosting scene
  120129. * @returns the ground mesh
  120130. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  120131. */
  120132. static CreateGround(name: string, options: {
  120133. width?: number;
  120134. height?: number;
  120135. subdivisions?: number;
  120136. subdivisionsX?: number;
  120137. subdivisionsY?: number;
  120138. updatable?: boolean;
  120139. }, scene?: Nullable<Scene>): Mesh;
  120140. /**
  120141. * Creates a tiled ground mesh
  120142. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  120143. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  120144. * * 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
  120145. * * 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
  120146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120147. * @param name defines the name of the mesh
  120148. * @param options defines the options used to create the mesh
  120149. * @param scene defines the hosting scene
  120150. * @returns the tiled ground mesh
  120151. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  120152. */
  120153. static CreateTiledGround(name: string, options: {
  120154. xmin: number;
  120155. zmin: number;
  120156. xmax: number;
  120157. zmax: number;
  120158. subdivisions?: {
  120159. w: number;
  120160. h: number;
  120161. };
  120162. precision?: {
  120163. w: number;
  120164. h: number;
  120165. };
  120166. updatable?: boolean;
  120167. }, scene?: Nullable<Scene>): Mesh;
  120168. /**
  120169. * Creates a ground mesh from a height map
  120170. * * The parameter `url` sets the URL of the height map image resource.
  120171. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  120172. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  120173. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  120174. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  120175. * * 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.
  120176. * * 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).
  120177. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  120178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120179. * @param name defines the name of the mesh
  120180. * @param url defines the url to the height map
  120181. * @param options defines the options used to create the mesh
  120182. * @param scene defines the hosting scene
  120183. * @returns the ground mesh
  120184. * @see https://doc.babylonjs.com/babylon101/height_map
  120185. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  120186. */
  120187. static CreateGroundFromHeightMap(name: string, url: string, options: {
  120188. width?: number;
  120189. height?: number;
  120190. subdivisions?: number;
  120191. minHeight?: number;
  120192. maxHeight?: number;
  120193. colorFilter?: Color3;
  120194. alphaFilter?: number;
  120195. updatable?: boolean;
  120196. onReady?: (mesh: GroundMesh) => void;
  120197. }, scene?: Nullable<Scene>): GroundMesh;
  120198. /**
  120199. * Creates a polygon mesh
  120200. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120201. * * 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
  120202. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120205. * * Remember you can only change the shape positions, not their number when updating a polygon
  120206. * @param name defines the name of the mesh
  120207. * @param options defines the options used to create the mesh
  120208. * @param scene defines the hosting scene
  120209. * @param earcutInjection can be used to inject your own earcut reference
  120210. * @returns the polygon mesh
  120211. */
  120212. static CreatePolygon(name: string, options: {
  120213. shape: Vector3[];
  120214. holes?: Vector3[][];
  120215. depth?: number;
  120216. faceUV?: Vector4[];
  120217. faceColors?: Color4[];
  120218. updatable?: boolean;
  120219. sideOrientation?: number;
  120220. frontUVs?: Vector4;
  120221. backUVs?: Vector4;
  120222. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120223. /**
  120224. * Creates an extruded polygon mesh, with depth in the Y direction.
  120225. * * 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)
  120226. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120227. * @param name defines the name of the mesh
  120228. * @param options defines the options used to create the mesh
  120229. * @param scene defines the hosting scene
  120230. * @param earcutInjection can be used to inject your own earcut reference
  120231. * @returns the polygon mesh
  120232. */
  120233. static ExtrudePolygon(name: string, options: {
  120234. shape: Vector3[];
  120235. holes?: Vector3[][];
  120236. depth?: number;
  120237. faceUV?: Vector4[];
  120238. faceColors?: Color4[];
  120239. updatable?: boolean;
  120240. sideOrientation?: number;
  120241. frontUVs?: Vector4;
  120242. backUVs?: Vector4;
  120243. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120244. /**
  120245. * Creates a tube mesh.
  120246. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120247. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120248. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120249. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120250. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120251. * * 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)
  120252. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120253. * * 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
  120254. * * 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
  120255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120259. * @param name defines the name of the mesh
  120260. * @param options defines the options used to create the mesh
  120261. * @param scene defines the hosting scene
  120262. * @returns the tube mesh
  120263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120264. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120265. */
  120266. static CreateTube(name: string, options: {
  120267. path: Vector3[];
  120268. radius?: number;
  120269. tessellation?: number;
  120270. radiusFunction?: {
  120271. (i: number, distance: number): number;
  120272. };
  120273. cap?: number;
  120274. arc?: number;
  120275. updatable?: boolean;
  120276. sideOrientation?: number;
  120277. frontUVs?: Vector4;
  120278. backUVs?: Vector4;
  120279. instance?: Mesh;
  120280. invertUV?: boolean;
  120281. }, scene?: Nullable<Scene>): Mesh;
  120282. /**
  120283. * Creates a polyhedron mesh
  120284. * * 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
  120285. * * The parameter `size` (positive float, default 1) sets the polygon size
  120286. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120287. * * 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`
  120288. * * 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
  120289. * * 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)`)
  120290. * * 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
  120291. * * 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
  120292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120295. * @param name defines the name of the mesh
  120296. * @param options defines the options used to create the mesh
  120297. * @param scene defines the hosting scene
  120298. * @returns the polyhedron mesh
  120299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120300. */
  120301. static CreatePolyhedron(name: string, options: {
  120302. type?: number;
  120303. size?: number;
  120304. sizeX?: number;
  120305. sizeY?: number;
  120306. sizeZ?: number;
  120307. custom?: any;
  120308. faceUV?: Vector4[];
  120309. faceColors?: Color4[];
  120310. flat?: boolean;
  120311. updatable?: boolean;
  120312. sideOrientation?: number;
  120313. frontUVs?: Vector4;
  120314. backUVs?: Vector4;
  120315. }, scene?: Nullable<Scene>): Mesh;
  120316. /**
  120317. * Creates a decal mesh.
  120318. * 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
  120319. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120320. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120321. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120322. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120323. * @param name defines the name of the mesh
  120324. * @param sourceMesh defines the mesh where the decal must be applied
  120325. * @param options defines the options used to create the mesh
  120326. * @param scene defines the hosting scene
  120327. * @returns the decal mesh
  120328. * @see https://doc.babylonjs.com/how_to/decals
  120329. */
  120330. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120331. position?: Vector3;
  120332. normal?: Vector3;
  120333. size?: Vector3;
  120334. angle?: number;
  120335. }): Mesh;
  120336. }
  120337. }
  120338. declare module BABYLON {
  120339. /**
  120340. * A simplifier interface for future simplification implementations
  120341. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120342. */
  120343. export interface ISimplifier {
  120344. /**
  120345. * Simplification of a given mesh according to the given settings.
  120346. * Since this requires computation, it is assumed that the function runs async.
  120347. * @param settings The settings of the simplification, including quality and distance
  120348. * @param successCallback A callback that will be called after the mesh was simplified.
  120349. * @param errorCallback in case of an error, this callback will be called. optional.
  120350. */
  120351. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  120352. }
  120353. /**
  120354. * Expected simplification settings.
  120355. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  120356. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120357. */
  120358. export interface ISimplificationSettings {
  120359. /**
  120360. * Gets or sets the expected quality
  120361. */
  120362. quality: number;
  120363. /**
  120364. * Gets or sets the distance when this optimized version should be used
  120365. */
  120366. distance: number;
  120367. /**
  120368. * Gets an already optimized mesh
  120369. */
  120370. optimizeMesh?: boolean;
  120371. }
  120372. /**
  120373. * Class used to specify simplification options
  120374. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120375. */
  120376. export class SimplificationSettings implements ISimplificationSettings {
  120377. /** expected quality */
  120378. quality: number;
  120379. /** distance when this optimized version should be used */
  120380. distance: number;
  120381. /** already optimized mesh */
  120382. optimizeMesh?: boolean | undefined;
  120383. /**
  120384. * Creates a SimplificationSettings
  120385. * @param quality expected quality
  120386. * @param distance distance when this optimized version should be used
  120387. * @param optimizeMesh already optimized mesh
  120388. */
  120389. constructor(
  120390. /** expected quality */
  120391. quality: number,
  120392. /** distance when this optimized version should be used */
  120393. distance: number,
  120394. /** already optimized mesh */
  120395. optimizeMesh?: boolean | undefined);
  120396. }
  120397. /**
  120398. * Interface used to define a simplification task
  120399. */
  120400. export interface ISimplificationTask {
  120401. /**
  120402. * Array of settings
  120403. */
  120404. settings: Array<ISimplificationSettings>;
  120405. /**
  120406. * Simplification type
  120407. */
  120408. simplificationType: SimplificationType;
  120409. /**
  120410. * Mesh to simplify
  120411. */
  120412. mesh: Mesh;
  120413. /**
  120414. * Callback called on success
  120415. */
  120416. successCallback?: () => void;
  120417. /**
  120418. * Defines if parallel processing can be used
  120419. */
  120420. parallelProcessing: boolean;
  120421. }
  120422. /**
  120423. * Queue used to order the simplification tasks
  120424. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120425. */
  120426. export class SimplificationQueue {
  120427. private _simplificationArray;
  120428. /**
  120429. * Gets a boolean indicating that the process is still running
  120430. */
  120431. running: boolean;
  120432. /**
  120433. * Creates a new queue
  120434. */
  120435. constructor();
  120436. /**
  120437. * Adds a new simplification task
  120438. * @param task defines a task to add
  120439. */
  120440. addTask(task: ISimplificationTask): void;
  120441. /**
  120442. * Execute next task
  120443. */
  120444. executeNext(): void;
  120445. /**
  120446. * Execute a simplification task
  120447. * @param task defines the task to run
  120448. */
  120449. runSimplification(task: ISimplificationTask): void;
  120450. private getSimplifier;
  120451. }
  120452. /**
  120453. * The implemented types of simplification
  120454. * At the moment only Quadratic Error Decimation is implemented
  120455. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120456. */
  120457. export enum SimplificationType {
  120458. /** Quadratic error decimation */
  120459. QUADRATIC = 0
  120460. }
  120461. }
  120462. declare module BABYLON {
  120463. interface Scene {
  120464. /** @hidden (Backing field) */
  120465. _simplificationQueue: SimplificationQueue;
  120466. /**
  120467. * Gets or sets the simplification queue attached to the scene
  120468. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120469. */
  120470. simplificationQueue: SimplificationQueue;
  120471. }
  120472. interface Mesh {
  120473. /**
  120474. * Simplify the mesh according to the given array of settings.
  120475. * Function will return immediately and will simplify async
  120476. * @param settings a collection of simplification settings
  120477. * @param parallelProcessing should all levels calculate parallel or one after the other
  120478. * @param simplificationType the type of simplification to run
  120479. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  120480. * @returns the current mesh
  120481. */
  120482. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  120483. }
  120484. /**
  120485. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  120486. * created in a scene
  120487. */
  120488. export class SimplicationQueueSceneComponent implements ISceneComponent {
  120489. /**
  120490. * The component name helpfull to identify the component in the list of scene components.
  120491. */
  120492. readonly name: string;
  120493. /**
  120494. * The scene the component belongs to.
  120495. */
  120496. scene: Scene;
  120497. /**
  120498. * Creates a new instance of the component for the given scene
  120499. * @param scene Defines the scene to register the component in
  120500. */
  120501. constructor(scene: Scene);
  120502. /**
  120503. * Registers the component in a given scene
  120504. */
  120505. register(): void;
  120506. /**
  120507. * Rebuilds the elements related to this component in case of
  120508. * context lost for instance.
  120509. */
  120510. rebuild(): void;
  120511. /**
  120512. * Disposes the component and the associated ressources
  120513. */
  120514. dispose(): void;
  120515. private _beforeCameraUpdate;
  120516. }
  120517. }
  120518. declare module BABYLON {
  120519. /**
  120520. * Navigation plugin interface to add navigation constrained by a navigation mesh
  120521. */
  120522. export interface INavigationEnginePlugin {
  120523. /**
  120524. * plugin name
  120525. */
  120526. name: string;
  120527. /**
  120528. * Creates a navigation mesh
  120529. * @param meshes array of all the geometry used to compute the navigatio mesh
  120530. * @param parameters bunch of parameters used to filter geometry
  120531. */
  120532. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120533. /**
  120534. * Create a navigation mesh debug mesh
  120535. * @param scene is where the mesh will be added
  120536. * @returns debug display mesh
  120537. */
  120538. createDebugNavMesh(scene: Scene): Mesh;
  120539. /**
  120540. * Get a navigation mesh constrained position, closest to the parameter position
  120541. * @param position world position
  120542. * @returns the closest point to position constrained by the navigation mesh
  120543. */
  120544. getClosestPoint(position: Vector3): Vector3;
  120545. /**
  120546. * Get a navigation mesh constrained position, within a particular radius
  120547. * @param position world position
  120548. * @param maxRadius the maximum distance to the constrained world position
  120549. * @returns the closest point to position constrained by the navigation mesh
  120550. */
  120551. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120552. /**
  120553. * Compute the final position from a segment made of destination-position
  120554. * @param position world position
  120555. * @param destination world position
  120556. * @returns the resulting point along the navmesh
  120557. */
  120558. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120559. /**
  120560. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120561. * @param start world position
  120562. * @param end world position
  120563. * @returns array containing world position composing the path
  120564. */
  120565. computePath(start: Vector3, end: Vector3): Vector3[];
  120566. /**
  120567. * If this plugin is supported
  120568. * @returns true if plugin is supported
  120569. */
  120570. isSupported(): boolean;
  120571. /**
  120572. * Create a new Crowd so you can add agents
  120573. * @param maxAgents the maximum agent count in the crowd
  120574. * @param maxAgentRadius the maximum radius an agent can have
  120575. * @param scene to attach the crowd to
  120576. * @returns the crowd you can add agents to
  120577. */
  120578. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120579. /**
  120580. * Release all resources
  120581. */
  120582. dispose(): void;
  120583. }
  120584. /**
  120585. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  120586. */
  120587. export interface ICrowd {
  120588. /**
  120589. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120590. * You can attach anything to that node. The node position is updated in the scene update tick.
  120591. * @param pos world position that will be constrained by the navigation mesh
  120592. * @param parameters agent parameters
  120593. * @param transform hooked to the agent that will be update by the scene
  120594. * @returns agent index
  120595. */
  120596. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120597. /**
  120598. * Returns the agent position in world space
  120599. * @param index agent index returned by addAgent
  120600. * @returns world space position
  120601. */
  120602. getAgentPosition(index: number): Vector3;
  120603. /**
  120604. * Gets the agent velocity in world space
  120605. * @param index agent index returned by addAgent
  120606. * @returns world space velocity
  120607. */
  120608. getAgentVelocity(index: number): Vector3;
  120609. /**
  120610. * remove a particular agent previously created
  120611. * @param index agent index returned by addAgent
  120612. */
  120613. removeAgent(index: number): void;
  120614. /**
  120615. * get the list of all agents attached to this crowd
  120616. * @returns list of agent indices
  120617. */
  120618. getAgents(): number[];
  120619. /**
  120620. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120621. * @param deltaTime in seconds
  120622. */
  120623. update(deltaTime: number): void;
  120624. /**
  120625. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120626. * @param index agent index returned by addAgent
  120627. * @param destination targeted world position
  120628. */
  120629. agentGoto(index: number, destination: Vector3): void;
  120630. /**
  120631. * Release all resources
  120632. */
  120633. dispose(): void;
  120634. }
  120635. /**
  120636. * Configures an agent
  120637. */
  120638. export interface IAgentParameters {
  120639. /**
  120640. * Agent radius. [Limit: >= 0]
  120641. */
  120642. radius: number;
  120643. /**
  120644. * Agent height. [Limit: > 0]
  120645. */
  120646. height: number;
  120647. /**
  120648. * Maximum allowed acceleration. [Limit: >= 0]
  120649. */
  120650. maxAcceleration: number;
  120651. /**
  120652. * Maximum allowed speed. [Limit: >= 0]
  120653. */
  120654. maxSpeed: number;
  120655. /**
  120656. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  120657. */
  120658. collisionQueryRange: number;
  120659. /**
  120660. * The path visibility optimization range. [Limit: > 0]
  120661. */
  120662. pathOptimizationRange: number;
  120663. /**
  120664. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  120665. */
  120666. separationWeight: number;
  120667. }
  120668. /**
  120669. * Configures the navigation mesh creation
  120670. */
  120671. export interface INavMeshParameters {
  120672. /**
  120673. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  120674. */
  120675. cs: number;
  120676. /**
  120677. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  120678. */
  120679. ch: number;
  120680. /**
  120681. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  120682. */
  120683. walkableSlopeAngle: number;
  120684. /**
  120685. * Minimum floor to 'ceiling' height that will still allow the floor area to
  120686. * be considered walkable. [Limit: >= 3] [Units: vx]
  120687. */
  120688. walkableHeight: number;
  120689. /**
  120690. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  120691. */
  120692. walkableClimb: number;
  120693. /**
  120694. * The distance to erode/shrink the walkable area of the heightfield away from
  120695. * obstructions. [Limit: >=0] [Units: vx]
  120696. */
  120697. walkableRadius: number;
  120698. /**
  120699. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  120700. */
  120701. maxEdgeLen: number;
  120702. /**
  120703. * The maximum distance a simplfied contour's border edges should deviate
  120704. * the original raw contour. [Limit: >=0] [Units: vx]
  120705. */
  120706. maxSimplificationError: number;
  120707. /**
  120708. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  120709. */
  120710. minRegionArea: number;
  120711. /**
  120712. * Any regions with a span count smaller than this value will, if possible,
  120713. * be merged with larger regions. [Limit: >=0] [Units: vx]
  120714. */
  120715. mergeRegionArea: number;
  120716. /**
  120717. * The maximum number of vertices allowed for polygons generated during the
  120718. * contour to polygon conversion process. [Limit: >= 3]
  120719. */
  120720. maxVertsPerPoly: number;
  120721. /**
  120722. * Sets the sampling distance to use when generating the detail mesh.
  120723. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120724. */
  120725. detailSampleDist: number;
  120726. /**
  120727. * The maximum distance the detail mesh surface should deviate from heightfield
  120728. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120729. */
  120730. detailSampleMaxError: number;
  120731. }
  120732. }
  120733. declare module BABYLON {
  120734. /**
  120735. * RecastJS navigation plugin
  120736. */
  120737. export class RecastJSPlugin implements INavigationEnginePlugin {
  120738. /**
  120739. * Reference to the Recast library
  120740. */
  120741. bjsRECAST: any;
  120742. /**
  120743. * plugin name
  120744. */
  120745. name: string;
  120746. /**
  120747. * the first navmesh created. We might extend this to support multiple navmeshes
  120748. */
  120749. navMesh: any;
  120750. /**
  120751. * Initializes the recastJS plugin
  120752. * @param recastInjection can be used to inject your own recast reference
  120753. */
  120754. constructor(recastInjection?: any);
  120755. /**
  120756. * Creates a navigation mesh
  120757. * @param meshes array of all the geometry used to compute the navigatio mesh
  120758. * @param parameters bunch of parameters used to filter geometry
  120759. */
  120760. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120761. /**
  120762. * Create a navigation mesh debug mesh
  120763. * @param scene is where the mesh will be added
  120764. * @returns debug display mesh
  120765. */
  120766. createDebugNavMesh(scene: Scene): Mesh;
  120767. /**
  120768. * Get a navigation mesh constrained position, closest to the parameter position
  120769. * @param position world position
  120770. * @returns the closest point to position constrained by the navigation mesh
  120771. */
  120772. getClosestPoint(position: Vector3): Vector3;
  120773. /**
  120774. * Get a navigation mesh constrained position, within a particular radius
  120775. * @param position world position
  120776. * @param maxRadius the maximum distance to the constrained world position
  120777. * @returns the closest point to position constrained by the navigation mesh
  120778. */
  120779. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120780. /**
  120781. * Compute the final position from a segment made of destination-position
  120782. * @param position world position
  120783. * @param destination world position
  120784. * @returns the resulting point along the navmesh
  120785. */
  120786. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120787. /**
  120788. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120789. * @param start world position
  120790. * @param end world position
  120791. * @returns array containing world position composing the path
  120792. */
  120793. computePath(start: Vector3, end: Vector3): Vector3[];
  120794. /**
  120795. * Create a new Crowd so you can add agents
  120796. * @param maxAgents the maximum agent count in the crowd
  120797. * @param maxAgentRadius the maximum radius an agent can have
  120798. * @param scene to attach the crowd to
  120799. * @returns the crowd you can add agents to
  120800. */
  120801. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120802. /**
  120803. * Disposes
  120804. */
  120805. dispose(): void;
  120806. /**
  120807. * If this plugin is supported
  120808. * @returns true if plugin is supported
  120809. */
  120810. isSupported(): boolean;
  120811. }
  120812. /**
  120813. * Recast detour crowd implementation
  120814. */
  120815. export class RecastJSCrowd implements ICrowd {
  120816. /**
  120817. * Recast/detour plugin
  120818. */
  120819. bjsRECASTPlugin: RecastJSPlugin;
  120820. /**
  120821. * Link to the detour crowd
  120822. */
  120823. recastCrowd: any;
  120824. /**
  120825. * One transform per agent
  120826. */
  120827. transforms: TransformNode[];
  120828. /**
  120829. * All agents created
  120830. */
  120831. agents: number[];
  120832. /**
  120833. * Link to the scene is kept to unregister the crowd from the scene
  120834. */
  120835. private _scene;
  120836. /**
  120837. * Observer for crowd updates
  120838. */
  120839. private _onBeforeAnimationsObserver;
  120840. /**
  120841. * Constructor
  120842. * @param plugin recastJS plugin
  120843. * @param maxAgents the maximum agent count in the crowd
  120844. * @param maxAgentRadius the maximum radius an agent can have
  120845. * @param scene to attach the crowd to
  120846. * @returns the crowd you can add agents to
  120847. */
  120848. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  120849. /**
  120850. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120851. * You can attach anything to that node. The node position is updated in the scene update tick.
  120852. * @param pos world position that will be constrained by the navigation mesh
  120853. * @param parameters agent parameters
  120854. * @param transform hooked to the agent that will be update by the scene
  120855. * @returns agent index
  120856. */
  120857. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120858. /**
  120859. * Returns the agent position in world space
  120860. * @param index agent index returned by addAgent
  120861. * @returns world space position
  120862. */
  120863. getAgentPosition(index: number): Vector3;
  120864. /**
  120865. * Returns the agent velocity in world space
  120866. * @param index agent index returned by addAgent
  120867. * @returns world space velocity
  120868. */
  120869. getAgentVelocity(index: number): Vector3;
  120870. /**
  120871. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120872. * @param index agent index returned by addAgent
  120873. * @param destination targeted world position
  120874. */
  120875. agentGoto(index: number, destination: Vector3): void;
  120876. /**
  120877. * remove a particular agent previously created
  120878. * @param index agent index returned by addAgent
  120879. */
  120880. removeAgent(index: number): void;
  120881. /**
  120882. * get the list of all agents attached to this crowd
  120883. * @returns list of agent indices
  120884. */
  120885. getAgents(): number[];
  120886. /**
  120887. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120888. * @param deltaTime in seconds
  120889. */
  120890. update(deltaTime: number): void;
  120891. /**
  120892. * Release all resources
  120893. */
  120894. dispose(): void;
  120895. }
  120896. }
  120897. declare module BABYLON {
  120898. /**
  120899. * Class used to enable access to IndexedDB
  120900. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120901. */
  120902. export class Database implements IOfflineProvider {
  120903. private _callbackManifestChecked;
  120904. private _currentSceneUrl;
  120905. private _db;
  120906. private _enableSceneOffline;
  120907. private _enableTexturesOffline;
  120908. private _manifestVersionFound;
  120909. private _mustUpdateRessources;
  120910. private _hasReachedQuota;
  120911. private _isSupported;
  120912. private _idbFactory;
  120913. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  120914. private static IsUASupportingBlobStorage;
  120915. /**
  120916. * Gets a boolean indicating if Database storate is enabled (off by default)
  120917. */
  120918. static IDBStorageEnabled: boolean;
  120919. /**
  120920. * Gets a boolean indicating if scene must be saved in the database
  120921. */
  120922. readonly enableSceneOffline: boolean;
  120923. /**
  120924. * Gets a boolean indicating if textures must be saved in the database
  120925. */
  120926. readonly enableTexturesOffline: boolean;
  120927. /**
  120928. * Creates a new Database
  120929. * @param urlToScene defines the url to load the scene
  120930. * @param callbackManifestChecked defines the callback to use when manifest is checked
  120931. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  120932. */
  120933. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  120934. private static _ParseURL;
  120935. private static _ReturnFullUrlLocation;
  120936. private _checkManifestFile;
  120937. /**
  120938. * Open the database and make it available
  120939. * @param successCallback defines the callback to call on success
  120940. * @param errorCallback defines the callback to call on error
  120941. */
  120942. open(successCallback: () => void, errorCallback: () => void): void;
  120943. /**
  120944. * Loads an image from the database
  120945. * @param url defines the url to load from
  120946. * @param image defines the target DOM image
  120947. */
  120948. loadImage(url: string, image: HTMLImageElement): void;
  120949. private _loadImageFromDBAsync;
  120950. private _saveImageIntoDBAsync;
  120951. private _checkVersionFromDB;
  120952. private _loadVersionFromDBAsync;
  120953. private _saveVersionIntoDBAsync;
  120954. /**
  120955. * Loads a file from database
  120956. * @param url defines the URL to load from
  120957. * @param sceneLoaded defines a callback to call on success
  120958. * @param progressCallBack defines a callback to call when progress changed
  120959. * @param errorCallback defines a callback to call on error
  120960. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  120961. */
  120962. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  120963. private _loadFileAsync;
  120964. private _saveFileAsync;
  120965. /**
  120966. * Validates if xhr data is correct
  120967. * @param xhr defines the request to validate
  120968. * @param dataType defines the expected data type
  120969. * @returns true if data is correct
  120970. */
  120971. private static _ValidateXHRData;
  120972. }
  120973. }
  120974. declare module BABYLON {
  120975. /** @hidden */
  120976. export var gpuUpdateParticlesPixelShader: {
  120977. name: string;
  120978. shader: string;
  120979. };
  120980. }
  120981. declare module BABYLON {
  120982. /** @hidden */
  120983. export var gpuUpdateParticlesVertexShader: {
  120984. name: string;
  120985. shader: string;
  120986. };
  120987. }
  120988. declare module BABYLON {
  120989. /** @hidden */
  120990. export var clipPlaneFragmentDeclaration2: {
  120991. name: string;
  120992. shader: string;
  120993. };
  120994. }
  120995. declare module BABYLON {
  120996. /** @hidden */
  120997. export var gpuRenderParticlesPixelShader: {
  120998. name: string;
  120999. shader: string;
  121000. };
  121001. }
  121002. declare module BABYLON {
  121003. /** @hidden */
  121004. export var clipPlaneVertexDeclaration2: {
  121005. name: string;
  121006. shader: string;
  121007. };
  121008. }
  121009. declare module BABYLON {
  121010. /** @hidden */
  121011. export var gpuRenderParticlesVertexShader: {
  121012. name: string;
  121013. shader: string;
  121014. };
  121015. }
  121016. declare module BABYLON {
  121017. /**
  121018. * This represents a GPU particle system in Babylon
  121019. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  121020. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  121021. */
  121022. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  121023. /**
  121024. * The layer mask we are rendering the particles through.
  121025. */
  121026. layerMask: number;
  121027. private _capacity;
  121028. private _activeCount;
  121029. private _currentActiveCount;
  121030. private _accumulatedCount;
  121031. private _renderEffect;
  121032. private _updateEffect;
  121033. private _buffer0;
  121034. private _buffer1;
  121035. private _spriteBuffer;
  121036. private _updateVAO;
  121037. private _renderVAO;
  121038. private _targetIndex;
  121039. private _sourceBuffer;
  121040. private _targetBuffer;
  121041. private _engine;
  121042. private _currentRenderId;
  121043. private _started;
  121044. private _stopped;
  121045. private _timeDelta;
  121046. private _randomTexture;
  121047. private _randomTexture2;
  121048. private _attributesStrideSize;
  121049. private _updateEffectOptions;
  121050. private _randomTextureSize;
  121051. private _actualFrame;
  121052. private readonly _rawTextureWidth;
  121053. /**
  121054. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  121055. */
  121056. static readonly IsSupported: boolean;
  121057. /**
  121058. * An event triggered when the system is disposed.
  121059. */
  121060. onDisposeObservable: Observable<GPUParticleSystem>;
  121061. /**
  121062. * Gets the maximum number of particles active at the same time.
  121063. * @returns The max number of active particles.
  121064. */
  121065. getCapacity(): number;
  121066. /**
  121067. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  121068. * to override the particles.
  121069. */
  121070. forceDepthWrite: boolean;
  121071. /**
  121072. * Gets or set the number of active particles
  121073. */
  121074. activeParticleCount: number;
  121075. private _preWarmDone;
  121076. /**
  121077. * Is this system ready to be used/rendered
  121078. * @return true if the system is ready
  121079. */
  121080. isReady(): boolean;
  121081. /**
  121082. * Gets if the system has been started. (Note: this will still be true after stop is called)
  121083. * @returns True if it has been started, otherwise false.
  121084. */
  121085. isStarted(): boolean;
  121086. /**
  121087. * Starts the particle system and begins to emit
  121088. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  121089. */
  121090. start(delay?: number): void;
  121091. /**
  121092. * Stops the particle system.
  121093. */
  121094. stop(): void;
  121095. /**
  121096. * Remove all active particles
  121097. */
  121098. reset(): void;
  121099. /**
  121100. * Returns the string "GPUParticleSystem"
  121101. * @returns a string containing the class name
  121102. */
  121103. getClassName(): string;
  121104. private _colorGradientsTexture;
  121105. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  121106. /**
  121107. * Adds a new color gradient
  121108. * @param gradient defines the gradient to use (between 0 and 1)
  121109. * @param color1 defines the color to affect to the specified gradient
  121110. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  121111. * @returns the current particle system
  121112. */
  121113. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  121114. /**
  121115. * Remove a specific color gradient
  121116. * @param gradient defines the gradient to remove
  121117. * @returns the current particle system
  121118. */
  121119. removeColorGradient(gradient: number): GPUParticleSystem;
  121120. private _angularSpeedGradientsTexture;
  121121. private _sizeGradientsTexture;
  121122. private _velocityGradientsTexture;
  121123. private _limitVelocityGradientsTexture;
  121124. private _dragGradientsTexture;
  121125. private _addFactorGradient;
  121126. /**
  121127. * Adds a new size gradient
  121128. * @param gradient defines the gradient to use (between 0 and 1)
  121129. * @param factor defines the size factor to affect to the specified gradient
  121130. * @returns the current particle system
  121131. */
  121132. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  121133. /**
  121134. * Remove a specific size gradient
  121135. * @param gradient defines the gradient to remove
  121136. * @returns the current particle system
  121137. */
  121138. removeSizeGradient(gradient: number): GPUParticleSystem;
  121139. /**
  121140. * Adds a new angular speed gradient
  121141. * @param gradient defines the gradient to use (between 0 and 1)
  121142. * @param factor defines the angular speed to affect to the specified gradient
  121143. * @returns the current particle system
  121144. */
  121145. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  121146. /**
  121147. * Remove a specific angular speed gradient
  121148. * @param gradient defines the gradient to remove
  121149. * @returns the current particle system
  121150. */
  121151. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  121152. /**
  121153. * Adds a new velocity gradient
  121154. * @param gradient defines the gradient to use (between 0 and 1)
  121155. * @param factor defines the velocity to affect to the specified gradient
  121156. * @returns the current particle system
  121157. */
  121158. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121159. /**
  121160. * Remove a specific velocity gradient
  121161. * @param gradient defines the gradient to remove
  121162. * @returns the current particle system
  121163. */
  121164. removeVelocityGradient(gradient: number): GPUParticleSystem;
  121165. /**
  121166. * Adds a new limit velocity gradient
  121167. * @param gradient defines the gradient to use (between 0 and 1)
  121168. * @param factor defines the limit velocity value to affect to the specified gradient
  121169. * @returns the current particle system
  121170. */
  121171. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121172. /**
  121173. * Remove a specific limit velocity gradient
  121174. * @param gradient defines the gradient to remove
  121175. * @returns the current particle system
  121176. */
  121177. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  121178. /**
  121179. * Adds a new drag gradient
  121180. * @param gradient defines the gradient to use (between 0 and 1)
  121181. * @param factor defines the drag value to affect to the specified gradient
  121182. * @returns the current particle system
  121183. */
  121184. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  121185. /**
  121186. * Remove a specific drag gradient
  121187. * @param gradient defines the gradient to remove
  121188. * @returns the current particle system
  121189. */
  121190. removeDragGradient(gradient: number): GPUParticleSystem;
  121191. /**
  121192. * Not supported by GPUParticleSystem
  121193. * @param gradient defines the gradient to use (between 0 and 1)
  121194. * @param factor defines the emit rate value to affect to the specified gradient
  121195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121196. * @returns the current particle system
  121197. */
  121198. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121199. /**
  121200. * Not supported by GPUParticleSystem
  121201. * @param gradient defines the gradient to remove
  121202. * @returns the current particle system
  121203. */
  121204. removeEmitRateGradient(gradient: number): IParticleSystem;
  121205. /**
  121206. * Not supported by GPUParticleSystem
  121207. * @param gradient defines the gradient to use (between 0 and 1)
  121208. * @param factor defines the start size value to affect to the specified gradient
  121209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121210. * @returns the current particle system
  121211. */
  121212. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121213. /**
  121214. * Not supported by GPUParticleSystem
  121215. * @param gradient defines the gradient to remove
  121216. * @returns the current particle system
  121217. */
  121218. removeStartSizeGradient(gradient: number): IParticleSystem;
  121219. /**
  121220. * Not supported by GPUParticleSystem
  121221. * @param gradient defines the gradient to use (between 0 and 1)
  121222. * @param min defines the color remap minimal range
  121223. * @param max defines the color remap maximal range
  121224. * @returns the current particle system
  121225. */
  121226. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121227. /**
  121228. * Not supported by GPUParticleSystem
  121229. * @param gradient defines the gradient to remove
  121230. * @returns the current particle system
  121231. */
  121232. removeColorRemapGradient(): IParticleSystem;
  121233. /**
  121234. * Not supported by GPUParticleSystem
  121235. * @param gradient defines the gradient to use (between 0 and 1)
  121236. * @param min defines the alpha remap minimal range
  121237. * @param max defines the alpha remap maximal range
  121238. * @returns the current particle system
  121239. */
  121240. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121241. /**
  121242. * Not supported by GPUParticleSystem
  121243. * @param gradient defines the gradient to remove
  121244. * @returns the current particle system
  121245. */
  121246. removeAlphaRemapGradient(): IParticleSystem;
  121247. /**
  121248. * Not supported by GPUParticleSystem
  121249. * @param gradient defines the gradient to use (between 0 and 1)
  121250. * @param color defines the color to affect to the specified gradient
  121251. * @returns the current particle system
  121252. */
  121253. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  121254. /**
  121255. * Not supported by GPUParticleSystem
  121256. * @param gradient defines the gradient to remove
  121257. * @returns the current particle system
  121258. */
  121259. removeRampGradient(): IParticleSystem;
  121260. /**
  121261. * Not supported by GPUParticleSystem
  121262. * @returns the list of ramp gradients
  121263. */
  121264. getRampGradients(): Nullable<Array<Color3Gradient>>;
  121265. /**
  121266. * Not supported by GPUParticleSystem
  121267. * Gets or sets a boolean indicating that ramp gradients must be used
  121268. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  121269. */
  121270. useRampGradients: boolean;
  121271. /**
  121272. * Not supported by GPUParticleSystem
  121273. * @param gradient defines the gradient to use (between 0 and 1)
  121274. * @param factor defines the life time factor to affect to the specified gradient
  121275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121276. * @returns the current particle system
  121277. */
  121278. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121279. /**
  121280. * Not supported by GPUParticleSystem
  121281. * @param gradient defines the gradient to remove
  121282. * @returns the current particle system
  121283. */
  121284. removeLifeTimeGradient(gradient: number): IParticleSystem;
  121285. /**
  121286. * Instantiates a GPU particle system.
  121287. * 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.
  121288. * @param name The name of the particle system
  121289. * @param options The options used to create the system
  121290. * @param scene The scene the particle system belongs to
  121291. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  121292. */
  121293. constructor(name: string, options: Partial<{
  121294. capacity: number;
  121295. randomTextureSize: number;
  121296. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  121297. protected _reset(): void;
  121298. private _createUpdateVAO;
  121299. private _createRenderVAO;
  121300. private _initialize;
  121301. /** @hidden */
  121302. _recreateUpdateEffect(): void;
  121303. /** @hidden */
  121304. _recreateRenderEffect(): void;
  121305. /**
  121306. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  121307. * @param preWarm defines if we are in the pre-warmimg phase
  121308. */
  121309. animate(preWarm?: boolean): void;
  121310. private _createFactorGradientTexture;
  121311. private _createSizeGradientTexture;
  121312. private _createAngularSpeedGradientTexture;
  121313. private _createVelocityGradientTexture;
  121314. private _createLimitVelocityGradientTexture;
  121315. private _createDragGradientTexture;
  121316. private _createColorGradientTexture;
  121317. /**
  121318. * Renders the particle system in its current state
  121319. * @param preWarm defines if the system should only update the particles but not render them
  121320. * @returns the current number of particles
  121321. */
  121322. render(preWarm?: boolean): number;
  121323. /**
  121324. * Rebuilds the particle system
  121325. */
  121326. rebuild(): void;
  121327. private _releaseBuffers;
  121328. private _releaseVAOs;
  121329. /**
  121330. * Disposes the particle system and free the associated resources
  121331. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  121332. */
  121333. dispose(disposeTexture?: boolean): void;
  121334. /**
  121335. * Clones the particle system.
  121336. * @param name The name of the cloned object
  121337. * @param newEmitter The new emitter to use
  121338. * @returns the cloned particle system
  121339. */
  121340. clone(name: string, newEmitter: any): GPUParticleSystem;
  121341. /**
  121342. * Serializes the particle system to a JSON object.
  121343. * @returns the JSON object
  121344. */
  121345. serialize(): any;
  121346. /**
  121347. * Parses a JSON object to create a GPU particle system.
  121348. * @param parsedParticleSystem The JSON object to parse
  121349. * @param scene The scene to create the particle system in
  121350. * @param rootUrl The root url to use to load external dependencies like texture
  121351. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  121352. * @returns the parsed GPU particle system
  121353. */
  121354. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  121355. }
  121356. }
  121357. declare module BABYLON {
  121358. /**
  121359. * Represents a set of particle systems working together to create a specific effect
  121360. */
  121361. export class ParticleSystemSet implements IDisposable {
  121362. private _emitterCreationOptions;
  121363. private _emitterNode;
  121364. /**
  121365. * Gets the particle system list
  121366. */
  121367. systems: IParticleSystem[];
  121368. /**
  121369. * Gets the emitter node used with this set
  121370. */
  121371. readonly emitterNode: Nullable<TransformNode>;
  121372. /**
  121373. * Creates a new emitter mesh as a sphere
  121374. * @param options defines the options used to create the sphere
  121375. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  121376. * @param scene defines the hosting scene
  121377. */
  121378. setEmitterAsSphere(options: {
  121379. diameter: number;
  121380. segments: number;
  121381. color: Color3;
  121382. }, renderingGroupId: number, scene: Scene): void;
  121383. /**
  121384. * Starts all particle systems of the set
  121385. * @param emitter defines an optional mesh to use as emitter for the particle systems
  121386. */
  121387. start(emitter?: AbstractMesh): void;
  121388. /**
  121389. * Release all associated resources
  121390. */
  121391. dispose(): void;
  121392. /**
  121393. * Serialize the set into a JSON compatible object
  121394. * @returns a JSON compatible representation of the set
  121395. */
  121396. serialize(): any;
  121397. /**
  121398. * Parse a new ParticleSystemSet from a serialized source
  121399. * @param data defines a JSON compatible representation of the set
  121400. * @param scene defines the hosting scene
  121401. * @param gpu defines if we want GPU particles or CPU particles
  121402. * @returns a new ParticleSystemSet
  121403. */
  121404. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  121405. }
  121406. }
  121407. declare module BABYLON {
  121408. /**
  121409. * This class is made for on one-liner static method to help creating particle system set.
  121410. */
  121411. export class ParticleHelper {
  121412. /**
  121413. * Gets or sets base Assets URL
  121414. */
  121415. static BaseAssetsUrl: string;
  121416. /**
  121417. * Create a default particle system that you can tweak
  121418. * @param emitter defines the emitter to use
  121419. * @param capacity defines the system capacity (default is 500 particles)
  121420. * @param scene defines the hosting scene
  121421. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  121422. * @returns the new Particle system
  121423. */
  121424. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  121425. /**
  121426. * This is the main static method (one-liner) of this helper to create different particle systems
  121427. * @param type This string represents the type to the particle system to create
  121428. * @param scene The scene where the particle system should live
  121429. * @param gpu If the system will use gpu
  121430. * @returns the ParticleSystemSet created
  121431. */
  121432. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  121433. /**
  121434. * Static function used to export a particle system to a ParticleSystemSet variable.
  121435. * Please note that the emitter shape is not exported
  121436. * @param systems defines the particle systems to export
  121437. * @returns the created particle system set
  121438. */
  121439. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  121440. }
  121441. }
  121442. declare module BABYLON {
  121443. interface Engine {
  121444. /**
  121445. * Create an effect to use with particle systems.
  121446. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  121447. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  121448. * @param uniformsNames defines a list of attribute names
  121449. * @param samplers defines an array of string used to represent textures
  121450. * @param defines defines the string containing the defines to use to compile the shaders
  121451. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121452. * @param onCompiled defines a function to call when the effect creation is successful
  121453. * @param onError defines a function to call when the effect creation has failed
  121454. * @returns the new Effect
  121455. */
  121456. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  121457. }
  121458. interface Mesh {
  121459. /**
  121460. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  121461. * @returns an array of IParticleSystem
  121462. */
  121463. getEmittedParticleSystems(): IParticleSystem[];
  121464. /**
  121465. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  121466. * @returns an array of IParticleSystem
  121467. */
  121468. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  121469. }
  121470. /**
  121471. * @hidden
  121472. */
  121473. export var _IDoNeedToBeInTheBuild: number;
  121474. }
  121475. declare module BABYLON {
  121476. interface Scene {
  121477. /** @hidden (Backing field) */
  121478. _physicsEngine: Nullable<IPhysicsEngine>;
  121479. /**
  121480. * Gets the current physics engine
  121481. * @returns a IPhysicsEngine or null if none attached
  121482. */
  121483. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  121484. /**
  121485. * Enables physics to the current scene
  121486. * @param gravity defines the scene's gravity for the physics engine
  121487. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  121488. * @return a boolean indicating if the physics engine was initialized
  121489. */
  121490. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  121491. /**
  121492. * Disables and disposes the physics engine associated with the scene
  121493. */
  121494. disablePhysicsEngine(): void;
  121495. /**
  121496. * Gets a boolean indicating if there is an active physics engine
  121497. * @returns a boolean indicating if there is an active physics engine
  121498. */
  121499. isPhysicsEnabled(): boolean;
  121500. /**
  121501. * Deletes a physics compound impostor
  121502. * @param compound defines the compound to delete
  121503. */
  121504. deleteCompoundImpostor(compound: any): void;
  121505. /**
  121506. * An event triggered when physic simulation is about to be run
  121507. */
  121508. onBeforePhysicsObservable: Observable<Scene>;
  121509. /**
  121510. * An event triggered when physic simulation has been done
  121511. */
  121512. onAfterPhysicsObservable: Observable<Scene>;
  121513. }
  121514. interface AbstractMesh {
  121515. /** @hidden */
  121516. _physicsImpostor: Nullable<PhysicsImpostor>;
  121517. /**
  121518. * Gets or sets impostor used for physic simulation
  121519. * @see http://doc.babylonjs.com/features/physics_engine
  121520. */
  121521. physicsImpostor: Nullable<PhysicsImpostor>;
  121522. /**
  121523. * Gets the current physics impostor
  121524. * @see http://doc.babylonjs.com/features/physics_engine
  121525. * @returns a physics impostor or null
  121526. */
  121527. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  121528. /** Apply a physic impulse to the mesh
  121529. * @param force defines the force to apply
  121530. * @param contactPoint defines where to apply the force
  121531. * @returns the current mesh
  121532. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121533. */
  121534. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  121535. /**
  121536. * Creates a physic joint between two meshes
  121537. * @param otherMesh defines the other mesh to use
  121538. * @param pivot1 defines the pivot to use on this mesh
  121539. * @param pivot2 defines the pivot to use on the other mesh
  121540. * @param options defines additional options (can be plugin dependent)
  121541. * @returns the current mesh
  121542. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  121543. */
  121544. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  121545. /** @hidden */
  121546. _disposePhysicsObserver: Nullable<Observer<Node>>;
  121547. }
  121548. /**
  121549. * Defines the physics engine scene component responsible to manage a physics engine
  121550. */
  121551. export class PhysicsEngineSceneComponent implements ISceneComponent {
  121552. /**
  121553. * The component name helpful to identify the component in the list of scene components.
  121554. */
  121555. readonly name: string;
  121556. /**
  121557. * The scene the component belongs to.
  121558. */
  121559. scene: Scene;
  121560. /**
  121561. * Creates a new instance of the component for the given scene
  121562. * @param scene Defines the scene to register the component in
  121563. */
  121564. constructor(scene: Scene);
  121565. /**
  121566. * Registers the component in a given scene
  121567. */
  121568. register(): void;
  121569. /**
  121570. * Rebuilds the elements related to this component in case of
  121571. * context lost for instance.
  121572. */
  121573. rebuild(): void;
  121574. /**
  121575. * Disposes the component and the associated ressources
  121576. */
  121577. dispose(): void;
  121578. }
  121579. }
  121580. declare module BABYLON {
  121581. /**
  121582. * A helper for physics simulations
  121583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121584. */
  121585. export class PhysicsHelper {
  121586. private _scene;
  121587. private _physicsEngine;
  121588. /**
  121589. * Initializes the Physics helper
  121590. * @param scene Babylon.js scene
  121591. */
  121592. constructor(scene: Scene);
  121593. /**
  121594. * Applies a radial explosion impulse
  121595. * @param origin the origin of the explosion
  121596. * @param radiusOrEventOptions the radius or the options of radial explosion
  121597. * @param strength the explosion strength
  121598. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121599. * @returns A physics radial explosion event, or null
  121600. */
  121601. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121602. /**
  121603. * Applies a radial explosion force
  121604. * @param origin the origin of the explosion
  121605. * @param radiusOrEventOptions the radius or the options of radial explosion
  121606. * @param strength the explosion strength
  121607. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121608. * @returns A physics radial explosion event, or null
  121609. */
  121610. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121611. /**
  121612. * Creates a gravitational field
  121613. * @param origin the origin of the explosion
  121614. * @param radiusOrEventOptions the radius or the options of radial explosion
  121615. * @param strength the explosion strength
  121616. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121617. * @returns A physics gravitational field event, or null
  121618. */
  121619. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  121620. /**
  121621. * Creates a physics updraft event
  121622. * @param origin the origin of the updraft
  121623. * @param radiusOrEventOptions the radius or the options of the updraft
  121624. * @param strength the strength of the updraft
  121625. * @param height the height of the updraft
  121626. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  121627. * @returns A physics updraft event, or null
  121628. */
  121629. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  121630. /**
  121631. * Creates a physics vortex event
  121632. * @param origin the of the vortex
  121633. * @param radiusOrEventOptions the radius or the options of the vortex
  121634. * @param strength the strength of the vortex
  121635. * @param height the height of the vortex
  121636. * @returns a Physics vortex event, or null
  121637. * A physics vortex event or null
  121638. */
  121639. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  121640. }
  121641. /**
  121642. * Represents a physics radial explosion event
  121643. */
  121644. class PhysicsRadialExplosionEvent {
  121645. private _scene;
  121646. private _options;
  121647. private _sphere;
  121648. private _dataFetched;
  121649. /**
  121650. * Initializes a radial explosioin event
  121651. * @param _scene BabylonJS scene
  121652. * @param _options The options for the vortex event
  121653. */
  121654. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  121655. /**
  121656. * Returns the data related to the radial explosion event (sphere).
  121657. * @returns The radial explosion event data
  121658. */
  121659. getData(): PhysicsRadialExplosionEventData;
  121660. /**
  121661. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  121662. * @param impostor A physics imposter
  121663. * @param origin the origin of the explosion
  121664. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  121665. */
  121666. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  121667. /**
  121668. * Triggers affecterd impostors callbacks
  121669. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  121670. */
  121671. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  121672. /**
  121673. * Disposes the sphere.
  121674. * @param force Specifies if the sphere should be disposed by force
  121675. */
  121676. dispose(force?: boolean): void;
  121677. /*** Helpers ***/
  121678. private _prepareSphere;
  121679. private _intersectsWithSphere;
  121680. }
  121681. /**
  121682. * Represents a gravitational field event
  121683. */
  121684. class PhysicsGravitationalFieldEvent {
  121685. private _physicsHelper;
  121686. private _scene;
  121687. private _origin;
  121688. private _options;
  121689. private _tickCallback;
  121690. private _sphere;
  121691. private _dataFetched;
  121692. /**
  121693. * Initializes the physics gravitational field event
  121694. * @param _physicsHelper A physics helper
  121695. * @param _scene BabylonJS scene
  121696. * @param _origin The origin position of the gravitational field event
  121697. * @param _options The options for the vortex event
  121698. */
  121699. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  121700. /**
  121701. * Returns the data related to the gravitational field event (sphere).
  121702. * @returns A gravitational field event
  121703. */
  121704. getData(): PhysicsGravitationalFieldEventData;
  121705. /**
  121706. * Enables the gravitational field.
  121707. */
  121708. enable(): void;
  121709. /**
  121710. * Disables the gravitational field.
  121711. */
  121712. disable(): void;
  121713. /**
  121714. * Disposes the sphere.
  121715. * @param force The force to dispose from the gravitational field event
  121716. */
  121717. dispose(force?: boolean): void;
  121718. private _tick;
  121719. }
  121720. /**
  121721. * Represents a physics updraft event
  121722. */
  121723. class PhysicsUpdraftEvent {
  121724. private _scene;
  121725. private _origin;
  121726. private _options;
  121727. private _physicsEngine;
  121728. private _originTop;
  121729. private _originDirection;
  121730. private _tickCallback;
  121731. private _cylinder;
  121732. private _cylinderPosition;
  121733. private _dataFetched;
  121734. /**
  121735. * Initializes the physics updraft event
  121736. * @param _scene BabylonJS scene
  121737. * @param _origin The origin position of the updraft
  121738. * @param _options The options for the updraft event
  121739. */
  121740. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  121741. /**
  121742. * Returns the data related to the updraft event (cylinder).
  121743. * @returns A physics updraft event
  121744. */
  121745. getData(): PhysicsUpdraftEventData;
  121746. /**
  121747. * Enables the updraft.
  121748. */
  121749. enable(): void;
  121750. /**
  121751. * Disables the updraft.
  121752. */
  121753. disable(): void;
  121754. /**
  121755. * Disposes the cylinder.
  121756. * @param force Specifies if the updraft should be disposed by force
  121757. */
  121758. dispose(force?: boolean): void;
  121759. private getImpostorHitData;
  121760. private _tick;
  121761. /*** Helpers ***/
  121762. private _prepareCylinder;
  121763. private _intersectsWithCylinder;
  121764. }
  121765. /**
  121766. * Represents a physics vortex event
  121767. */
  121768. class PhysicsVortexEvent {
  121769. private _scene;
  121770. private _origin;
  121771. private _options;
  121772. private _physicsEngine;
  121773. private _originTop;
  121774. private _tickCallback;
  121775. private _cylinder;
  121776. private _cylinderPosition;
  121777. private _dataFetched;
  121778. /**
  121779. * Initializes the physics vortex event
  121780. * @param _scene The BabylonJS scene
  121781. * @param _origin The origin position of the vortex
  121782. * @param _options The options for the vortex event
  121783. */
  121784. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  121785. /**
  121786. * Returns the data related to the vortex event (cylinder).
  121787. * @returns The physics vortex event data
  121788. */
  121789. getData(): PhysicsVortexEventData;
  121790. /**
  121791. * Enables the vortex.
  121792. */
  121793. enable(): void;
  121794. /**
  121795. * Disables the cortex.
  121796. */
  121797. disable(): void;
  121798. /**
  121799. * Disposes the sphere.
  121800. * @param force
  121801. */
  121802. dispose(force?: boolean): void;
  121803. private getImpostorHitData;
  121804. private _tick;
  121805. /*** Helpers ***/
  121806. private _prepareCylinder;
  121807. private _intersectsWithCylinder;
  121808. }
  121809. /**
  121810. * Options fot the radial explosion event
  121811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121812. */
  121813. export class PhysicsRadialExplosionEventOptions {
  121814. /**
  121815. * The radius of the sphere for the radial explosion.
  121816. */
  121817. radius: number;
  121818. /**
  121819. * The strenth of the explosion.
  121820. */
  121821. strength: number;
  121822. /**
  121823. * The strenght of the force in correspondence to the distance of the affected object
  121824. */
  121825. falloff: PhysicsRadialImpulseFalloff;
  121826. /**
  121827. * Sphere options for the radial explosion.
  121828. */
  121829. sphere: {
  121830. segments: number;
  121831. diameter: number;
  121832. };
  121833. /**
  121834. * Sphere options for the radial explosion.
  121835. */
  121836. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  121837. }
  121838. /**
  121839. * Options fot the updraft event
  121840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121841. */
  121842. export class PhysicsUpdraftEventOptions {
  121843. /**
  121844. * The radius of the cylinder for the vortex
  121845. */
  121846. radius: number;
  121847. /**
  121848. * The strenth of the updraft.
  121849. */
  121850. strength: number;
  121851. /**
  121852. * The height of the cylinder for the updraft.
  121853. */
  121854. height: number;
  121855. /**
  121856. * The mode for the the updraft.
  121857. */
  121858. updraftMode: PhysicsUpdraftMode;
  121859. }
  121860. /**
  121861. * Options fot the vortex event
  121862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121863. */
  121864. export class PhysicsVortexEventOptions {
  121865. /**
  121866. * The radius of the cylinder for the vortex
  121867. */
  121868. radius: number;
  121869. /**
  121870. * The strenth of the vortex.
  121871. */
  121872. strength: number;
  121873. /**
  121874. * The height of the cylinder for the vortex.
  121875. */
  121876. height: number;
  121877. /**
  121878. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  121879. */
  121880. centripetalForceThreshold: number;
  121881. /**
  121882. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  121883. */
  121884. centripetalForceMultiplier: number;
  121885. /**
  121886. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  121887. */
  121888. centrifugalForceMultiplier: number;
  121889. /**
  121890. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  121891. */
  121892. updraftForceMultiplier: number;
  121893. }
  121894. /**
  121895. * The strenght of the force in correspondence to the distance of the affected object
  121896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121897. */
  121898. export enum PhysicsRadialImpulseFalloff {
  121899. /** Defines that impulse is constant in strength across it's whole radius */
  121900. Constant = 0,
  121901. /** Defines that impulse gets weaker if it's further from the origin */
  121902. Linear = 1
  121903. }
  121904. /**
  121905. * The strength of the force in correspondence to the distance of the affected object
  121906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121907. */
  121908. export enum PhysicsUpdraftMode {
  121909. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  121910. Center = 0,
  121911. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  121912. Perpendicular = 1
  121913. }
  121914. /**
  121915. * Interface for a physics hit data
  121916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121917. */
  121918. export interface PhysicsHitData {
  121919. /**
  121920. * The force applied at the contact point
  121921. */
  121922. force: Vector3;
  121923. /**
  121924. * The contact point
  121925. */
  121926. contactPoint: Vector3;
  121927. /**
  121928. * The distance from the origin to the contact point
  121929. */
  121930. distanceFromOrigin: number;
  121931. }
  121932. /**
  121933. * Interface for radial explosion event data
  121934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121935. */
  121936. export interface PhysicsRadialExplosionEventData {
  121937. /**
  121938. * A sphere used for the radial explosion event
  121939. */
  121940. sphere: Mesh;
  121941. }
  121942. /**
  121943. * Interface for gravitational field event data
  121944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121945. */
  121946. export interface PhysicsGravitationalFieldEventData {
  121947. /**
  121948. * A sphere mesh used for the gravitational field event
  121949. */
  121950. sphere: Mesh;
  121951. }
  121952. /**
  121953. * Interface for updraft event data
  121954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121955. */
  121956. export interface PhysicsUpdraftEventData {
  121957. /**
  121958. * A cylinder used for the updraft event
  121959. */
  121960. cylinder: Mesh;
  121961. }
  121962. /**
  121963. * Interface for vortex event data
  121964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121965. */
  121966. export interface PhysicsVortexEventData {
  121967. /**
  121968. * A cylinder used for the vortex event
  121969. */
  121970. cylinder: Mesh;
  121971. }
  121972. /**
  121973. * Interface for an affected physics impostor
  121974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121975. */
  121976. export interface PhysicsAffectedImpostorWithData {
  121977. /**
  121978. * The impostor affected by the effect
  121979. */
  121980. impostor: PhysicsImpostor;
  121981. /**
  121982. * The data about the hit/horce from the explosion
  121983. */
  121984. hitData: PhysicsHitData;
  121985. }
  121986. }
  121987. declare module BABYLON {
  121988. /** @hidden */
  121989. export var blackAndWhitePixelShader: {
  121990. name: string;
  121991. shader: string;
  121992. };
  121993. }
  121994. declare module BABYLON {
  121995. /**
  121996. * Post process used to render in black and white
  121997. */
  121998. export class BlackAndWhitePostProcess extends PostProcess {
  121999. /**
  122000. * Linear about to convert he result to black and white (default: 1)
  122001. */
  122002. degree: number;
  122003. /**
  122004. * Creates a black and white post process
  122005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122006. * @param name The name of the effect.
  122007. * @param options The required width/height ratio to downsize to before computing the render pass.
  122008. * @param camera The camera to apply the render pass to.
  122009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122010. * @param engine The engine which the post process will be applied. (default: current engine)
  122011. * @param reusable If the post process can be reused on the same frame. (default: false)
  122012. */
  122013. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122014. }
  122015. }
  122016. declare module BABYLON {
  122017. /**
  122018. * This represents a set of one or more post processes in Babylon.
  122019. * A post process can be used to apply a shader to a texture after it is rendered.
  122020. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122021. */
  122022. export class PostProcessRenderEffect {
  122023. private _postProcesses;
  122024. private _getPostProcesses;
  122025. private _singleInstance;
  122026. private _cameras;
  122027. private _indicesForCamera;
  122028. /**
  122029. * Name of the effect
  122030. * @hidden
  122031. */
  122032. _name: string;
  122033. /**
  122034. * Instantiates a post process render effect.
  122035. * A post process can be used to apply a shader to a texture after it is rendered.
  122036. * @param engine The engine the effect is tied to
  122037. * @param name The name of the effect
  122038. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  122039. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  122040. */
  122041. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  122042. /**
  122043. * Checks if all the post processes in the effect are supported.
  122044. */
  122045. readonly isSupported: boolean;
  122046. /**
  122047. * Updates the current state of the effect
  122048. * @hidden
  122049. */
  122050. _update(): void;
  122051. /**
  122052. * Attaches the effect on cameras
  122053. * @param cameras The camera to attach to.
  122054. * @hidden
  122055. */
  122056. _attachCameras(cameras: Camera): void;
  122057. /**
  122058. * Attaches the effect on cameras
  122059. * @param cameras The camera to attach to.
  122060. * @hidden
  122061. */
  122062. _attachCameras(cameras: Camera[]): void;
  122063. /**
  122064. * Detaches the effect on cameras
  122065. * @param cameras The camera to detatch from.
  122066. * @hidden
  122067. */
  122068. _detachCameras(cameras: Camera): void;
  122069. /**
  122070. * Detatches the effect on cameras
  122071. * @param cameras The camera to detatch from.
  122072. * @hidden
  122073. */
  122074. _detachCameras(cameras: Camera[]): void;
  122075. /**
  122076. * Enables the effect on given cameras
  122077. * @param cameras The camera to enable.
  122078. * @hidden
  122079. */
  122080. _enable(cameras: Camera): void;
  122081. /**
  122082. * Enables the effect on given cameras
  122083. * @param cameras The camera to enable.
  122084. * @hidden
  122085. */
  122086. _enable(cameras: Nullable<Camera[]>): void;
  122087. /**
  122088. * Disables the effect on the given cameras
  122089. * @param cameras The camera to disable.
  122090. * @hidden
  122091. */
  122092. _disable(cameras: Camera): void;
  122093. /**
  122094. * Disables the effect on the given cameras
  122095. * @param cameras The camera to disable.
  122096. * @hidden
  122097. */
  122098. _disable(cameras: Nullable<Camera[]>): void;
  122099. /**
  122100. * Gets a list of the post processes contained in the effect.
  122101. * @param camera The camera to get the post processes on.
  122102. * @returns The list of the post processes in the effect.
  122103. */
  122104. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  122105. }
  122106. }
  122107. declare module BABYLON {
  122108. /** @hidden */
  122109. export var extractHighlightsPixelShader: {
  122110. name: string;
  122111. shader: string;
  122112. };
  122113. }
  122114. declare module BABYLON {
  122115. /**
  122116. * 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.
  122117. */
  122118. export class ExtractHighlightsPostProcess extends PostProcess {
  122119. /**
  122120. * The luminance threshold, pixels below this value will be set to black.
  122121. */
  122122. threshold: number;
  122123. /** @hidden */
  122124. _exposure: number;
  122125. /**
  122126. * Post process which has the input texture to be used when performing highlight extraction
  122127. * @hidden
  122128. */
  122129. _inputPostProcess: Nullable<PostProcess>;
  122130. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122131. }
  122132. }
  122133. declare module BABYLON {
  122134. /** @hidden */
  122135. export var bloomMergePixelShader: {
  122136. name: string;
  122137. shader: string;
  122138. };
  122139. }
  122140. declare module BABYLON {
  122141. /**
  122142. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122143. */
  122144. export class BloomMergePostProcess extends PostProcess {
  122145. /** Weight of the bloom to be added to the original input. */
  122146. weight: number;
  122147. /**
  122148. * Creates a new instance of @see BloomMergePostProcess
  122149. * @param name The name of the effect.
  122150. * @param originalFromInput Post process which's input will be used for the merge.
  122151. * @param blurred Blurred highlights post process which's output will be used.
  122152. * @param weight Weight of the bloom to be added to the original input.
  122153. * @param options The required width/height ratio to downsize to before computing the render pass.
  122154. * @param camera The camera to apply the render pass to.
  122155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122156. * @param engine The engine which the post process will be applied. (default: current engine)
  122157. * @param reusable If the post process can be reused on the same frame. (default: false)
  122158. * @param textureType Type of textures used when performing the post process. (default: 0)
  122159. * @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)
  122160. */
  122161. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  122162. /** Weight of the bloom to be added to the original input. */
  122163. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122164. }
  122165. }
  122166. declare module BABYLON {
  122167. /**
  122168. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122169. */
  122170. export class BloomEffect extends PostProcessRenderEffect {
  122171. private bloomScale;
  122172. /**
  122173. * @hidden Internal
  122174. */
  122175. _effects: Array<PostProcess>;
  122176. /**
  122177. * @hidden Internal
  122178. */
  122179. _downscale: ExtractHighlightsPostProcess;
  122180. private _blurX;
  122181. private _blurY;
  122182. private _merge;
  122183. /**
  122184. * The luminance threshold to find bright areas of the image to bloom.
  122185. */
  122186. threshold: number;
  122187. /**
  122188. * The strength of the bloom.
  122189. */
  122190. weight: number;
  122191. /**
  122192. * Specifies the size of the bloom blur kernel, relative to the final output size
  122193. */
  122194. kernel: number;
  122195. /**
  122196. * Creates a new instance of @see BloomEffect
  122197. * @param scene The scene the effect belongs to.
  122198. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122199. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122200. * @param bloomWeight The the strength of bloom.
  122201. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122202. * @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)
  122203. */
  122204. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  122205. /**
  122206. * Disposes each of the internal effects for a given camera.
  122207. * @param camera The camera to dispose the effect on.
  122208. */
  122209. disposeEffects(camera: Camera): void;
  122210. /**
  122211. * @hidden Internal
  122212. */
  122213. _updateEffects(): void;
  122214. /**
  122215. * Internal
  122216. * @returns if all the contained post processes are ready.
  122217. * @hidden
  122218. */
  122219. _isReady(): boolean;
  122220. }
  122221. }
  122222. declare module BABYLON {
  122223. /** @hidden */
  122224. export var chromaticAberrationPixelShader: {
  122225. name: string;
  122226. shader: string;
  122227. };
  122228. }
  122229. declare module BABYLON {
  122230. /**
  122231. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122232. */
  122233. export class ChromaticAberrationPostProcess extends PostProcess {
  122234. /**
  122235. * The amount of seperation of rgb channels (default: 30)
  122236. */
  122237. aberrationAmount: number;
  122238. /**
  122239. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122240. */
  122241. radialIntensity: number;
  122242. /**
  122243. * 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))
  122244. */
  122245. direction: Vector2;
  122246. /**
  122247. * 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))
  122248. */
  122249. centerPosition: Vector2;
  122250. /**
  122251. * Creates a new instance ChromaticAberrationPostProcess
  122252. * @param name The name of the effect.
  122253. * @param screenWidth The width of the screen to apply the effect on.
  122254. * @param screenHeight The height of the screen to apply the effect on.
  122255. * @param options The required width/height ratio to downsize to before computing the render pass.
  122256. * @param camera The camera to apply the render pass to.
  122257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122258. * @param engine The engine which the post process will be applied. (default: current engine)
  122259. * @param reusable If the post process can be reused on the same frame. (default: false)
  122260. * @param textureType Type of textures used when performing the post process. (default: 0)
  122261. * @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)
  122262. */
  122263. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122264. }
  122265. }
  122266. declare module BABYLON {
  122267. /** @hidden */
  122268. export var circleOfConfusionPixelShader: {
  122269. name: string;
  122270. shader: string;
  122271. };
  122272. }
  122273. declare module BABYLON {
  122274. /**
  122275. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122276. */
  122277. export class CircleOfConfusionPostProcess extends PostProcess {
  122278. /**
  122279. * 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.
  122280. */
  122281. lensSize: number;
  122282. /**
  122283. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122284. */
  122285. fStop: number;
  122286. /**
  122287. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122288. */
  122289. focusDistance: number;
  122290. /**
  122291. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122292. */
  122293. focalLength: number;
  122294. private _depthTexture;
  122295. /**
  122296. * Creates a new instance CircleOfConfusionPostProcess
  122297. * @param name The name of the effect.
  122298. * @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.
  122299. * @param options The required width/height ratio to downsize to before computing the render pass.
  122300. * @param camera The camera to apply the render pass to.
  122301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122302. * @param engine The engine which the post process will be applied. (default: current engine)
  122303. * @param reusable If the post process can be reused on the same frame. (default: false)
  122304. * @param textureType Type of textures used when performing the post process. (default: 0)
  122305. * @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)
  122306. */
  122307. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122308. /**
  122309. * 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.
  122310. */
  122311. depthTexture: RenderTargetTexture;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /** @hidden */
  122316. export var colorCorrectionPixelShader: {
  122317. name: string;
  122318. shader: string;
  122319. };
  122320. }
  122321. declare module BABYLON {
  122322. /**
  122323. *
  122324. * This post-process allows the modification of rendered colors by using
  122325. * a 'look-up table' (LUT). This effect is also called Color Grading.
  122326. *
  122327. * The object needs to be provided an url to a texture containing the color
  122328. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  122329. * Use an image editing software to tweak the LUT to match your needs.
  122330. *
  122331. * For an example of a color LUT, see here:
  122332. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  122333. * For explanations on color grading, see here:
  122334. * @see http://udn.epicgames.com/Three/ColorGrading.html
  122335. *
  122336. */
  122337. export class ColorCorrectionPostProcess extends PostProcess {
  122338. private _colorTableTexture;
  122339. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122340. }
  122341. }
  122342. declare module BABYLON {
  122343. /** @hidden */
  122344. export var convolutionPixelShader: {
  122345. name: string;
  122346. shader: string;
  122347. };
  122348. }
  122349. declare module BABYLON {
  122350. /**
  122351. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  122352. * input texture to perform effects such as edge detection or sharpening
  122353. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122354. */
  122355. export class ConvolutionPostProcess extends PostProcess {
  122356. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122357. kernel: number[];
  122358. /**
  122359. * Creates a new instance ConvolutionPostProcess
  122360. * @param name The name of the effect.
  122361. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  122362. * @param options The required width/height ratio to downsize to before computing the render pass.
  122363. * @param camera The camera to apply the render pass to.
  122364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122365. * @param engine The engine which the post process will be applied. (default: current engine)
  122366. * @param reusable If the post process can be reused on the same frame. (default: false)
  122367. * @param textureType Type of textures used when performing the post process. (default: 0)
  122368. */
  122369. constructor(name: string,
  122370. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122371. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122372. /**
  122373. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122374. */
  122375. static EdgeDetect0Kernel: number[];
  122376. /**
  122377. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122378. */
  122379. static EdgeDetect1Kernel: number[];
  122380. /**
  122381. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122382. */
  122383. static EdgeDetect2Kernel: number[];
  122384. /**
  122385. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122386. */
  122387. static SharpenKernel: number[];
  122388. /**
  122389. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122390. */
  122391. static EmbossKernel: number[];
  122392. /**
  122393. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122394. */
  122395. static GaussianKernel: number[];
  122396. }
  122397. }
  122398. declare module BABYLON {
  122399. /**
  122400. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  122401. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  122402. * based on samples that have a large difference in distance than the center pixel.
  122403. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  122404. */
  122405. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  122406. direction: Vector2;
  122407. /**
  122408. * Creates a new instance CircleOfConfusionPostProcess
  122409. * @param name The name of the effect.
  122410. * @param scene The scene the effect belongs to.
  122411. * @param direction The direction the blur should be applied.
  122412. * @param kernel The size of the kernel used to blur.
  122413. * @param options The required width/height ratio to downsize to before computing the render pass.
  122414. * @param camera The camera to apply the render pass to.
  122415. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  122416. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  122417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122418. * @param engine The engine which the post process will be applied. (default: current engine)
  122419. * @param reusable If the post process can be reused on the same frame. (default: false)
  122420. * @param textureType Type of textures used when performing the post process. (default: 0)
  122421. * @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)
  122422. */
  122423. 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);
  122424. }
  122425. }
  122426. declare module BABYLON {
  122427. /** @hidden */
  122428. export var depthOfFieldMergePixelShader: {
  122429. name: string;
  122430. shader: string;
  122431. };
  122432. }
  122433. declare module BABYLON {
  122434. /**
  122435. * Options to be set when merging outputs from the default pipeline.
  122436. */
  122437. export class DepthOfFieldMergePostProcessOptions {
  122438. /**
  122439. * The original image to merge on top of
  122440. */
  122441. originalFromInput: PostProcess;
  122442. /**
  122443. * Parameters to perform the merge of the depth of field effect
  122444. */
  122445. depthOfField?: {
  122446. circleOfConfusion: PostProcess;
  122447. blurSteps: Array<PostProcess>;
  122448. };
  122449. /**
  122450. * Parameters to perform the merge of bloom effect
  122451. */
  122452. bloom?: {
  122453. blurred: PostProcess;
  122454. weight: number;
  122455. };
  122456. }
  122457. /**
  122458. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122459. */
  122460. export class DepthOfFieldMergePostProcess extends PostProcess {
  122461. private blurSteps;
  122462. /**
  122463. * Creates a new instance of DepthOfFieldMergePostProcess
  122464. * @param name The name of the effect.
  122465. * @param originalFromInput Post process which's input will be used for the merge.
  122466. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  122467. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  122468. * @param options The required width/height ratio to downsize to before computing the render pass.
  122469. * @param camera The camera to apply the render pass to.
  122470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122471. * @param engine The engine which the post process will be applied. (default: current engine)
  122472. * @param reusable If the post process can be reused on the same frame. (default: false)
  122473. * @param textureType Type of textures used when performing the post process. (default: 0)
  122474. * @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)
  122475. */
  122476. 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);
  122477. /**
  122478. * Updates the effect with the current post process compile time values and recompiles the shader.
  122479. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122480. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122481. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122482. * @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
  122483. * @param onCompiled Called when the shader has been compiled.
  122484. * @param onError Called if there is an error when compiling a shader.
  122485. */
  122486. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  122487. }
  122488. }
  122489. declare module BABYLON {
  122490. /**
  122491. * Specifies the level of max blur that should be applied when using the depth of field effect
  122492. */
  122493. export enum DepthOfFieldEffectBlurLevel {
  122494. /**
  122495. * Subtle blur
  122496. */
  122497. Low = 0,
  122498. /**
  122499. * Medium blur
  122500. */
  122501. Medium = 1,
  122502. /**
  122503. * Large blur
  122504. */
  122505. High = 2
  122506. }
  122507. /**
  122508. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  122509. */
  122510. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  122511. private _circleOfConfusion;
  122512. /**
  122513. * @hidden Internal, blurs from high to low
  122514. */
  122515. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  122516. private _depthOfFieldBlurY;
  122517. private _dofMerge;
  122518. /**
  122519. * @hidden Internal post processes in depth of field effect
  122520. */
  122521. _effects: Array<PostProcess>;
  122522. /**
  122523. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  122524. */
  122525. focalLength: number;
  122526. /**
  122527. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122528. */
  122529. fStop: number;
  122530. /**
  122531. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122532. */
  122533. focusDistance: number;
  122534. /**
  122535. * 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.
  122536. */
  122537. lensSize: number;
  122538. /**
  122539. * Creates a new instance DepthOfFieldEffect
  122540. * @param scene The scene the effect belongs to.
  122541. * @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.
  122542. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122543. * @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)
  122544. */
  122545. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  122546. /**
  122547. * Get the current class name of the current effet
  122548. * @returns "DepthOfFieldEffect"
  122549. */
  122550. getClassName(): string;
  122551. /**
  122552. * 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.
  122553. */
  122554. depthTexture: RenderTargetTexture;
  122555. /**
  122556. * Disposes each of the internal effects for a given camera.
  122557. * @param camera The camera to dispose the effect on.
  122558. */
  122559. disposeEffects(camera: Camera): void;
  122560. /**
  122561. * @hidden Internal
  122562. */
  122563. _updateEffects(): void;
  122564. /**
  122565. * Internal
  122566. * @returns if all the contained post processes are ready.
  122567. * @hidden
  122568. */
  122569. _isReady(): boolean;
  122570. }
  122571. }
  122572. declare module BABYLON {
  122573. /** @hidden */
  122574. export var displayPassPixelShader: {
  122575. name: string;
  122576. shader: string;
  122577. };
  122578. }
  122579. declare module BABYLON {
  122580. /**
  122581. * DisplayPassPostProcess which produces an output the same as it's input
  122582. */
  122583. export class DisplayPassPostProcess extends PostProcess {
  122584. /**
  122585. * Creates the DisplayPassPostProcess
  122586. * @param name The name of the effect.
  122587. * @param options The required width/height ratio to downsize to before computing the render pass.
  122588. * @param camera The camera to apply the render pass to.
  122589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122590. * @param engine The engine which the post process will be applied. (default: current engine)
  122591. * @param reusable If the post process can be reused on the same frame. (default: false)
  122592. */
  122593. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122594. }
  122595. }
  122596. declare module BABYLON {
  122597. /** @hidden */
  122598. export var filterPixelShader: {
  122599. name: string;
  122600. shader: string;
  122601. };
  122602. }
  122603. declare module BABYLON {
  122604. /**
  122605. * Applies a kernel filter to the image
  122606. */
  122607. export class FilterPostProcess extends PostProcess {
  122608. /** The matrix to be applied to the image */
  122609. kernelMatrix: Matrix;
  122610. /**
  122611. *
  122612. * @param name The name of the effect.
  122613. * @param kernelMatrix The matrix to be applied to the image
  122614. * @param options The required width/height ratio to downsize to before computing the render pass.
  122615. * @param camera The camera to apply the render pass to.
  122616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122617. * @param engine The engine which the post process will be applied. (default: current engine)
  122618. * @param reusable If the post process can be reused on the same frame. (default: false)
  122619. */
  122620. constructor(name: string,
  122621. /** The matrix to be applied to the image */
  122622. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122623. }
  122624. }
  122625. declare module BABYLON {
  122626. /** @hidden */
  122627. export var fxaaPixelShader: {
  122628. name: string;
  122629. shader: string;
  122630. };
  122631. }
  122632. declare module BABYLON {
  122633. /** @hidden */
  122634. export var fxaaVertexShader: {
  122635. name: string;
  122636. shader: string;
  122637. };
  122638. }
  122639. declare module BABYLON {
  122640. /**
  122641. * Fxaa post process
  122642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122643. */
  122644. export class FxaaPostProcess extends PostProcess {
  122645. /** @hidden */
  122646. texelWidth: number;
  122647. /** @hidden */
  122648. texelHeight: number;
  122649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122650. private _getDefines;
  122651. }
  122652. }
  122653. declare module BABYLON {
  122654. /** @hidden */
  122655. export var grainPixelShader: {
  122656. name: string;
  122657. shader: string;
  122658. };
  122659. }
  122660. declare module BABYLON {
  122661. /**
  122662. * The GrainPostProcess adds noise to the image at mid luminance levels
  122663. */
  122664. export class GrainPostProcess extends PostProcess {
  122665. /**
  122666. * The intensity of the grain added (default: 30)
  122667. */
  122668. intensity: number;
  122669. /**
  122670. * If the grain should be randomized on every frame
  122671. */
  122672. animated: boolean;
  122673. /**
  122674. * Creates a new instance of @see GrainPostProcess
  122675. * @param name The name of the effect.
  122676. * @param options The required width/height ratio to downsize to before computing the render pass.
  122677. * @param camera The camera to apply the render pass to.
  122678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122679. * @param engine The engine which the post process will be applied. (default: current engine)
  122680. * @param reusable If the post process can be reused on the same frame. (default: false)
  122681. * @param textureType Type of textures used when performing the post process. (default: 0)
  122682. * @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)
  122683. */
  122684. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122685. }
  122686. }
  122687. declare module BABYLON {
  122688. /** @hidden */
  122689. export var highlightsPixelShader: {
  122690. name: string;
  122691. shader: string;
  122692. };
  122693. }
  122694. declare module BABYLON {
  122695. /**
  122696. * Extracts highlights from the image
  122697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122698. */
  122699. export class HighlightsPostProcess extends PostProcess {
  122700. /**
  122701. * Extracts highlights from the image
  122702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122703. * @param name The name of the effect.
  122704. * @param options The required width/height ratio to downsize to before computing the render pass.
  122705. * @param camera The camera to apply the render pass to.
  122706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122707. * @param engine The engine which the post process will be applied. (default: current engine)
  122708. * @param reusable If the post process can be reused on the same frame. (default: false)
  122709. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122710. */
  122711. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122712. }
  122713. }
  122714. declare module BABYLON {
  122715. /** @hidden */
  122716. export var mrtFragmentDeclaration: {
  122717. name: string;
  122718. shader: string;
  122719. };
  122720. }
  122721. declare module BABYLON {
  122722. /** @hidden */
  122723. export var geometryPixelShader: {
  122724. name: string;
  122725. shader: string;
  122726. };
  122727. }
  122728. declare module BABYLON {
  122729. /** @hidden */
  122730. export var geometryVertexShader: {
  122731. name: string;
  122732. shader: string;
  122733. };
  122734. }
  122735. declare module BABYLON {
  122736. /** @hidden */
  122737. interface ISavedTransformationMatrix {
  122738. world: Matrix;
  122739. viewProjection: Matrix;
  122740. }
  122741. /**
  122742. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122743. */
  122744. export class GeometryBufferRenderer {
  122745. /**
  122746. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122747. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122748. */
  122749. static readonly POSITION_TEXTURE_TYPE: number;
  122750. /**
  122751. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122752. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122753. */
  122754. static readonly VELOCITY_TEXTURE_TYPE: number;
  122755. /**
  122756. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122757. * in order to compute objects velocities when enableVelocity is set to "true"
  122758. * @hidden
  122759. */
  122760. _previousTransformationMatrices: {
  122761. [index: number]: ISavedTransformationMatrix;
  122762. };
  122763. /**
  122764. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  122765. * in order to compute objects velocities when enableVelocity is set to "true"
  122766. * @hidden
  122767. */
  122768. _previousBonesTransformationMatrices: {
  122769. [index: number]: Float32Array;
  122770. };
  122771. /**
  122772. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  122773. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  122774. */
  122775. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  122776. private _scene;
  122777. private _multiRenderTarget;
  122778. private _ratio;
  122779. private _enablePosition;
  122780. private _enableVelocity;
  122781. private _positionIndex;
  122782. private _velocityIndex;
  122783. protected _effect: Effect;
  122784. protected _cachedDefines: string;
  122785. /**
  122786. * Set the render list (meshes to be rendered) used in the G buffer.
  122787. */
  122788. renderList: Mesh[];
  122789. /**
  122790. * Gets wether or not G buffer are supported by the running hardware.
  122791. * This requires draw buffer supports
  122792. */
  122793. readonly isSupported: boolean;
  122794. /**
  122795. * Returns the index of the given texture type in the G-Buffer textures array
  122796. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122797. * @returns the index of the given texture type in the G-Buffer textures array
  122798. */
  122799. getTextureIndex(textureType: number): number;
  122800. /**
  122801. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122802. */
  122803. /**
  122804. * Sets whether or not objects positions are enabled for the G buffer.
  122805. */
  122806. enablePosition: boolean;
  122807. /**
  122808. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122809. */
  122810. /**
  122811. * Sets wether or not objects velocities are enabled for the G buffer.
  122812. */
  122813. enableVelocity: boolean;
  122814. /**
  122815. * Gets the scene associated with the buffer.
  122816. */
  122817. readonly scene: Scene;
  122818. /**
  122819. * Gets the ratio used by the buffer during its creation.
  122820. * How big is the buffer related to the main canvas.
  122821. */
  122822. readonly ratio: number;
  122823. /** @hidden */
  122824. static _SceneComponentInitialization: (scene: Scene) => void;
  122825. /**
  122826. * Creates a new G Buffer for the scene
  122827. * @param scene The scene the buffer belongs to
  122828. * @param ratio How big is the buffer related to the main canvas.
  122829. */
  122830. constructor(scene: Scene, ratio?: number);
  122831. /**
  122832. * Checks wether everything is ready to render a submesh to the G buffer.
  122833. * @param subMesh the submesh to check readiness for
  122834. * @param useInstances is the mesh drawn using instance or not
  122835. * @returns true if ready otherwise false
  122836. */
  122837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122838. /**
  122839. * Gets the current underlying G Buffer.
  122840. * @returns the buffer
  122841. */
  122842. getGBuffer(): MultiRenderTarget;
  122843. /**
  122844. * Gets the number of samples used to render the buffer (anti aliasing).
  122845. */
  122846. /**
  122847. * Sets the number of samples used to render the buffer (anti aliasing).
  122848. */
  122849. samples: number;
  122850. /**
  122851. * Disposes the renderer and frees up associated resources.
  122852. */
  122853. dispose(): void;
  122854. protected _createRenderTargets(): void;
  122855. private _copyBonesTransformationMatrices;
  122856. }
  122857. }
  122858. declare module BABYLON {
  122859. interface Scene {
  122860. /** @hidden (Backing field) */
  122861. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122862. /**
  122863. * Gets or Sets the current geometry buffer associated to the scene.
  122864. */
  122865. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122866. /**
  122867. * Enables a GeometryBufferRender and associates it with the scene
  122868. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  122869. * @returns the GeometryBufferRenderer
  122870. */
  122871. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  122872. /**
  122873. * Disables the GeometryBufferRender associated with the scene
  122874. */
  122875. disableGeometryBufferRenderer(): void;
  122876. }
  122877. /**
  122878. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  122879. * in several rendering techniques.
  122880. */
  122881. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  122882. /**
  122883. * The component name helpful to identify the component in the list of scene components.
  122884. */
  122885. readonly name: string;
  122886. /**
  122887. * The scene the component belongs to.
  122888. */
  122889. scene: Scene;
  122890. /**
  122891. * Creates a new instance of the component for the given scene
  122892. * @param scene Defines the scene to register the component in
  122893. */
  122894. constructor(scene: Scene);
  122895. /**
  122896. * Registers the component in a given scene
  122897. */
  122898. register(): void;
  122899. /**
  122900. * Rebuilds the elements related to this component in case of
  122901. * context lost for instance.
  122902. */
  122903. rebuild(): void;
  122904. /**
  122905. * Disposes the component and the associated ressources
  122906. */
  122907. dispose(): void;
  122908. private _gatherRenderTargets;
  122909. }
  122910. }
  122911. declare module BABYLON {
  122912. /** @hidden */
  122913. export var motionBlurPixelShader: {
  122914. name: string;
  122915. shader: string;
  122916. };
  122917. }
  122918. declare module BABYLON {
  122919. /**
  122920. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122921. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122922. * As an example, all you have to do is to create the post-process:
  122923. * var mb = new BABYLON.MotionBlurPostProcess(
  122924. * 'mb', // The name of the effect.
  122925. * scene, // The scene containing the objects to blur according to their velocity.
  122926. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122927. * camera // The camera to apply the render pass to.
  122928. * );
  122929. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122930. */
  122931. export class MotionBlurPostProcess extends PostProcess {
  122932. /**
  122933. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122934. */
  122935. motionStrength: number;
  122936. /**
  122937. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122938. */
  122939. /**
  122940. * Sets the number of iterations to be used for motion blur quality
  122941. */
  122942. motionBlurSamples: number;
  122943. private _motionBlurSamples;
  122944. private _geometryBufferRenderer;
  122945. /**
  122946. * Creates a new instance MotionBlurPostProcess
  122947. * @param name The name of the effect.
  122948. * @param scene The scene containing the objects to blur according to their velocity.
  122949. * @param options The required width/height ratio to downsize to before computing the render pass.
  122950. * @param camera The camera to apply the render pass to.
  122951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122952. * @param engine The engine which the post process will be applied. (default: current engine)
  122953. * @param reusable If the post process can be reused on the same frame. (default: false)
  122954. * @param textureType Type of textures used when performing the post process. (default: 0)
  122955. * @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)
  122956. */
  122957. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122958. /**
  122959. * Excludes the given skinned mesh from computing bones velocities.
  122960. * 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.
  122961. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  122962. */
  122963. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122964. /**
  122965. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  122966. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  122967. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  122968. */
  122969. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122970. /**
  122971. * Disposes the post process.
  122972. * @param camera The camera to dispose the post process on.
  122973. */
  122974. dispose(camera?: Camera): void;
  122975. }
  122976. }
  122977. declare module BABYLON {
  122978. /** @hidden */
  122979. export var refractionPixelShader: {
  122980. name: string;
  122981. shader: string;
  122982. };
  122983. }
  122984. declare module BABYLON {
  122985. /**
  122986. * Post process which applies a refractin texture
  122987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122988. */
  122989. export class RefractionPostProcess extends PostProcess {
  122990. /** the base color of the refraction (used to taint the rendering) */
  122991. color: Color3;
  122992. /** simulated refraction depth */
  122993. depth: number;
  122994. /** the coefficient of the base color (0 to remove base color tainting) */
  122995. colorLevel: number;
  122996. private _refTexture;
  122997. private _ownRefractionTexture;
  122998. /**
  122999. * Gets or sets the refraction texture
  123000. * Please note that you are responsible for disposing the texture if you set it manually
  123001. */
  123002. refractionTexture: Texture;
  123003. /**
  123004. * Initializes the RefractionPostProcess
  123005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123006. * @param name The name of the effect.
  123007. * @param refractionTextureUrl Url of the refraction texture to use
  123008. * @param color the base color of the refraction (used to taint the rendering)
  123009. * @param depth simulated refraction depth
  123010. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  123011. * @param camera The camera to apply the render pass to.
  123012. * @param options The required width/height ratio to downsize to before computing the render pass.
  123013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123014. * @param engine The engine which the post process will be applied. (default: current engine)
  123015. * @param reusable If the post process can be reused on the same frame. (default: false)
  123016. */
  123017. constructor(name: string, refractionTextureUrl: string,
  123018. /** the base color of the refraction (used to taint the rendering) */
  123019. color: Color3,
  123020. /** simulated refraction depth */
  123021. depth: number,
  123022. /** the coefficient of the base color (0 to remove base color tainting) */
  123023. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123024. /**
  123025. * Disposes of the post process
  123026. * @param camera Camera to dispose post process on
  123027. */
  123028. dispose(camera: Camera): void;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. /** @hidden */
  123033. export var sharpenPixelShader: {
  123034. name: string;
  123035. shader: string;
  123036. };
  123037. }
  123038. declare module BABYLON {
  123039. /**
  123040. * The SharpenPostProcess applies a sharpen kernel to every pixel
  123041. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123042. */
  123043. export class SharpenPostProcess extends PostProcess {
  123044. /**
  123045. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  123046. */
  123047. colorAmount: number;
  123048. /**
  123049. * How much sharpness should be applied (default: 0.3)
  123050. */
  123051. edgeAmount: number;
  123052. /**
  123053. * Creates a new instance ConvolutionPostProcess
  123054. * @param name The name of the effect.
  123055. * @param options The required width/height ratio to downsize to before computing the render pass.
  123056. * @param camera The camera to apply the render pass to.
  123057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123058. * @param engine The engine which the post process will be applied. (default: current engine)
  123059. * @param reusable If the post process can be reused on the same frame. (default: false)
  123060. * @param textureType Type of textures used when performing the post process. (default: 0)
  123061. * @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)
  123062. */
  123063. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123064. }
  123065. }
  123066. declare module BABYLON {
  123067. /**
  123068. * PostProcessRenderPipeline
  123069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123070. */
  123071. export class PostProcessRenderPipeline {
  123072. private engine;
  123073. private _renderEffects;
  123074. private _renderEffectsForIsolatedPass;
  123075. /**
  123076. * List of inspectable custom properties (used by the Inspector)
  123077. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  123078. */
  123079. inspectableCustomProperties: IInspectable[];
  123080. /**
  123081. * @hidden
  123082. */
  123083. protected _cameras: Camera[];
  123084. /** @hidden */
  123085. _name: string;
  123086. /**
  123087. * Gets pipeline name
  123088. */
  123089. readonly name: string;
  123090. /**
  123091. * Initializes a PostProcessRenderPipeline
  123092. * @param engine engine to add the pipeline to
  123093. * @param name name of the pipeline
  123094. */
  123095. constructor(engine: Engine, name: string);
  123096. /**
  123097. * Gets the class name
  123098. * @returns "PostProcessRenderPipeline"
  123099. */
  123100. getClassName(): string;
  123101. /**
  123102. * If all the render effects in the pipeline are supported
  123103. */
  123104. readonly isSupported: boolean;
  123105. /**
  123106. * Adds an effect to the pipeline
  123107. * @param renderEffect the effect to add
  123108. */
  123109. addEffect(renderEffect: PostProcessRenderEffect): void;
  123110. /** @hidden */
  123111. _rebuild(): void;
  123112. /** @hidden */
  123113. _enableEffect(renderEffectName: string, cameras: Camera): void;
  123114. /** @hidden */
  123115. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  123116. /** @hidden */
  123117. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123118. /** @hidden */
  123119. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123120. /** @hidden */
  123121. _attachCameras(cameras: Camera, unique: boolean): void;
  123122. /** @hidden */
  123123. _attachCameras(cameras: Camera[], unique: boolean): void;
  123124. /** @hidden */
  123125. _detachCameras(cameras: Camera): void;
  123126. /** @hidden */
  123127. _detachCameras(cameras: Nullable<Camera[]>): void;
  123128. /** @hidden */
  123129. _update(): void;
  123130. /** @hidden */
  123131. _reset(): void;
  123132. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  123133. /**
  123134. * Disposes of the pipeline
  123135. */
  123136. dispose(): void;
  123137. }
  123138. }
  123139. declare module BABYLON {
  123140. /**
  123141. * PostProcessRenderPipelineManager class
  123142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123143. */
  123144. export class PostProcessRenderPipelineManager {
  123145. private _renderPipelines;
  123146. /**
  123147. * Initializes a PostProcessRenderPipelineManager
  123148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123149. */
  123150. constructor();
  123151. /**
  123152. * Gets the list of supported render pipelines
  123153. */
  123154. readonly supportedPipelines: PostProcessRenderPipeline[];
  123155. /**
  123156. * Adds a pipeline to the manager
  123157. * @param renderPipeline The pipeline to add
  123158. */
  123159. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  123160. /**
  123161. * Attaches a camera to the pipeline
  123162. * @param renderPipelineName The name of the pipeline to attach to
  123163. * @param cameras the camera to attach
  123164. * @param unique if the camera can be attached multiple times to the pipeline
  123165. */
  123166. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  123167. /**
  123168. * Detaches a camera from the pipeline
  123169. * @param renderPipelineName The name of the pipeline to detach from
  123170. * @param cameras the camera to detach
  123171. */
  123172. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  123173. /**
  123174. * Enables an effect by name on a pipeline
  123175. * @param renderPipelineName the name of the pipeline to enable the effect in
  123176. * @param renderEffectName the name of the effect to enable
  123177. * @param cameras the cameras that the effect should be enabled on
  123178. */
  123179. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123180. /**
  123181. * Disables an effect by name on a pipeline
  123182. * @param renderPipelineName the name of the pipeline to disable the effect in
  123183. * @param renderEffectName the name of the effect to disable
  123184. * @param cameras the cameras that the effect should be disabled on
  123185. */
  123186. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123187. /**
  123188. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  123189. */
  123190. update(): void;
  123191. /** @hidden */
  123192. _rebuild(): void;
  123193. /**
  123194. * Disposes of the manager and pipelines
  123195. */
  123196. dispose(): void;
  123197. }
  123198. }
  123199. declare module BABYLON {
  123200. interface Scene {
  123201. /** @hidden (Backing field) */
  123202. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123203. /**
  123204. * Gets the postprocess render pipeline manager
  123205. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123206. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123207. */
  123208. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123209. }
  123210. /**
  123211. * Defines the Render Pipeline scene component responsible to rendering pipelines
  123212. */
  123213. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  123214. /**
  123215. * The component name helpfull to identify the component in the list of scene components.
  123216. */
  123217. readonly name: string;
  123218. /**
  123219. * The scene the component belongs to.
  123220. */
  123221. scene: Scene;
  123222. /**
  123223. * Creates a new instance of the component for the given scene
  123224. * @param scene Defines the scene to register the component in
  123225. */
  123226. constructor(scene: Scene);
  123227. /**
  123228. * Registers the component in a given scene
  123229. */
  123230. register(): void;
  123231. /**
  123232. * Rebuilds the elements related to this component in case of
  123233. * context lost for instance.
  123234. */
  123235. rebuild(): void;
  123236. /**
  123237. * Disposes the component and the associated ressources
  123238. */
  123239. dispose(): void;
  123240. private _gatherRenderTargets;
  123241. }
  123242. }
  123243. declare module BABYLON {
  123244. /**
  123245. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  123246. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123247. */
  123248. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123249. private _scene;
  123250. private _camerasToBeAttached;
  123251. /**
  123252. * ID of the sharpen post process,
  123253. */
  123254. private readonly SharpenPostProcessId;
  123255. /**
  123256. * @ignore
  123257. * ID of the image processing post process;
  123258. */
  123259. readonly ImageProcessingPostProcessId: string;
  123260. /**
  123261. * @ignore
  123262. * ID of the Fast Approximate Anti-Aliasing post process;
  123263. */
  123264. readonly FxaaPostProcessId: string;
  123265. /**
  123266. * ID of the chromatic aberration post process,
  123267. */
  123268. private readonly ChromaticAberrationPostProcessId;
  123269. /**
  123270. * ID of the grain post process
  123271. */
  123272. private readonly GrainPostProcessId;
  123273. /**
  123274. * Sharpen post process which will apply a sharpen convolution to enhance edges
  123275. */
  123276. sharpen: SharpenPostProcess;
  123277. private _sharpenEffect;
  123278. private bloom;
  123279. /**
  123280. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  123281. */
  123282. depthOfField: DepthOfFieldEffect;
  123283. /**
  123284. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123285. */
  123286. fxaa: FxaaPostProcess;
  123287. /**
  123288. * Image post processing pass used to perform operations such as tone mapping or color grading.
  123289. */
  123290. imageProcessing: ImageProcessingPostProcess;
  123291. /**
  123292. * Chromatic aberration post process which will shift rgb colors in the image
  123293. */
  123294. chromaticAberration: ChromaticAberrationPostProcess;
  123295. private _chromaticAberrationEffect;
  123296. /**
  123297. * Grain post process which add noise to the image
  123298. */
  123299. grain: GrainPostProcess;
  123300. private _grainEffect;
  123301. /**
  123302. * Glow post process which adds a glow to emissive areas of the image
  123303. */
  123304. private _glowLayer;
  123305. /**
  123306. * Animations which can be used to tweak settings over a period of time
  123307. */
  123308. animations: Animation[];
  123309. private _imageProcessingConfigurationObserver;
  123310. private _sharpenEnabled;
  123311. private _bloomEnabled;
  123312. private _depthOfFieldEnabled;
  123313. private _depthOfFieldBlurLevel;
  123314. private _fxaaEnabled;
  123315. private _imageProcessingEnabled;
  123316. private _defaultPipelineTextureType;
  123317. private _bloomScale;
  123318. private _chromaticAberrationEnabled;
  123319. private _grainEnabled;
  123320. private _buildAllowed;
  123321. /**
  123322. * Gets active scene
  123323. */
  123324. readonly scene: Scene;
  123325. /**
  123326. * Enable or disable the sharpen process from the pipeline
  123327. */
  123328. sharpenEnabled: boolean;
  123329. private _resizeObserver;
  123330. private _hardwareScaleLevel;
  123331. private _bloomKernel;
  123332. /**
  123333. * Specifies the size of the bloom blur kernel, relative to the final output size
  123334. */
  123335. bloomKernel: number;
  123336. /**
  123337. * Specifies the weight of the bloom in the final rendering
  123338. */
  123339. private _bloomWeight;
  123340. /**
  123341. * Specifies the luma threshold for the area that will be blurred by the bloom
  123342. */
  123343. private _bloomThreshold;
  123344. private _hdr;
  123345. /**
  123346. * The strength of the bloom.
  123347. */
  123348. bloomWeight: number;
  123349. /**
  123350. * The strength of the bloom.
  123351. */
  123352. bloomThreshold: number;
  123353. /**
  123354. * The scale of the bloom, lower value will provide better performance.
  123355. */
  123356. bloomScale: number;
  123357. /**
  123358. * Enable or disable the bloom from the pipeline
  123359. */
  123360. bloomEnabled: boolean;
  123361. private _rebuildBloom;
  123362. /**
  123363. * If the depth of field is enabled.
  123364. */
  123365. depthOfFieldEnabled: boolean;
  123366. /**
  123367. * Blur level of the depth of field effect. (Higher blur will effect performance)
  123368. */
  123369. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  123370. /**
  123371. * If the anti aliasing is enabled.
  123372. */
  123373. fxaaEnabled: boolean;
  123374. private _samples;
  123375. /**
  123376. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123377. */
  123378. samples: number;
  123379. /**
  123380. * If image processing is enabled.
  123381. */
  123382. imageProcessingEnabled: boolean;
  123383. /**
  123384. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  123385. */
  123386. glowLayerEnabled: boolean;
  123387. /**
  123388. * Gets the glow layer (or null if not defined)
  123389. */
  123390. readonly glowLayer: Nullable<GlowLayer>;
  123391. /**
  123392. * Enable or disable the chromaticAberration process from the pipeline
  123393. */
  123394. chromaticAberrationEnabled: boolean;
  123395. /**
  123396. * Enable or disable the grain process from the pipeline
  123397. */
  123398. grainEnabled: boolean;
  123399. /**
  123400. * @constructor
  123401. * @param name - The rendering pipeline name (default: "")
  123402. * @param hdr - If high dynamic range textures should be used (default: true)
  123403. * @param scene - The scene linked to this pipeline (default: the last created scene)
  123404. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  123405. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  123406. */
  123407. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  123408. /**
  123409. * Get the class name
  123410. * @returns "DefaultRenderingPipeline"
  123411. */
  123412. getClassName(): string;
  123413. /**
  123414. * Force the compilation of the entire pipeline.
  123415. */
  123416. prepare(): void;
  123417. private _hasCleared;
  123418. private _prevPostProcess;
  123419. private _prevPrevPostProcess;
  123420. private _setAutoClearAndTextureSharing;
  123421. private _depthOfFieldSceneObserver;
  123422. private _buildPipeline;
  123423. private _disposePostProcesses;
  123424. /**
  123425. * Adds a camera to the pipeline
  123426. * @param camera the camera to be added
  123427. */
  123428. addCamera(camera: Camera): void;
  123429. /**
  123430. * Removes a camera from the pipeline
  123431. * @param camera the camera to remove
  123432. */
  123433. removeCamera(camera: Camera): void;
  123434. /**
  123435. * Dispose of the pipeline and stop all post processes
  123436. */
  123437. dispose(): void;
  123438. /**
  123439. * Serialize the rendering pipeline (Used when exporting)
  123440. * @returns the serialized object
  123441. */
  123442. serialize(): any;
  123443. /**
  123444. * Parse the serialized pipeline
  123445. * @param source Source pipeline.
  123446. * @param scene The scene to load the pipeline to.
  123447. * @param rootUrl The URL of the serialized pipeline.
  123448. * @returns An instantiated pipeline from the serialized object.
  123449. */
  123450. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  123451. }
  123452. }
  123453. declare module BABYLON {
  123454. /** @hidden */
  123455. export var lensHighlightsPixelShader: {
  123456. name: string;
  123457. shader: string;
  123458. };
  123459. }
  123460. declare module BABYLON {
  123461. /** @hidden */
  123462. export var depthOfFieldPixelShader: {
  123463. name: string;
  123464. shader: string;
  123465. };
  123466. }
  123467. declare module BABYLON {
  123468. /**
  123469. * BABYLON.JS Chromatic Aberration GLSL Shader
  123470. * Author: Olivier Guyot
  123471. * Separates very slightly R, G and B colors on the edges of the screen
  123472. * Inspired by Francois Tarlier & Martins Upitis
  123473. */
  123474. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  123475. /**
  123476. * @ignore
  123477. * The chromatic aberration PostProcess id in the pipeline
  123478. */
  123479. LensChromaticAberrationEffect: string;
  123480. /**
  123481. * @ignore
  123482. * The highlights enhancing PostProcess id in the pipeline
  123483. */
  123484. HighlightsEnhancingEffect: string;
  123485. /**
  123486. * @ignore
  123487. * The depth-of-field PostProcess id in the pipeline
  123488. */
  123489. LensDepthOfFieldEffect: string;
  123490. private _scene;
  123491. private _depthTexture;
  123492. private _grainTexture;
  123493. private _chromaticAberrationPostProcess;
  123494. private _highlightsPostProcess;
  123495. private _depthOfFieldPostProcess;
  123496. private _edgeBlur;
  123497. private _grainAmount;
  123498. private _chromaticAberration;
  123499. private _distortion;
  123500. private _highlightsGain;
  123501. private _highlightsThreshold;
  123502. private _dofDistance;
  123503. private _dofAperture;
  123504. private _dofDarken;
  123505. private _dofPentagon;
  123506. private _blurNoise;
  123507. /**
  123508. * @constructor
  123509. *
  123510. * Effect parameters are as follow:
  123511. * {
  123512. * chromatic_aberration: number; // from 0 to x (1 for realism)
  123513. * edge_blur: number; // from 0 to x (1 for realism)
  123514. * distortion: number; // from 0 to x (1 for realism)
  123515. * grain_amount: number; // from 0 to 1
  123516. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  123517. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  123518. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  123519. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  123520. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  123521. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  123522. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  123523. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  123524. * }
  123525. * Note: if an effect parameter is unset, effect is disabled
  123526. *
  123527. * @param name The rendering pipeline name
  123528. * @param parameters - An object containing all parameters (see above)
  123529. * @param scene The scene linked to this pipeline
  123530. * @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)
  123531. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123532. */
  123533. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  123534. /**
  123535. * Get the class name
  123536. * @returns "LensRenderingPipeline"
  123537. */
  123538. getClassName(): string;
  123539. /**
  123540. * Gets associated scene
  123541. */
  123542. readonly scene: Scene;
  123543. /**
  123544. * Gets or sets the edge blur
  123545. */
  123546. edgeBlur: number;
  123547. /**
  123548. * Gets or sets the grain amount
  123549. */
  123550. grainAmount: number;
  123551. /**
  123552. * Gets or sets the chromatic aberration amount
  123553. */
  123554. chromaticAberration: number;
  123555. /**
  123556. * Gets or sets the depth of field aperture
  123557. */
  123558. dofAperture: number;
  123559. /**
  123560. * Gets or sets the edge distortion
  123561. */
  123562. edgeDistortion: number;
  123563. /**
  123564. * Gets or sets the depth of field distortion
  123565. */
  123566. dofDistortion: number;
  123567. /**
  123568. * Gets or sets the darken out of focus amount
  123569. */
  123570. darkenOutOfFocus: number;
  123571. /**
  123572. * Gets or sets a boolean indicating if blur noise is enabled
  123573. */
  123574. blurNoise: boolean;
  123575. /**
  123576. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  123577. */
  123578. pentagonBokeh: boolean;
  123579. /**
  123580. * Gets or sets the highlight grain amount
  123581. */
  123582. highlightsGain: number;
  123583. /**
  123584. * Gets or sets the highlight threshold
  123585. */
  123586. highlightsThreshold: number;
  123587. /**
  123588. * Sets the amount of blur at the edges
  123589. * @param amount blur amount
  123590. */
  123591. setEdgeBlur(amount: number): void;
  123592. /**
  123593. * Sets edge blur to 0
  123594. */
  123595. disableEdgeBlur(): void;
  123596. /**
  123597. * Sets the amout of grain
  123598. * @param amount Amount of grain
  123599. */
  123600. setGrainAmount(amount: number): void;
  123601. /**
  123602. * Set grain amount to 0
  123603. */
  123604. disableGrain(): void;
  123605. /**
  123606. * Sets the chromatic aberration amount
  123607. * @param amount amount of chromatic aberration
  123608. */
  123609. setChromaticAberration(amount: number): void;
  123610. /**
  123611. * Sets chromatic aberration amount to 0
  123612. */
  123613. disableChromaticAberration(): void;
  123614. /**
  123615. * Sets the EdgeDistortion amount
  123616. * @param amount amount of EdgeDistortion
  123617. */
  123618. setEdgeDistortion(amount: number): void;
  123619. /**
  123620. * Sets edge distortion to 0
  123621. */
  123622. disableEdgeDistortion(): void;
  123623. /**
  123624. * Sets the FocusDistance amount
  123625. * @param amount amount of FocusDistance
  123626. */
  123627. setFocusDistance(amount: number): void;
  123628. /**
  123629. * Disables depth of field
  123630. */
  123631. disableDepthOfField(): void;
  123632. /**
  123633. * Sets the Aperture amount
  123634. * @param amount amount of Aperture
  123635. */
  123636. setAperture(amount: number): void;
  123637. /**
  123638. * Sets the DarkenOutOfFocus amount
  123639. * @param amount amount of DarkenOutOfFocus
  123640. */
  123641. setDarkenOutOfFocus(amount: number): void;
  123642. private _pentagonBokehIsEnabled;
  123643. /**
  123644. * Creates a pentagon bokeh effect
  123645. */
  123646. enablePentagonBokeh(): void;
  123647. /**
  123648. * Disables the pentagon bokeh effect
  123649. */
  123650. disablePentagonBokeh(): void;
  123651. /**
  123652. * Enables noise blur
  123653. */
  123654. enableNoiseBlur(): void;
  123655. /**
  123656. * Disables noise blur
  123657. */
  123658. disableNoiseBlur(): void;
  123659. /**
  123660. * Sets the HighlightsGain amount
  123661. * @param amount amount of HighlightsGain
  123662. */
  123663. setHighlightsGain(amount: number): void;
  123664. /**
  123665. * Sets the HighlightsThreshold amount
  123666. * @param amount amount of HighlightsThreshold
  123667. */
  123668. setHighlightsThreshold(amount: number): void;
  123669. /**
  123670. * Disables highlights
  123671. */
  123672. disableHighlights(): void;
  123673. /**
  123674. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  123675. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  123676. */
  123677. dispose(disableDepthRender?: boolean): void;
  123678. private _createChromaticAberrationPostProcess;
  123679. private _createHighlightsPostProcess;
  123680. private _createDepthOfFieldPostProcess;
  123681. private _createGrainTexture;
  123682. }
  123683. }
  123684. declare module BABYLON {
  123685. /** @hidden */
  123686. export var ssao2PixelShader: {
  123687. name: string;
  123688. shader: string;
  123689. };
  123690. }
  123691. declare module BABYLON {
  123692. /** @hidden */
  123693. export var ssaoCombinePixelShader: {
  123694. name: string;
  123695. shader: string;
  123696. };
  123697. }
  123698. declare module BABYLON {
  123699. /**
  123700. * Render pipeline to produce ssao effect
  123701. */
  123702. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  123703. /**
  123704. * @ignore
  123705. * The PassPostProcess id in the pipeline that contains the original scene color
  123706. */
  123707. SSAOOriginalSceneColorEffect: string;
  123708. /**
  123709. * @ignore
  123710. * The SSAO PostProcess id in the pipeline
  123711. */
  123712. SSAORenderEffect: string;
  123713. /**
  123714. * @ignore
  123715. * The horizontal blur PostProcess id in the pipeline
  123716. */
  123717. SSAOBlurHRenderEffect: string;
  123718. /**
  123719. * @ignore
  123720. * The vertical blur PostProcess id in the pipeline
  123721. */
  123722. SSAOBlurVRenderEffect: string;
  123723. /**
  123724. * @ignore
  123725. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123726. */
  123727. SSAOCombineRenderEffect: string;
  123728. /**
  123729. * The output strength of the SSAO post-process. Default value is 1.0.
  123730. */
  123731. totalStrength: number;
  123732. /**
  123733. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  123734. */
  123735. maxZ: number;
  123736. /**
  123737. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  123738. */
  123739. minZAspect: number;
  123740. private _samples;
  123741. /**
  123742. * Number of samples used for the SSAO calculations. Default value is 8
  123743. */
  123744. samples: number;
  123745. private _textureSamples;
  123746. /**
  123747. * Number of samples to use for antialiasing
  123748. */
  123749. textureSamples: number;
  123750. /**
  123751. * Ratio object used for SSAO ratio and blur ratio
  123752. */
  123753. private _ratio;
  123754. /**
  123755. * Dynamically generated sphere sampler.
  123756. */
  123757. private _sampleSphere;
  123758. /**
  123759. * Blur filter offsets
  123760. */
  123761. private _samplerOffsets;
  123762. private _expensiveBlur;
  123763. /**
  123764. * If bilateral blur should be used
  123765. */
  123766. expensiveBlur: boolean;
  123767. /**
  123768. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  123769. */
  123770. radius: number;
  123771. /**
  123772. * The base color of the SSAO post-process
  123773. * The final result is "base + ssao" between [0, 1]
  123774. */
  123775. base: number;
  123776. /**
  123777. * Support test.
  123778. */
  123779. static readonly IsSupported: boolean;
  123780. private _scene;
  123781. private _depthTexture;
  123782. private _normalTexture;
  123783. private _randomTexture;
  123784. private _originalColorPostProcess;
  123785. private _ssaoPostProcess;
  123786. private _blurHPostProcess;
  123787. private _blurVPostProcess;
  123788. private _ssaoCombinePostProcess;
  123789. private _firstUpdate;
  123790. /**
  123791. * Gets active scene
  123792. */
  123793. readonly scene: Scene;
  123794. /**
  123795. * @constructor
  123796. * @param name The rendering pipeline name
  123797. * @param scene The scene linked to this pipeline
  123798. * @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 }
  123799. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123800. */
  123801. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123802. /**
  123803. * Get the class name
  123804. * @returns "SSAO2RenderingPipeline"
  123805. */
  123806. getClassName(): string;
  123807. /**
  123808. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123809. */
  123810. dispose(disableGeometryBufferRenderer?: boolean): void;
  123811. private _createBlurPostProcess;
  123812. /** @hidden */
  123813. _rebuild(): void;
  123814. private _bits;
  123815. private _radicalInverse_VdC;
  123816. private _hammersley;
  123817. private _hemisphereSample_uniform;
  123818. private _generateHemisphere;
  123819. private _createSSAOPostProcess;
  123820. private _createSSAOCombinePostProcess;
  123821. private _createRandomTexture;
  123822. /**
  123823. * Serialize the rendering pipeline (Used when exporting)
  123824. * @returns the serialized object
  123825. */
  123826. serialize(): any;
  123827. /**
  123828. * Parse the serialized pipeline
  123829. * @param source Source pipeline.
  123830. * @param scene The scene to load the pipeline to.
  123831. * @param rootUrl The URL of the serialized pipeline.
  123832. * @returns An instantiated pipeline from the serialized object.
  123833. */
  123834. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  123835. }
  123836. }
  123837. declare module BABYLON {
  123838. /** @hidden */
  123839. export var ssaoPixelShader: {
  123840. name: string;
  123841. shader: string;
  123842. };
  123843. }
  123844. declare module BABYLON {
  123845. /**
  123846. * Render pipeline to produce ssao effect
  123847. */
  123848. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  123849. /**
  123850. * @ignore
  123851. * The PassPostProcess id in the pipeline that contains the original scene color
  123852. */
  123853. SSAOOriginalSceneColorEffect: string;
  123854. /**
  123855. * @ignore
  123856. * The SSAO PostProcess id in the pipeline
  123857. */
  123858. SSAORenderEffect: string;
  123859. /**
  123860. * @ignore
  123861. * The horizontal blur PostProcess id in the pipeline
  123862. */
  123863. SSAOBlurHRenderEffect: string;
  123864. /**
  123865. * @ignore
  123866. * The vertical blur PostProcess id in the pipeline
  123867. */
  123868. SSAOBlurVRenderEffect: string;
  123869. /**
  123870. * @ignore
  123871. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123872. */
  123873. SSAOCombineRenderEffect: string;
  123874. /**
  123875. * The output strength of the SSAO post-process. Default value is 1.0.
  123876. */
  123877. totalStrength: number;
  123878. /**
  123879. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  123880. */
  123881. radius: number;
  123882. /**
  123883. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  123884. * Must not be equal to fallOff and superior to fallOff.
  123885. * Default value is 0.0075
  123886. */
  123887. area: number;
  123888. /**
  123889. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  123890. * Must not be equal to area and inferior to area.
  123891. * Default value is 0.000001
  123892. */
  123893. fallOff: number;
  123894. /**
  123895. * The base color of the SSAO post-process
  123896. * The final result is "base + ssao" between [0, 1]
  123897. */
  123898. base: number;
  123899. private _scene;
  123900. private _depthTexture;
  123901. private _randomTexture;
  123902. private _originalColorPostProcess;
  123903. private _ssaoPostProcess;
  123904. private _blurHPostProcess;
  123905. private _blurVPostProcess;
  123906. private _ssaoCombinePostProcess;
  123907. private _firstUpdate;
  123908. /**
  123909. * Gets active scene
  123910. */
  123911. readonly scene: Scene;
  123912. /**
  123913. * @constructor
  123914. * @param name - The rendering pipeline name
  123915. * @param scene - The scene linked to this pipeline
  123916. * @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 }
  123917. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  123918. */
  123919. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123920. /**
  123921. * Get the class name
  123922. * @returns "SSAORenderingPipeline"
  123923. */
  123924. getClassName(): string;
  123925. /**
  123926. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123927. */
  123928. dispose(disableDepthRender?: boolean): void;
  123929. private _createBlurPostProcess;
  123930. /** @hidden */
  123931. _rebuild(): void;
  123932. private _createSSAOPostProcess;
  123933. private _createSSAOCombinePostProcess;
  123934. private _createRandomTexture;
  123935. }
  123936. }
  123937. declare module BABYLON {
  123938. /** @hidden */
  123939. export var standardPixelShader: {
  123940. name: string;
  123941. shader: string;
  123942. };
  123943. }
  123944. declare module BABYLON {
  123945. /**
  123946. * Standard rendering pipeline
  123947. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123948. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  123949. */
  123950. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123951. /**
  123952. * Public members
  123953. */
  123954. /**
  123955. * Post-process which contains the original scene color before the pipeline applies all the effects
  123956. */
  123957. originalPostProcess: Nullable<PostProcess>;
  123958. /**
  123959. * Post-process used to down scale an image x4
  123960. */
  123961. downSampleX4PostProcess: Nullable<PostProcess>;
  123962. /**
  123963. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  123964. */
  123965. brightPassPostProcess: Nullable<PostProcess>;
  123966. /**
  123967. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  123968. */
  123969. blurHPostProcesses: PostProcess[];
  123970. /**
  123971. * Post-process array storing all the vertical blur post-processes used by the pipeline
  123972. */
  123973. blurVPostProcesses: PostProcess[];
  123974. /**
  123975. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  123976. */
  123977. textureAdderPostProcess: Nullable<PostProcess>;
  123978. /**
  123979. * Post-process used to create volumetric lighting effect
  123980. */
  123981. volumetricLightPostProcess: Nullable<PostProcess>;
  123982. /**
  123983. * Post-process used to smooth the previous volumetric light post-process on the X axis
  123984. */
  123985. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  123986. /**
  123987. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  123988. */
  123989. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  123990. /**
  123991. * Post-process used to merge the volumetric light effect and the real scene color
  123992. */
  123993. volumetricLightMergePostProces: Nullable<PostProcess>;
  123994. /**
  123995. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  123996. */
  123997. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  123998. /**
  123999. * Base post-process used to calculate the average luminance of the final image for HDR
  124000. */
  124001. luminancePostProcess: Nullable<PostProcess>;
  124002. /**
  124003. * Post-processes used to create down sample post-processes in order to get
  124004. * the average luminance of the final image for HDR
  124005. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  124006. */
  124007. luminanceDownSamplePostProcesses: PostProcess[];
  124008. /**
  124009. * Post-process used to create a HDR effect (light adaptation)
  124010. */
  124011. hdrPostProcess: Nullable<PostProcess>;
  124012. /**
  124013. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  124014. */
  124015. textureAdderFinalPostProcess: Nullable<PostProcess>;
  124016. /**
  124017. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  124018. */
  124019. lensFlareFinalPostProcess: Nullable<PostProcess>;
  124020. /**
  124021. * Post-process used to merge the final HDR post-process and the real scene color
  124022. */
  124023. hdrFinalPostProcess: Nullable<PostProcess>;
  124024. /**
  124025. * Post-process used to create a lens flare effect
  124026. */
  124027. lensFlarePostProcess: Nullable<PostProcess>;
  124028. /**
  124029. * Post-process that merges the result of the lens flare post-process and the real scene color
  124030. */
  124031. lensFlareComposePostProcess: Nullable<PostProcess>;
  124032. /**
  124033. * Post-process used to create a motion blur effect
  124034. */
  124035. motionBlurPostProcess: Nullable<PostProcess>;
  124036. /**
  124037. * Post-process used to create a depth of field effect
  124038. */
  124039. depthOfFieldPostProcess: Nullable<PostProcess>;
  124040. /**
  124041. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124042. */
  124043. fxaaPostProcess: Nullable<FxaaPostProcess>;
  124044. /**
  124045. * Represents the brightness threshold in order to configure the illuminated surfaces
  124046. */
  124047. brightThreshold: number;
  124048. /**
  124049. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  124050. */
  124051. blurWidth: number;
  124052. /**
  124053. * Sets if the blur for highlighted surfaces must be only horizontal
  124054. */
  124055. horizontalBlur: boolean;
  124056. /**
  124057. * Gets the overall exposure used by the pipeline
  124058. */
  124059. /**
  124060. * Sets the overall exposure used by the pipeline
  124061. */
  124062. exposure: number;
  124063. /**
  124064. * Texture used typically to simulate "dirty" on camera lens
  124065. */
  124066. lensTexture: Nullable<Texture>;
  124067. /**
  124068. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  124069. */
  124070. volumetricLightCoefficient: number;
  124071. /**
  124072. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  124073. */
  124074. volumetricLightPower: number;
  124075. /**
  124076. * Used the set the blur intensity to smooth the volumetric lights
  124077. */
  124078. volumetricLightBlurScale: number;
  124079. /**
  124080. * Light (spot or directional) used to generate the volumetric lights rays
  124081. * The source light must have a shadow generate so the pipeline can get its
  124082. * depth map
  124083. */
  124084. sourceLight: Nullable<SpotLight | DirectionalLight>;
  124085. /**
  124086. * For eye adaptation, represents the minimum luminance the eye can see
  124087. */
  124088. hdrMinimumLuminance: number;
  124089. /**
  124090. * For eye adaptation, represents the decrease luminance speed
  124091. */
  124092. hdrDecreaseRate: number;
  124093. /**
  124094. * For eye adaptation, represents the increase luminance speed
  124095. */
  124096. hdrIncreaseRate: number;
  124097. /**
  124098. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124099. */
  124100. /**
  124101. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124102. */
  124103. hdrAutoExposure: boolean;
  124104. /**
  124105. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  124106. */
  124107. lensColorTexture: Nullable<Texture>;
  124108. /**
  124109. * The overall strengh for the lens flare effect
  124110. */
  124111. lensFlareStrength: number;
  124112. /**
  124113. * Dispersion coefficient for lens flare ghosts
  124114. */
  124115. lensFlareGhostDispersal: number;
  124116. /**
  124117. * Main lens flare halo width
  124118. */
  124119. lensFlareHaloWidth: number;
  124120. /**
  124121. * Based on the lens distortion effect, defines how much the lens flare result
  124122. * is distorted
  124123. */
  124124. lensFlareDistortionStrength: number;
  124125. /**
  124126. * Lens star texture must be used to simulate rays on the flares and is available
  124127. * in the documentation
  124128. */
  124129. lensStarTexture: Nullable<Texture>;
  124130. /**
  124131. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  124132. * flare effect by taking account of the dirt texture
  124133. */
  124134. lensFlareDirtTexture: Nullable<Texture>;
  124135. /**
  124136. * Represents the focal length for the depth of field effect
  124137. */
  124138. depthOfFieldDistance: number;
  124139. /**
  124140. * Represents the blur intensity for the blurred part of the depth of field effect
  124141. */
  124142. depthOfFieldBlurWidth: number;
  124143. /**
  124144. * Gets how much the image is blurred by the movement while using the motion blur post-process
  124145. */
  124146. /**
  124147. * Sets how much the image is blurred by the movement while using the motion blur post-process
  124148. */
  124149. motionStrength: number;
  124150. /**
  124151. * Gets wether or not the motion blur post-process is object based or screen based.
  124152. */
  124153. /**
  124154. * Sets wether or not the motion blur post-process should be object based or screen based
  124155. */
  124156. objectBasedMotionBlur: boolean;
  124157. /**
  124158. * List of animations for the pipeline (IAnimatable implementation)
  124159. */
  124160. animations: Animation[];
  124161. /**
  124162. * Private members
  124163. */
  124164. private _scene;
  124165. private _currentDepthOfFieldSource;
  124166. private _basePostProcess;
  124167. private _fixedExposure;
  124168. private _currentExposure;
  124169. private _hdrAutoExposure;
  124170. private _hdrCurrentLuminance;
  124171. private _motionStrength;
  124172. private _isObjectBasedMotionBlur;
  124173. private _floatTextureType;
  124174. private _camerasToBeAttached;
  124175. private _ratio;
  124176. private _bloomEnabled;
  124177. private _depthOfFieldEnabled;
  124178. private _vlsEnabled;
  124179. private _lensFlareEnabled;
  124180. private _hdrEnabled;
  124181. private _motionBlurEnabled;
  124182. private _fxaaEnabled;
  124183. private _motionBlurSamples;
  124184. private _volumetricLightStepsCount;
  124185. private _samples;
  124186. /**
  124187. * @ignore
  124188. * Specifies if the bloom pipeline is enabled
  124189. */
  124190. BloomEnabled: boolean;
  124191. /**
  124192. * @ignore
  124193. * Specifies if the depth of field pipeline is enabed
  124194. */
  124195. DepthOfFieldEnabled: boolean;
  124196. /**
  124197. * @ignore
  124198. * Specifies if the lens flare pipeline is enabed
  124199. */
  124200. LensFlareEnabled: boolean;
  124201. /**
  124202. * @ignore
  124203. * Specifies if the HDR pipeline is enabled
  124204. */
  124205. HDREnabled: boolean;
  124206. /**
  124207. * @ignore
  124208. * Specifies if the volumetric lights scattering effect is enabled
  124209. */
  124210. VLSEnabled: boolean;
  124211. /**
  124212. * @ignore
  124213. * Specifies if the motion blur effect is enabled
  124214. */
  124215. MotionBlurEnabled: boolean;
  124216. /**
  124217. * Specifies if anti-aliasing is enabled
  124218. */
  124219. fxaaEnabled: boolean;
  124220. /**
  124221. * Specifies the number of steps used to calculate the volumetric lights
  124222. * Typically in interval [50, 200]
  124223. */
  124224. volumetricLightStepsCount: number;
  124225. /**
  124226. * Specifies the number of samples used for the motion blur effect
  124227. * Typically in interval [16, 64]
  124228. */
  124229. motionBlurSamples: number;
  124230. /**
  124231. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124232. */
  124233. samples: number;
  124234. /**
  124235. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  124236. * @constructor
  124237. * @param name The rendering pipeline name
  124238. * @param scene The scene linked to this pipeline
  124239. * @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)
  124240. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  124241. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124242. */
  124243. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  124244. private _buildPipeline;
  124245. private _createDownSampleX4PostProcess;
  124246. private _createBrightPassPostProcess;
  124247. private _createBlurPostProcesses;
  124248. private _createTextureAdderPostProcess;
  124249. private _createVolumetricLightPostProcess;
  124250. private _createLuminancePostProcesses;
  124251. private _createHdrPostProcess;
  124252. private _createLensFlarePostProcess;
  124253. private _createDepthOfFieldPostProcess;
  124254. private _createMotionBlurPostProcess;
  124255. private _getDepthTexture;
  124256. private _disposePostProcesses;
  124257. /**
  124258. * Dispose of the pipeline and stop all post processes
  124259. */
  124260. dispose(): void;
  124261. /**
  124262. * Serialize the rendering pipeline (Used when exporting)
  124263. * @returns the serialized object
  124264. */
  124265. serialize(): any;
  124266. /**
  124267. * Parse the serialized pipeline
  124268. * @param source Source pipeline.
  124269. * @param scene The scene to load the pipeline to.
  124270. * @param rootUrl The URL of the serialized pipeline.
  124271. * @returns An instantiated pipeline from the serialized object.
  124272. */
  124273. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  124274. /**
  124275. * Luminance steps
  124276. */
  124277. static LuminanceSteps: number;
  124278. }
  124279. }
  124280. declare module BABYLON {
  124281. /** @hidden */
  124282. export var tonemapPixelShader: {
  124283. name: string;
  124284. shader: string;
  124285. };
  124286. }
  124287. declare module BABYLON {
  124288. /** Defines operator used for tonemapping */
  124289. export enum TonemappingOperator {
  124290. /** Hable */
  124291. Hable = 0,
  124292. /** Reinhard */
  124293. Reinhard = 1,
  124294. /** HejiDawson */
  124295. HejiDawson = 2,
  124296. /** Photographic */
  124297. Photographic = 3
  124298. }
  124299. /**
  124300. * Defines a post process to apply tone mapping
  124301. */
  124302. export class TonemapPostProcess extends PostProcess {
  124303. private _operator;
  124304. /** Defines the required exposure adjustement */
  124305. exposureAdjustment: number;
  124306. /**
  124307. * Creates a new TonemapPostProcess
  124308. * @param name defines the name of the postprocess
  124309. * @param _operator defines the operator to use
  124310. * @param exposureAdjustment defines the required exposure adjustement
  124311. * @param camera defines the camera to use (can be null)
  124312. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  124313. * @param engine defines the hosting engine (can be ignore if camera is set)
  124314. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  124315. */
  124316. constructor(name: string, _operator: TonemappingOperator,
  124317. /** Defines the required exposure adjustement */
  124318. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  124319. }
  124320. }
  124321. declare module BABYLON {
  124322. /** @hidden */
  124323. export var depthVertexShader: {
  124324. name: string;
  124325. shader: string;
  124326. };
  124327. }
  124328. declare module BABYLON {
  124329. /** @hidden */
  124330. export var volumetricLightScatteringPixelShader: {
  124331. name: string;
  124332. shader: string;
  124333. };
  124334. }
  124335. declare module BABYLON {
  124336. /** @hidden */
  124337. export var volumetricLightScatteringPassVertexShader: {
  124338. name: string;
  124339. shader: string;
  124340. };
  124341. }
  124342. declare module BABYLON {
  124343. /** @hidden */
  124344. export var volumetricLightScatteringPassPixelShader: {
  124345. name: string;
  124346. shader: string;
  124347. };
  124348. }
  124349. declare module BABYLON {
  124350. /**
  124351. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  124352. */
  124353. export class VolumetricLightScatteringPostProcess extends PostProcess {
  124354. private _volumetricLightScatteringPass;
  124355. private _volumetricLightScatteringRTT;
  124356. private _viewPort;
  124357. private _screenCoordinates;
  124358. private _cachedDefines;
  124359. /**
  124360. * If not undefined, the mesh position is computed from the attached node position
  124361. */
  124362. attachedNode: {
  124363. position: Vector3;
  124364. };
  124365. /**
  124366. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  124367. */
  124368. customMeshPosition: Vector3;
  124369. /**
  124370. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  124371. */
  124372. useCustomMeshPosition: boolean;
  124373. /**
  124374. * If the post-process should inverse the light scattering direction
  124375. */
  124376. invert: boolean;
  124377. /**
  124378. * The internal mesh used by the post-process
  124379. */
  124380. mesh: Mesh;
  124381. /**
  124382. * @hidden
  124383. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  124384. */
  124385. useDiffuseColor: boolean;
  124386. /**
  124387. * Array containing the excluded meshes not rendered in the internal pass
  124388. */
  124389. excludedMeshes: AbstractMesh[];
  124390. /**
  124391. * Controls the overall intensity of the post-process
  124392. */
  124393. exposure: number;
  124394. /**
  124395. * Dissipates each sample's contribution in range [0, 1]
  124396. */
  124397. decay: number;
  124398. /**
  124399. * Controls the overall intensity of each sample
  124400. */
  124401. weight: number;
  124402. /**
  124403. * Controls the density of each sample
  124404. */
  124405. density: number;
  124406. /**
  124407. * @constructor
  124408. * @param name The post-process name
  124409. * @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)
  124410. * @param camera The camera that the post-process will be attached to
  124411. * @param mesh The mesh used to create the light scattering
  124412. * @param samples The post-process quality, default 100
  124413. * @param samplingModeThe post-process filtering mode
  124414. * @param engine The babylon engine
  124415. * @param reusable If the post-process is reusable
  124416. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  124417. */
  124418. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  124419. /**
  124420. * Returns the string "VolumetricLightScatteringPostProcess"
  124421. * @returns "VolumetricLightScatteringPostProcess"
  124422. */
  124423. getClassName(): string;
  124424. private _isReady;
  124425. /**
  124426. * Sets the new light position for light scattering effect
  124427. * @param position The new custom light position
  124428. */
  124429. setCustomMeshPosition(position: Vector3): void;
  124430. /**
  124431. * Returns the light position for light scattering effect
  124432. * @return Vector3 The custom light position
  124433. */
  124434. getCustomMeshPosition(): Vector3;
  124435. /**
  124436. * Disposes the internal assets and detaches the post-process from the camera
  124437. */
  124438. dispose(camera: Camera): void;
  124439. /**
  124440. * Returns the render target texture used by the post-process
  124441. * @return the render target texture used by the post-process
  124442. */
  124443. getPass(): RenderTargetTexture;
  124444. private _meshExcluded;
  124445. private _createPass;
  124446. private _updateMeshScreenCoordinates;
  124447. /**
  124448. * Creates a default mesh for the Volumeric Light Scattering post-process
  124449. * @param name The mesh name
  124450. * @param scene The scene where to create the mesh
  124451. * @return the default mesh
  124452. */
  124453. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  124454. }
  124455. }
  124456. declare module BABYLON {
  124457. interface Scene {
  124458. /** @hidden (Backing field) */
  124459. _boundingBoxRenderer: BoundingBoxRenderer;
  124460. /** @hidden (Backing field) */
  124461. _forceShowBoundingBoxes: boolean;
  124462. /**
  124463. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  124464. */
  124465. forceShowBoundingBoxes: boolean;
  124466. /**
  124467. * Gets the bounding box renderer associated with the scene
  124468. * @returns a BoundingBoxRenderer
  124469. */
  124470. getBoundingBoxRenderer(): BoundingBoxRenderer;
  124471. }
  124472. interface AbstractMesh {
  124473. /** @hidden (Backing field) */
  124474. _showBoundingBox: boolean;
  124475. /**
  124476. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  124477. */
  124478. showBoundingBox: boolean;
  124479. }
  124480. /**
  124481. * Component responsible of rendering the bounding box of the meshes in a scene.
  124482. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124483. */
  124484. export class BoundingBoxRenderer implements ISceneComponent {
  124485. /**
  124486. * The component name helpfull to identify the component in the list of scene components.
  124487. */
  124488. readonly name: string;
  124489. /**
  124490. * The scene the component belongs to.
  124491. */
  124492. scene: Scene;
  124493. /**
  124494. * Color of the bounding box lines placed in front of an object
  124495. */
  124496. frontColor: Color3;
  124497. /**
  124498. * Color of the bounding box lines placed behind an object
  124499. */
  124500. backColor: Color3;
  124501. /**
  124502. * Defines if the renderer should show the back lines or not
  124503. */
  124504. showBackLines: boolean;
  124505. /**
  124506. * @hidden
  124507. */
  124508. renderList: SmartArray<BoundingBox>;
  124509. private _colorShader;
  124510. private _vertexBuffers;
  124511. private _indexBuffer;
  124512. private _fillIndexBuffer;
  124513. private _fillIndexData;
  124514. /**
  124515. * Instantiates a new bounding box renderer in a scene.
  124516. * @param scene the scene the renderer renders in
  124517. */
  124518. constructor(scene: Scene);
  124519. /**
  124520. * Registers the component in a given scene
  124521. */
  124522. register(): void;
  124523. private _evaluateSubMesh;
  124524. private _activeMesh;
  124525. private _prepareRessources;
  124526. private _createIndexBuffer;
  124527. /**
  124528. * Rebuilds the elements related to this component in case of
  124529. * context lost for instance.
  124530. */
  124531. rebuild(): void;
  124532. /**
  124533. * @hidden
  124534. */
  124535. reset(): void;
  124536. /**
  124537. * Render the bounding boxes of a specific rendering group
  124538. * @param renderingGroupId defines the rendering group to render
  124539. */
  124540. render(renderingGroupId: number): void;
  124541. /**
  124542. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124543. * @param mesh Define the mesh to render the occlusion bounding box for
  124544. */
  124545. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  124546. /**
  124547. * Dispose and release the resources attached to this renderer.
  124548. */
  124549. dispose(): void;
  124550. }
  124551. }
  124552. declare module BABYLON {
  124553. /** @hidden */
  124554. export var depthPixelShader: {
  124555. name: string;
  124556. shader: string;
  124557. };
  124558. }
  124559. declare module BABYLON {
  124560. /**
  124561. * This represents a depth renderer in Babylon.
  124562. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  124563. */
  124564. export class DepthRenderer {
  124565. private _scene;
  124566. private _depthMap;
  124567. private _effect;
  124568. private readonly _storeNonLinearDepth;
  124569. private readonly _clearColor;
  124570. /** Get if the depth renderer is using packed depth or not */
  124571. readonly isPacked: boolean;
  124572. private _cachedDefines;
  124573. private _camera;
  124574. /**
  124575. * Specifiess that the depth renderer will only be used within
  124576. * the camera it is created for.
  124577. * This can help forcing its rendering during the camera processing.
  124578. */
  124579. useOnlyInActiveCamera: boolean;
  124580. /** @hidden */
  124581. static _SceneComponentInitialization: (scene: Scene) => void;
  124582. /**
  124583. * Instantiates a depth renderer
  124584. * @param scene The scene the renderer belongs to
  124585. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  124586. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  124587. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124588. */
  124589. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  124590. /**
  124591. * Creates the depth rendering effect and checks if the effect is ready.
  124592. * @param subMesh The submesh to be used to render the depth map of
  124593. * @param useInstances If multiple world instances should be used
  124594. * @returns if the depth renderer is ready to render the depth map
  124595. */
  124596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124597. /**
  124598. * Gets the texture which the depth map will be written to.
  124599. * @returns The depth map texture
  124600. */
  124601. getDepthMap(): RenderTargetTexture;
  124602. /**
  124603. * Disposes of the depth renderer.
  124604. */
  124605. dispose(): void;
  124606. }
  124607. }
  124608. declare module BABYLON {
  124609. interface Scene {
  124610. /** @hidden (Backing field) */
  124611. _depthRenderer: {
  124612. [id: string]: DepthRenderer;
  124613. };
  124614. /**
  124615. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  124616. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  124617. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124618. * @returns the created depth renderer
  124619. */
  124620. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  124621. /**
  124622. * Disables a depth renderer for a given camera
  124623. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  124624. */
  124625. disableDepthRenderer(camera?: Nullable<Camera>): void;
  124626. }
  124627. /**
  124628. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  124629. * in several rendering techniques.
  124630. */
  124631. export class DepthRendererSceneComponent implements ISceneComponent {
  124632. /**
  124633. * The component name helpfull to identify the component in the list of scene components.
  124634. */
  124635. readonly name: string;
  124636. /**
  124637. * The scene the component belongs to.
  124638. */
  124639. scene: Scene;
  124640. /**
  124641. * Creates a new instance of the component for the given scene
  124642. * @param scene Defines the scene to register the component in
  124643. */
  124644. constructor(scene: Scene);
  124645. /**
  124646. * Registers the component in a given scene
  124647. */
  124648. register(): void;
  124649. /**
  124650. * Rebuilds the elements related to this component in case of
  124651. * context lost for instance.
  124652. */
  124653. rebuild(): void;
  124654. /**
  124655. * Disposes the component and the associated ressources
  124656. */
  124657. dispose(): void;
  124658. private _gatherRenderTargets;
  124659. private _gatherActiveCameraRenderTargets;
  124660. }
  124661. }
  124662. declare module BABYLON {
  124663. /** @hidden */
  124664. export var outlinePixelShader: {
  124665. name: string;
  124666. shader: string;
  124667. };
  124668. }
  124669. declare module BABYLON {
  124670. /** @hidden */
  124671. export var outlineVertexShader: {
  124672. name: string;
  124673. shader: string;
  124674. };
  124675. }
  124676. declare module BABYLON {
  124677. interface Scene {
  124678. /** @hidden */
  124679. _outlineRenderer: OutlineRenderer;
  124680. /**
  124681. * Gets the outline renderer associated with the scene
  124682. * @returns a OutlineRenderer
  124683. */
  124684. getOutlineRenderer(): OutlineRenderer;
  124685. }
  124686. interface AbstractMesh {
  124687. /** @hidden (Backing field) */
  124688. _renderOutline: boolean;
  124689. /**
  124690. * Gets or sets a boolean indicating if the outline must be rendered as well
  124691. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  124692. */
  124693. renderOutline: boolean;
  124694. /** @hidden (Backing field) */
  124695. _renderOverlay: boolean;
  124696. /**
  124697. * Gets or sets a boolean indicating if the overlay must be rendered as well
  124698. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  124699. */
  124700. renderOverlay: boolean;
  124701. }
  124702. /**
  124703. * This class is responsible to draw bothe outline/overlay of meshes.
  124704. * It should not be used directly but through the available method on mesh.
  124705. */
  124706. export class OutlineRenderer implements ISceneComponent {
  124707. /**
  124708. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  124709. */
  124710. private static _StencilReference;
  124711. /**
  124712. * The name of the component. Each component must have a unique name.
  124713. */
  124714. name: string;
  124715. /**
  124716. * The scene the component belongs to.
  124717. */
  124718. scene: Scene;
  124719. /**
  124720. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  124721. */
  124722. zOffset: number;
  124723. private _engine;
  124724. private _effect;
  124725. private _cachedDefines;
  124726. private _savedDepthWrite;
  124727. /**
  124728. * Instantiates a new outline renderer. (There could be only one per scene).
  124729. * @param scene Defines the scene it belongs to
  124730. */
  124731. constructor(scene: Scene);
  124732. /**
  124733. * Register the component to one instance of a scene.
  124734. */
  124735. register(): void;
  124736. /**
  124737. * Rebuilds the elements related to this component in case of
  124738. * context lost for instance.
  124739. */
  124740. rebuild(): void;
  124741. /**
  124742. * Disposes the component and the associated ressources.
  124743. */
  124744. dispose(): void;
  124745. /**
  124746. * Renders the outline in the canvas.
  124747. * @param subMesh Defines the sumesh to render
  124748. * @param batch Defines the batch of meshes in case of instances
  124749. * @param useOverlay Defines if the rendering is for the overlay or the outline
  124750. */
  124751. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  124752. /**
  124753. * Returns whether or not the outline renderer is ready for a given submesh.
  124754. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  124755. * @param subMesh Defines the submesh to check readyness for
  124756. * @param useInstances Defines wheter wee are trying to render instances or not
  124757. * @returns true if ready otherwise false
  124758. */
  124759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124760. private _beforeRenderingMesh;
  124761. private _afterRenderingMesh;
  124762. }
  124763. }
  124764. declare module BABYLON {
  124765. /**
  124766. * Class used to manage multiple sprites of different sizes on the same spritesheet
  124767. * @see http://doc.babylonjs.com/babylon101/sprites
  124768. */
  124769. export class SpritePackedManager extends SpriteManager {
  124770. /** defines the packed manager's name */
  124771. name: string;
  124772. /**
  124773. * Creates a new sprite manager from a packed sprite sheet
  124774. * @param name defines the manager's name
  124775. * @param imgUrl defines the sprite sheet url
  124776. * @param capacity defines the maximum allowed number of sprites
  124777. * @param scene defines the hosting scene
  124778. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  124779. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124780. * @param samplingMode defines the smapling mode to use with spritesheet
  124781. * @param fromPacked set to true; do not alter
  124782. */
  124783. constructor(
  124784. /** defines the packed manager's name */
  124785. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  124786. }
  124787. }
  124788. declare module BABYLON {
  124789. /**
  124790. * Defines the list of states available for a task inside a AssetsManager
  124791. */
  124792. export enum AssetTaskState {
  124793. /**
  124794. * Initialization
  124795. */
  124796. INIT = 0,
  124797. /**
  124798. * Running
  124799. */
  124800. RUNNING = 1,
  124801. /**
  124802. * Done
  124803. */
  124804. DONE = 2,
  124805. /**
  124806. * Error
  124807. */
  124808. ERROR = 3
  124809. }
  124810. /**
  124811. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  124812. */
  124813. export abstract class AbstractAssetTask {
  124814. /**
  124815. * Task name
  124816. */ name: string;
  124817. /**
  124818. * Callback called when the task is successful
  124819. */
  124820. onSuccess: (task: any) => void;
  124821. /**
  124822. * Callback called when the task is not successful
  124823. */
  124824. onError: (task: any, message?: string, exception?: any) => void;
  124825. /**
  124826. * Creates a new AssetsManager
  124827. * @param name defines the name of the task
  124828. */
  124829. constructor(
  124830. /**
  124831. * Task name
  124832. */ name: string);
  124833. private _isCompleted;
  124834. private _taskState;
  124835. private _errorObject;
  124836. /**
  124837. * Get if the task is completed
  124838. */
  124839. readonly isCompleted: boolean;
  124840. /**
  124841. * Gets the current state of the task
  124842. */
  124843. readonly taskState: AssetTaskState;
  124844. /**
  124845. * Gets the current error object (if task is in error)
  124846. */
  124847. readonly errorObject: {
  124848. message?: string;
  124849. exception?: any;
  124850. };
  124851. /**
  124852. * Internal only
  124853. * @hidden
  124854. */
  124855. _setErrorObject(message?: string, exception?: any): void;
  124856. /**
  124857. * Execute the current task
  124858. * @param scene defines the scene where you want your assets to be loaded
  124859. * @param onSuccess is a callback called when the task is successfully executed
  124860. * @param onError is a callback called if an error occurs
  124861. */
  124862. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124863. /**
  124864. * Execute the current task
  124865. * @param scene defines the scene where you want your assets to be loaded
  124866. * @param onSuccess is a callback called when the task is successfully executed
  124867. * @param onError is a callback called if an error occurs
  124868. */
  124869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124870. /**
  124871. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  124872. * This can be used with failed tasks that have the reason for failure fixed.
  124873. */
  124874. reset(): void;
  124875. private onErrorCallback;
  124876. private onDoneCallback;
  124877. }
  124878. /**
  124879. * Define the interface used by progress events raised during assets loading
  124880. */
  124881. export interface IAssetsProgressEvent {
  124882. /**
  124883. * Defines the number of remaining tasks to process
  124884. */
  124885. remainingCount: number;
  124886. /**
  124887. * Defines the total number of tasks
  124888. */
  124889. totalCount: number;
  124890. /**
  124891. * Defines the task that was just processed
  124892. */
  124893. task: AbstractAssetTask;
  124894. }
  124895. /**
  124896. * Class used to share progress information about assets loading
  124897. */
  124898. export class AssetsProgressEvent implements IAssetsProgressEvent {
  124899. /**
  124900. * Defines the number of remaining tasks to process
  124901. */
  124902. remainingCount: number;
  124903. /**
  124904. * Defines the total number of tasks
  124905. */
  124906. totalCount: number;
  124907. /**
  124908. * Defines the task that was just processed
  124909. */
  124910. task: AbstractAssetTask;
  124911. /**
  124912. * Creates a AssetsProgressEvent
  124913. * @param remainingCount defines the number of remaining tasks to process
  124914. * @param totalCount defines the total number of tasks
  124915. * @param task defines the task that was just processed
  124916. */
  124917. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  124918. }
  124919. /**
  124920. * Define a task used by AssetsManager to load meshes
  124921. */
  124922. export class MeshAssetTask extends AbstractAssetTask {
  124923. /**
  124924. * Defines the name of the task
  124925. */
  124926. name: string;
  124927. /**
  124928. * Defines the list of mesh's names you want to load
  124929. */
  124930. meshesNames: any;
  124931. /**
  124932. * Defines the root url to use as a base to load your meshes and associated resources
  124933. */
  124934. rootUrl: string;
  124935. /**
  124936. * Defines the filename of the scene to load from
  124937. */
  124938. sceneFilename: string;
  124939. /**
  124940. * Gets the list of loaded meshes
  124941. */
  124942. loadedMeshes: Array<AbstractMesh>;
  124943. /**
  124944. * Gets the list of loaded particle systems
  124945. */
  124946. loadedParticleSystems: Array<IParticleSystem>;
  124947. /**
  124948. * Gets the list of loaded skeletons
  124949. */
  124950. loadedSkeletons: Array<Skeleton>;
  124951. /**
  124952. * Gets the list of loaded animation groups
  124953. */
  124954. loadedAnimationGroups: Array<AnimationGroup>;
  124955. /**
  124956. * Callback called when the task is successful
  124957. */
  124958. onSuccess: (task: MeshAssetTask) => void;
  124959. /**
  124960. * Callback called when the task is successful
  124961. */
  124962. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  124963. /**
  124964. * Creates a new MeshAssetTask
  124965. * @param name defines the name of the task
  124966. * @param meshesNames defines the list of mesh's names you want to load
  124967. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  124968. * @param sceneFilename defines the filename of the scene to load from
  124969. */
  124970. constructor(
  124971. /**
  124972. * Defines the name of the task
  124973. */
  124974. name: string,
  124975. /**
  124976. * Defines the list of mesh's names you want to load
  124977. */
  124978. meshesNames: any,
  124979. /**
  124980. * Defines the root url to use as a base to load your meshes and associated resources
  124981. */
  124982. rootUrl: string,
  124983. /**
  124984. * Defines the filename of the scene to load from
  124985. */
  124986. sceneFilename: string);
  124987. /**
  124988. * Execute the current task
  124989. * @param scene defines the scene where you want your assets to be loaded
  124990. * @param onSuccess is a callback called when the task is successfully executed
  124991. * @param onError is a callback called if an error occurs
  124992. */
  124993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124994. }
  124995. /**
  124996. * Define a task used by AssetsManager to load text content
  124997. */
  124998. export class TextFileAssetTask extends AbstractAssetTask {
  124999. /**
  125000. * Defines the name of the task
  125001. */
  125002. name: string;
  125003. /**
  125004. * Defines the location of the file to load
  125005. */
  125006. url: string;
  125007. /**
  125008. * Gets the loaded text string
  125009. */
  125010. text: string;
  125011. /**
  125012. * Callback called when the task is successful
  125013. */
  125014. onSuccess: (task: TextFileAssetTask) => void;
  125015. /**
  125016. * Callback called when the task is successful
  125017. */
  125018. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  125019. /**
  125020. * Creates a new TextFileAssetTask object
  125021. * @param name defines the name of the task
  125022. * @param url defines the location of the file to load
  125023. */
  125024. constructor(
  125025. /**
  125026. * Defines the name of the task
  125027. */
  125028. name: string,
  125029. /**
  125030. * Defines the location of the file to load
  125031. */
  125032. url: string);
  125033. /**
  125034. * Execute the current task
  125035. * @param scene defines the scene where you want your assets to be loaded
  125036. * @param onSuccess is a callback called when the task is successfully executed
  125037. * @param onError is a callback called if an error occurs
  125038. */
  125039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125040. }
  125041. /**
  125042. * Define a task used by AssetsManager to load binary data
  125043. */
  125044. export class BinaryFileAssetTask extends AbstractAssetTask {
  125045. /**
  125046. * Defines the name of the task
  125047. */
  125048. name: string;
  125049. /**
  125050. * Defines the location of the file to load
  125051. */
  125052. url: string;
  125053. /**
  125054. * Gets the lodaded data (as an array buffer)
  125055. */
  125056. data: ArrayBuffer;
  125057. /**
  125058. * Callback called when the task is successful
  125059. */
  125060. onSuccess: (task: BinaryFileAssetTask) => void;
  125061. /**
  125062. * Callback called when the task is successful
  125063. */
  125064. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  125065. /**
  125066. * Creates a new BinaryFileAssetTask object
  125067. * @param name defines the name of the new task
  125068. * @param url defines the location of the file to load
  125069. */
  125070. constructor(
  125071. /**
  125072. * Defines the name of the task
  125073. */
  125074. name: string,
  125075. /**
  125076. * Defines the location of the file to load
  125077. */
  125078. url: string);
  125079. /**
  125080. * Execute the current task
  125081. * @param scene defines the scene where you want your assets to be loaded
  125082. * @param onSuccess is a callback called when the task is successfully executed
  125083. * @param onError is a callback called if an error occurs
  125084. */
  125085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125086. }
  125087. /**
  125088. * Define a task used by AssetsManager to load images
  125089. */
  125090. export class ImageAssetTask extends AbstractAssetTask {
  125091. /**
  125092. * Defines the name of the task
  125093. */
  125094. name: string;
  125095. /**
  125096. * Defines the location of the image to load
  125097. */
  125098. url: string;
  125099. /**
  125100. * Gets the loaded images
  125101. */
  125102. image: HTMLImageElement;
  125103. /**
  125104. * Callback called when the task is successful
  125105. */
  125106. onSuccess: (task: ImageAssetTask) => void;
  125107. /**
  125108. * Callback called when the task is successful
  125109. */
  125110. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  125111. /**
  125112. * Creates a new ImageAssetTask
  125113. * @param name defines the name of the task
  125114. * @param url defines the location of the image to load
  125115. */
  125116. constructor(
  125117. /**
  125118. * Defines the name of the task
  125119. */
  125120. name: string,
  125121. /**
  125122. * Defines the location of the image to load
  125123. */
  125124. url: string);
  125125. /**
  125126. * Execute the current task
  125127. * @param scene defines the scene where you want your assets to be loaded
  125128. * @param onSuccess is a callback called when the task is successfully executed
  125129. * @param onError is a callback called if an error occurs
  125130. */
  125131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125132. }
  125133. /**
  125134. * Defines the interface used by texture loading tasks
  125135. */
  125136. export interface ITextureAssetTask<TEX extends BaseTexture> {
  125137. /**
  125138. * Gets the loaded texture
  125139. */
  125140. texture: TEX;
  125141. }
  125142. /**
  125143. * Define a task used by AssetsManager to load 2D textures
  125144. */
  125145. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  125146. /**
  125147. * Defines the name of the task
  125148. */
  125149. name: string;
  125150. /**
  125151. * Defines the location of the file to load
  125152. */
  125153. url: string;
  125154. /**
  125155. * Defines if mipmap should not be generated (default is false)
  125156. */
  125157. noMipmap?: boolean | undefined;
  125158. /**
  125159. * Defines if texture must be inverted on Y axis (default is false)
  125160. */
  125161. invertY?: boolean | undefined;
  125162. /**
  125163. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125164. */
  125165. samplingMode: number;
  125166. /**
  125167. * Gets the loaded texture
  125168. */
  125169. texture: Texture;
  125170. /**
  125171. * Callback called when the task is successful
  125172. */
  125173. onSuccess: (task: TextureAssetTask) => void;
  125174. /**
  125175. * Callback called when the task is successful
  125176. */
  125177. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  125178. /**
  125179. * Creates a new TextureAssetTask object
  125180. * @param name defines the name of the task
  125181. * @param url defines the location of the file to load
  125182. * @param noMipmap defines if mipmap should not be generated (default is false)
  125183. * @param invertY defines if texture must be inverted on Y axis (default is false)
  125184. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125185. */
  125186. constructor(
  125187. /**
  125188. * Defines the name of the task
  125189. */
  125190. name: string,
  125191. /**
  125192. * Defines the location of the file to load
  125193. */
  125194. url: string,
  125195. /**
  125196. * Defines if mipmap should not be generated (default is false)
  125197. */
  125198. noMipmap?: boolean | undefined,
  125199. /**
  125200. * Defines if texture must be inverted on Y axis (default is false)
  125201. */
  125202. invertY?: boolean | undefined,
  125203. /**
  125204. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125205. */
  125206. samplingMode?: number);
  125207. /**
  125208. * Execute the current task
  125209. * @param scene defines the scene where you want your assets to be loaded
  125210. * @param onSuccess is a callback called when the task is successfully executed
  125211. * @param onError is a callback called if an error occurs
  125212. */
  125213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125214. }
  125215. /**
  125216. * Define a task used by AssetsManager to load cube textures
  125217. */
  125218. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  125219. /**
  125220. * Defines the name of the task
  125221. */
  125222. name: string;
  125223. /**
  125224. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125225. */
  125226. url: string;
  125227. /**
  125228. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125229. */
  125230. extensions?: string[] | undefined;
  125231. /**
  125232. * Defines if mipmaps should not be generated (default is false)
  125233. */
  125234. noMipmap?: boolean | undefined;
  125235. /**
  125236. * Defines the explicit list of files (undefined by default)
  125237. */
  125238. files?: string[] | undefined;
  125239. /**
  125240. * Gets the loaded texture
  125241. */
  125242. texture: CubeTexture;
  125243. /**
  125244. * Callback called when the task is successful
  125245. */
  125246. onSuccess: (task: CubeTextureAssetTask) => void;
  125247. /**
  125248. * Callback called when the task is successful
  125249. */
  125250. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  125251. /**
  125252. * Creates a new CubeTextureAssetTask
  125253. * @param name defines the name of the task
  125254. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125255. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125256. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125257. * @param files defines the explicit list of files (undefined by default)
  125258. */
  125259. constructor(
  125260. /**
  125261. * Defines the name of the task
  125262. */
  125263. name: string,
  125264. /**
  125265. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125266. */
  125267. url: string,
  125268. /**
  125269. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125270. */
  125271. extensions?: string[] | undefined,
  125272. /**
  125273. * Defines if mipmaps should not be generated (default is false)
  125274. */
  125275. noMipmap?: boolean | undefined,
  125276. /**
  125277. * Defines the explicit list of files (undefined by default)
  125278. */
  125279. files?: string[] | undefined);
  125280. /**
  125281. * Execute the current task
  125282. * @param scene defines the scene where you want your assets to be loaded
  125283. * @param onSuccess is a callback called when the task is successfully executed
  125284. * @param onError is a callback called if an error occurs
  125285. */
  125286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125287. }
  125288. /**
  125289. * Define a task used by AssetsManager to load HDR cube textures
  125290. */
  125291. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  125292. /**
  125293. * Defines the name of the task
  125294. */
  125295. name: string;
  125296. /**
  125297. * Defines the location of the file to load
  125298. */
  125299. url: string;
  125300. /**
  125301. * Defines the desired size (the more it increases the longer the generation will be)
  125302. */
  125303. size: number;
  125304. /**
  125305. * Defines if mipmaps should not be generated (default is false)
  125306. */
  125307. noMipmap: boolean;
  125308. /**
  125309. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125310. */
  125311. generateHarmonics: boolean;
  125312. /**
  125313. * 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)
  125314. */
  125315. gammaSpace: boolean;
  125316. /**
  125317. * Internal Use Only
  125318. */
  125319. reserved: boolean;
  125320. /**
  125321. * Gets the loaded texture
  125322. */
  125323. texture: HDRCubeTexture;
  125324. /**
  125325. * Callback called when the task is successful
  125326. */
  125327. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  125328. /**
  125329. * Callback called when the task is successful
  125330. */
  125331. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  125332. /**
  125333. * Creates a new HDRCubeTextureAssetTask object
  125334. * @param name defines the name of the task
  125335. * @param url defines the location of the file to load
  125336. * @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.
  125337. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125338. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125339. * @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)
  125340. * @param reserved Internal use only
  125341. */
  125342. constructor(
  125343. /**
  125344. * Defines the name of the task
  125345. */
  125346. name: string,
  125347. /**
  125348. * Defines the location of the file to load
  125349. */
  125350. url: string,
  125351. /**
  125352. * Defines the desired size (the more it increases the longer the generation will be)
  125353. */
  125354. size: number,
  125355. /**
  125356. * Defines if mipmaps should not be generated (default is false)
  125357. */
  125358. noMipmap?: boolean,
  125359. /**
  125360. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125361. */
  125362. generateHarmonics?: boolean,
  125363. /**
  125364. * 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)
  125365. */
  125366. gammaSpace?: boolean,
  125367. /**
  125368. * Internal Use Only
  125369. */
  125370. reserved?: boolean);
  125371. /**
  125372. * Execute the current task
  125373. * @param scene defines the scene where you want your assets to be loaded
  125374. * @param onSuccess is a callback called when the task is successfully executed
  125375. * @param onError is a callback called if an error occurs
  125376. */
  125377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125378. }
  125379. /**
  125380. * Define a task used by AssetsManager to load Equirectangular cube textures
  125381. */
  125382. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  125383. /**
  125384. * Defines the name of the task
  125385. */
  125386. name: string;
  125387. /**
  125388. * Defines the location of the file to load
  125389. */
  125390. url: string;
  125391. /**
  125392. * Defines the desired size (the more it increases the longer the generation will be)
  125393. */
  125394. size: number;
  125395. /**
  125396. * Defines if mipmaps should not be generated (default is false)
  125397. */
  125398. noMipmap: boolean;
  125399. /**
  125400. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125401. * but the standard material would require them in Gamma space) (default is true)
  125402. */
  125403. gammaSpace: boolean;
  125404. /**
  125405. * Gets the loaded texture
  125406. */
  125407. texture: EquiRectangularCubeTexture;
  125408. /**
  125409. * Callback called when the task is successful
  125410. */
  125411. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  125412. /**
  125413. * Callback called when the task is successful
  125414. */
  125415. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  125416. /**
  125417. * Creates a new EquiRectangularCubeTextureAssetTask object
  125418. * @param name defines the name of the task
  125419. * @param url defines the location of the file to load
  125420. * @param size defines the desired size (the more it increases the longer the generation will be)
  125421. * If the size is omitted this implies you are using a preprocessed cubemap.
  125422. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125423. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  125424. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  125425. * (default is true)
  125426. */
  125427. constructor(
  125428. /**
  125429. * Defines the name of the task
  125430. */
  125431. name: string,
  125432. /**
  125433. * Defines the location of the file to load
  125434. */
  125435. url: string,
  125436. /**
  125437. * Defines the desired size (the more it increases the longer the generation will be)
  125438. */
  125439. size: number,
  125440. /**
  125441. * Defines if mipmaps should not be generated (default is false)
  125442. */
  125443. noMipmap?: boolean,
  125444. /**
  125445. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125446. * but the standard material would require them in Gamma space) (default is true)
  125447. */
  125448. gammaSpace?: boolean);
  125449. /**
  125450. * Execute the current task
  125451. * @param scene defines the scene where you want your assets to be loaded
  125452. * @param onSuccess is a callback called when the task is successfully executed
  125453. * @param onError is a callback called if an error occurs
  125454. */
  125455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125456. }
  125457. /**
  125458. * This class can be used to easily import assets into a scene
  125459. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  125460. */
  125461. export class AssetsManager {
  125462. private _scene;
  125463. private _isLoading;
  125464. protected _tasks: AbstractAssetTask[];
  125465. protected _waitingTasksCount: number;
  125466. protected _totalTasksCount: number;
  125467. /**
  125468. * Callback called when all tasks are processed
  125469. */
  125470. onFinish: (tasks: AbstractAssetTask[]) => void;
  125471. /**
  125472. * Callback called when a task is successful
  125473. */
  125474. onTaskSuccess: (task: AbstractAssetTask) => void;
  125475. /**
  125476. * Callback called when a task had an error
  125477. */
  125478. onTaskError: (task: AbstractAssetTask) => void;
  125479. /**
  125480. * Callback called when a task is done (whatever the result is)
  125481. */
  125482. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  125483. /**
  125484. * Observable called when all tasks are processed
  125485. */
  125486. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  125487. /**
  125488. * Observable called when a task had an error
  125489. */
  125490. onTaskErrorObservable: Observable<AbstractAssetTask>;
  125491. /**
  125492. * Observable called when all tasks were executed
  125493. */
  125494. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  125495. /**
  125496. * Observable called when a task is done (whatever the result is)
  125497. */
  125498. onProgressObservable: Observable<IAssetsProgressEvent>;
  125499. /**
  125500. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  125501. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125502. */
  125503. useDefaultLoadingScreen: boolean;
  125504. /**
  125505. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  125506. * when all assets have been downloaded.
  125507. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  125508. */
  125509. autoHideLoadingUI: boolean;
  125510. /**
  125511. * Creates a new AssetsManager
  125512. * @param scene defines the scene to work on
  125513. */
  125514. constructor(scene: Scene);
  125515. /**
  125516. * Add a MeshAssetTask to the list of active tasks
  125517. * @param taskName defines the name of the new task
  125518. * @param meshesNames defines the name of meshes to load
  125519. * @param rootUrl defines the root url to use to locate files
  125520. * @param sceneFilename defines the filename of the scene file
  125521. * @returns a new MeshAssetTask object
  125522. */
  125523. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  125524. /**
  125525. * Add a TextFileAssetTask to the list of active tasks
  125526. * @param taskName defines the name of the new task
  125527. * @param url defines the url of the file to load
  125528. * @returns a new TextFileAssetTask object
  125529. */
  125530. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  125531. /**
  125532. * Add a BinaryFileAssetTask to the list of active tasks
  125533. * @param taskName defines the name of the new task
  125534. * @param url defines the url of the file to load
  125535. * @returns a new BinaryFileAssetTask object
  125536. */
  125537. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  125538. /**
  125539. * Add a ImageAssetTask to the list of active tasks
  125540. * @param taskName defines the name of the new task
  125541. * @param url defines the url of the file to load
  125542. * @returns a new ImageAssetTask object
  125543. */
  125544. addImageTask(taskName: string, url: string): ImageAssetTask;
  125545. /**
  125546. * Add a TextureAssetTask to the list of active tasks
  125547. * @param taskName defines the name of the new task
  125548. * @param url defines the url of the file to load
  125549. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125550. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  125551. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125552. * @returns a new TextureAssetTask object
  125553. */
  125554. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  125555. /**
  125556. * Add a CubeTextureAssetTask to the list of active tasks
  125557. * @param taskName defines the name of the new task
  125558. * @param url defines the url of the file to load
  125559. * @param extensions defines the extension to use to load the cube map (can be null)
  125560. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125561. * @param files defines the list of files to load (can be null)
  125562. * @returns a new CubeTextureAssetTask object
  125563. */
  125564. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  125565. /**
  125566. *
  125567. * Add a HDRCubeTextureAssetTask to the list of active tasks
  125568. * @param taskName defines the name of the new task
  125569. * @param url defines the url of the file to load
  125570. * @param size defines the size you want for the cubemap (can be null)
  125571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125572. * @param generateHarmonics defines if you want to automatically generate (true by default)
  125573. * @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)
  125574. * @param reserved Internal use only
  125575. * @returns a new HDRCubeTextureAssetTask object
  125576. */
  125577. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  125578. /**
  125579. *
  125580. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  125581. * @param taskName defines the name of the new task
  125582. * @param url defines the url of the file to load
  125583. * @param size defines the size you want for the cubemap (can be null)
  125584. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125585. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125586. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125587. * @returns a new EquiRectangularCubeTextureAssetTask object
  125588. */
  125589. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  125590. /**
  125591. * Remove a task from the assets manager.
  125592. * @param task the task to remove
  125593. */
  125594. removeTask(task: AbstractAssetTask): void;
  125595. private _decreaseWaitingTasksCount;
  125596. private _runTask;
  125597. /**
  125598. * Reset the AssetsManager and remove all tasks
  125599. * @return the current instance of the AssetsManager
  125600. */
  125601. reset(): AssetsManager;
  125602. /**
  125603. * Start the loading process
  125604. * @return the current instance of the AssetsManager
  125605. */
  125606. load(): AssetsManager;
  125607. /**
  125608. * Start the loading process as an async operation
  125609. * @return a promise returning the list of failed tasks
  125610. */
  125611. loadAsync(): Promise<void>;
  125612. }
  125613. }
  125614. declare module BABYLON {
  125615. /**
  125616. * Wrapper class for promise with external resolve and reject.
  125617. */
  125618. export class Deferred<T> {
  125619. /**
  125620. * The promise associated with this deferred object.
  125621. */
  125622. readonly promise: Promise<T>;
  125623. private _resolve;
  125624. private _reject;
  125625. /**
  125626. * The resolve method of the promise associated with this deferred object.
  125627. */
  125628. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  125629. /**
  125630. * The reject method of the promise associated with this deferred object.
  125631. */
  125632. readonly reject: (reason?: any) => void;
  125633. /**
  125634. * Constructor for this deferred object.
  125635. */
  125636. constructor();
  125637. }
  125638. }
  125639. declare module BABYLON {
  125640. /**
  125641. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  125642. */
  125643. export class MeshExploder {
  125644. private _centerMesh;
  125645. private _meshes;
  125646. private _meshesOrigins;
  125647. private _toCenterVectors;
  125648. private _scaledDirection;
  125649. private _newPosition;
  125650. private _centerPosition;
  125651. /**
  125652. * Explodes meshes from a center mesh.
  125653. * @param meshes The meshes to explode.
  125654. * @param centerMesh The mesh to be center of explosion.
  125655. */
  125656. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  125657. private _setCenterMesh;
  125658. /**
  125659. * Get class name
  125660. * @returns "MeshExploder"
  125661. */
  125662. getClassName(): string;
  125663. /**
  125664. * "Exploded meshes"
  125665. * @returns Array of meshes with the centerMesh at index 0.
  125666. */
  125667. getMeshes(): Array<Mesh>;
  125668. /**
  125669. * Explodes meshes giving a specific direction
  125670. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  125671. */
  125672. explode(direction?: number): void;
  125673. }
  125674. }
  125675. declare module BABYLON {
  125676. /**
  125677. * Class used to help managing file picking and drag'n'drop
  125678. */
  125679. export class FilesInput {
  125680. /**
  125681. * List of files ready to be loaded
  125682. */
  125683. static readonly FilesToLoad: {
  125684. [key: string]: File;
  125685. };
  125686. /**
  125687. * Callback called when a file is processed
  125688. */
  125689. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  125690. private _engine;
  125691. private _currentScene;
  125692. private _sceneLoadedCallback;
  125693. private _progressCallback;
  125694. private _additionalRenderLoopLogicCallback;
  125695. private _textureLoadingCallback;
  125696. private _startingProcessingFilesCallback;
  125697. private _onReloadCallback;
  125698. private _errorCallback;
  125699. private _elementToMonitor;
  125700. private _sceneFileToLoad;
  125701. private _filesToLoad;
  125702. /**
  125703. * Creates a new FilesInput
  125704. * @param engine defines the rendering engine
  125705. * @param scene defines the hosting scene
  125706. * @param sceneLoadedCallback callback called when scene is loaded
  125707. * @param progressCallback callback called to track progress
  125708. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  125709. * @param textureLoadingCallback callback called when a texture is loading
  125710. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  125711. * @param onReloadCallback callback called when a reload is requested
  125712. * @param errorCallback callback call if an error occurs
  125713. */
  125714. 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);
  125715. private _dragEnterHandler;
  125716. private _dragOverHandler;
  125717. private _dropHandler;
  125718. /**
  125719. * Calls this function to listen to drag'n'drop events on a specific DOM element
  125720. * @param elementToMonitor defines the DOM element to track
  125721. */
  125722. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  125723. /**
  125724. * Release all associated resources
  125725. */
  125726. dispose(): void;
  125727. private renderFunction;
  125728. private drag;
  125729. private drop;
  125730. private _traverseFolder;
  125731. private _processFiles;
  125732. /**
  125733. * Load files from a drop event
  125734. * @param event defines the drop event to use as source
  125735. */
  125736. loadFiles(event: any): void;
  125737. private _processReload;
  125738. /**
  125739. * Reload the current scene from the loaded files
  125740. */
  125741. reload(): void;
  125742. }
  125743. }
  125744. declare module BABYLON {
  125745. /**
  125746. * Defines the root class used to create scene optimization to use with SceneOptimizer
  125747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125748. */
  125749. export class SceneOptimization {
  125750. /**
  125751. * Defines the priority of this optimization (0 by default which means first in the list)
  125752. */
  125753. priority: number;
  125754. /**
  125755. * Gets a string describing the action executed by the current optimization
  125756. * @returns description string
  125757. */
  125758. getDescription(): string;
  125759. /**
  125760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125761. * @param scene defines the current scene where to apply this optimization
  125762. * @param optimizer defines the current optimizer
  125763. * @returns true if everything that can be done was applied
  125764. */
  125765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125766. /**
  125767. * Creates the SceneOptimization object
  125768. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125769. * @param desc defines the description associated with the optimization
  125770. */
  125771. constructor(
  125772. /**
  125773. * Defines the priority of this optimization (0 by default which means first in the list)
  125774. */
  125775. priority?: number);
  125776. }
  125777. /**
  125778. * Defines an optimization used to reduce the size of render target textures
  125779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125780. */
  125781. export class TextureOptimization extends SceneOptimization {
  125782. /**
  125783. * Defines the priority of this optimization (0 by default which means first in the list)
  125784. */
  125785. priority: number;
  125786. /**
  125787. * 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
  125788. */
  125789. maximumSize: number;
  125790. /**
  125791. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125792. */
  125793. step: number;
  125794. /**
  125795. * Gets a string describing the action executed by the current optimization
  125796. * @returns description string
  125797. */
  125798. getDescription(): string;
  125799. /**
  125800. * Creates the TextureOptimization object
  125801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125802. * @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
  125803. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125804. */
  125805. constructor(
  125806. /**
  125807. * Defines the priority of this optimization (0 by default which means first in the list)
  125808. */
  125809. priority?: number,
  125810. /**
  125811. * 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
  125812. */
  125813. maximumSize?: number,
  125814. /**
  125815. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125816. */
  125817. step?: number);
  125818. /**
  125819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125820. * @param scene defines the current scene where to apply this optimization
  125821. * @param optimizer defines the current optimizer
  125822. * @returns true if everything that can be done was applied
  125823. */
  125824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125825. }
  125826. /**
  125827. * Defines an optimization used to increase or decrease the rendering resolution
  125828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125829. */
  125830. export class HardwareScalingOptimization extends SceneOptimization {
  125831. /**
  125832. * Defines the priority of this optimization (0 by default which means first in the list)
  125833. */
  125834. priority: number;
  125835. /**
  125836. * Defines the maximum scale to use (2 by default)
  125837. */
  125838. maximumScale: number;
  125839. /**
  125840. * Defines the step to use between two passes (0.5 by default)
  125841. */
  125842. step: number;
  125843. private _currentScale;
  125844. private _directionOffset;
  125845. /**
  125846. * Gets a string describing the action executed by the current optimization
  125847. * @return description string
  125848. */
  125849. getDescription(): string;
  125850. /**
  125851. * Creates the HardwareScalingOptimization object
  125852. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125853. * @param maximumScale defines the maximum scale to use (2 by default)
  125854. * @param step defines the step to use between two passes (0.5 by default)
  125855. */
  125856. constructor(
  125857. /**
  125858. * Defines the priority of this optimization (0 by default which means first in the list)
  125859. */
  125860. priority?: number,
  125861. /**
  125862. * Defines the maximum scale to use (2 by default)
  125863. */
  125864. maximumScale?: number,
  125865. /**
  125866. * Defines the step to use between two passes (0.5 by default)
  125867. */
  125868. step?: number);
  125869. /**
  125870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125871. * @param scene defines the current scene where to apply this optimization
  125872. * @param optimizer defines the current optimizer
  125873. * @returns true if everything that can be done was applied
  125874. */
  125875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125876. }
  125877. /**
  125878. * Defines an optimization used to remove shadows
  125879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125880. */
  125881. export class ShadowsOptimization extends SceneOptimization {
  125882. /**
  125883. * Gets a string describing the action executed by the current optimization
  125884. * @return description string
  125885. */
  125886. getDescription(): string;
  125887. /**
  125888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125889. * @param scene defines the current scene where to apply this optimization
  125890. * @param optimizer defines the current optimizer
  125891. * @returns true if everything that can be done was applied
  125892. */
  125893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125894. }
  125895. /**
  125896. * Defines an optimization used to turn post-processes off
  125897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125898. */
  125899. export class PostProcessesOptimization extends SceneOptimization {
  125900. /**
  125901. * Gets a string describing the action executed by the current optimization
  125902. * @return description string
  125903. */
  125904. getDescription(): string;
  125905. /**
  125906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125907. * @param scene defines the current scene where to apply this optimization
  125908. * @param optimizer defines the current optimizer
  125909. * @returns true if everything that can be done was applied
  125910. */
  125911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125912. }
  125913. /**
  125914. * Defines an optimization used to turn lens flares off
  125915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125916. */
  125917. export class LensFlaresOptimization extends SceneOptimization {
  125918. /**
  125919. * Gets a string describing the action executed by the current optimization
  125920. * @return description string
  125921. */
  125922. getDescription(): string;
  125923. /**
  125924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125925. * @param scene defines the current scene where to apply this optimization
  125926. * @param optimizer defines the current optimizer
  125927. * @returns true if everything that can be done was applied
  125928. */
  125929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125930. }
  125931. /**
  125932. * Defines an optimization based on user defined callback.
  125933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125934. */
  125935. export class CustomOptimization extends SceneOptimization {
  125936. /**
  125937. * Callback called to apply the custom optimization.
  125938. */
  125939. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  125940. /**
  125941. * Callback called to get custom description
  125942. */
  125943. onGetDescription: () => string;
  125944. /**
  125945. * Gets a string describing the action executed by the current optimization
  125946. * @returns description string
  125947. */
  125948. getDescription(): string;
  125949. /**
  125950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125951. * @param scene defines the current scene where to apply this optimization
  125952. * @param optimizer defines the current optimizer
  125953. * @returns true if everything that can be done was applied
  125954. */
  125955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125956. }
  125957. /**
  125958. * Defines an optimization used to turn particles off
  125959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125960. */
  125961. export class ParticlesOptimization extends SceneOptimization {
  125962. /**
  125963. * Gets a string describing the action executed by the current optimization
  125964. * @return description string
  125965. */
  125966. getDescription(): string;
  125967. /**
  125968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125969. * @param scene defines the current scene where to apply this optimization
  125970. * @param optimizer defines the current optimizer
  125971. * @returns true if everything that can be done was applied
  125972. */
  125973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125974. }
  125975. /**
  125976. * Defines an optimization used to turn render targets off
  125977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125978. */
  125979. export class RenderTargetsOptimization extends SceneOptimization {
  125980. /**
  125981. * Gets a string describing the action executed by the current optimization
  125982. * @return description string
  125983. */
  125984. getDescription(): string;
  125985. /**
  125986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125987. * @param scene defines the current scene where to apply this optimization
  125988. * @param optimizer defines the current optimizer
  125989. * @returns true if everything that can be done was applied
  125990. */
  125991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125992. }
  125993. /**
  125994. * Defines an optimization used to merge meshes with compatible materials
  125995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125996. */
  125997. export class MergeMeshesOptimization extends SceneOptimization {
  125998. private static _UpdateSelectionTree;
  125999. /**
  126000. * Gets or sets a boolean which defines if optimization octree has to be updated
  126001. */
  126002. /**
  126003. * Gets or sets a boolean which defines if optimization octree has to be updated
  126004. */
  126005. static UpdateSelectionTree: boolean;
  126006. /**
  126007. * Gets a string describing the action executed by the current optimization
  126008. * @return description string
  126009. */
  126010. getDescription(): string;
  126011. private _canBeMerged;
  126012. /**
  126013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126014. * @param scene defines the current scene where to apply this optimization
  126015. * @param optimizer defines the current optimizer
  126016. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  126017. * @returns true if everything that can be done was applied
  126018. */
  126019. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  126020. }
  126021. /**
  126022. * Defines a list of options used by SceneOptimizer
  126023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126024. */
  126025. export class SceneOptimizerOptions {
  126026. /**
  126027. * Defines the target frame rate to reach (60 by default)
  126028. */
  126029. targetFrameRate: number;
  126030. /**
  126031. * Defines the interval between two checkes (2000ms by default)
  126032. */
  126033. trackerDuration: number;
  126034. /**
  126035. * Gets the list of optimizations to apply
  126036. */
  126037. optimizations: SceneOptimization[];
  126038. /**
  126039. * Creates a new list of options used by SceneOptimizer
  126040. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  126041. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  126042. */
  126043. constructor(
  126044. /**
  126045. * Defines the target frame rate to reach (60 by default)
  126046. */
  126047. targetFrameRate?: number,
  126048. /**
  126049. * Defines the interval between two checkes (2000ms by default)
  126050. */
  126051. trackerDuration?: number);
  126052. /**
  126053. * Add a new optimization
  126054. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  126055. * @returns the current SceneOptimizerOptions
  126056. */
  126057. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  126058. /**
  126059. * Add a new custom optimization
  126060. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  126061. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  126062. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126063. * @returns the current SceneOptimizerOptions
  126064. */
  126065. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  126066. /**
  126067. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  126068. * @param targetFrameRate defines the target frame rate (60 by default)
  126069. * @returns a SceneOptimizerOptions object
  126070. */
  126071. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126072. /**
  126073. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  126074. * @param targetFrameRate defines the target frame rate (60 by default)
  126075. * @returns a SceneOptimizerOptions object
  126076. */
  126077. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126078. /**
  126079. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  126080. * @param targetFrameRate defines the target frame rate (60 by default)
  126081. * @returns a SceneOptimizerOptions object
  126082. */
  126083. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126084. }
  126085. /**
  126086. * Class used to run optimizations in order to reach a target frame rate
  126087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126088. */
  126089. export class SceneOptimizer implements IDisposable {
  126090. private _isRunning;
  126091. private _options;
  126092. private _scene;
  126093. private _currentPriorityLevel;
  126094. private _targetFrameRate;
  126095. private _trackerDuration;
  126096. private _currentFrameRate;
  126097. private _sceneDisposeObserver;
  126098. private _improvementMode;
  126099. /**
  126100. * Defines an observable called when the optimizer reaches the target frame rate
  126101. */
  126102. onSuccessObservable: Observable<SceneOptimizer>;
  126103. /**
  126104. * Defines an observable called when the optimizer enables an optimization
  126105. */
  126106. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  126107. /**
  126108. * Defines an observable called when the optimizer is not able to reach the target frame rate
  126109. */
  126110. onFailureObservable: Observable<SceneOptimizer>;
  126111. /**
  126112. * Gets a boolean indicating if the optimizer is in improvement mode
  126113. */
  126114. readonly isInImprovementMode: boolean;
  126115. /**
  126116. * Gets the current priority level (0 at start)
  126117. */
  126118. readonly currentPriorityLevel: number;
  126119. /**
  126120. * Gets the current frame rate checked by the SceneOptimizer
  126121. */
  126122. readonly currentFrameRate: number;
  126123. /**
  126124. * Gets or sets the current target frame rate (60 by default)
  126125. */
  126126. /**
  126127. * Gets or sets the current target frame rate (60 by default)
  126128. */
  126129. targetFrameRate: number;
  126130. /**
  126131. * Gets or sets the current interval between two checks (every 2000ms by default)
  126132. */
  126133. /**
  126134. * Gets or sets the current interval between two checks (every 2000ms by default)
  126135. */
  126136. trackerDuration: number;
  126137. /**
  126138. * Gets the list of active optimizations
  126139. */
  126140. readonly optimizations: SceneOptimization[];
  126141. /**
  126142. * Creates a new SceneOptimizer
  126143. * @param scene defines the scene to work on
  126144. * @param options defines the options to use with the SceneOptimizer
  126145. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  126146. * @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)
  126147. */
  126148. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  126149. /**
  126150. * Stops the current optimizer
  126151. */
  126152. stop(): void;
  126153. /**
  126154. * Reset the optimizer to initial step (current priority level = 0)
  126155. */
  126156. reset(): void;
  126157. /**
  126158. * Start the optimizer. By default it will try to reach a specific framerate
  126159. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  126160. */
  126161. start(): void;
  126162. private _checkCurrentState;
  126163. /**
  126164. * Release all resources
  126165. */
  126166. dispose(): void;
  126167. /**
  126168. * Helper function to create a SceneOptimizer with one single line of code
  126169. * @param scene defines the scene to work on
  126170. * @param options defines the options to use with the SceneOptimizer
  126171. * @param onSuccess defines a callback to call on success
  126172. * @param onFailure defines a callback to call on failure
  126173. * @returns the new SceneOptimizer object
  126174. */
  126175. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  126176. }
  126177. }
  126178. declare module BABYLON {
  126179. /**
  126180. * Class used to serialize a scene into a string
  126181. */
  126182. export class SceneSerializer {
  126183. /**
  126184. * Clear cache used by a previous serialization
  126185. */
  126186. static ClearCache(): void;
  126187. /**
  126188. * Serialize a scene into a JSON compatible object
  126189. * @param scene defines the scene to serialize
  126190. * @returns a JSON compatible object
  126191. */
  126192. static Serialize(scene: Scene): any;
  126193. /**
  126194. * Serialize a mesh into a JSON compatible object
  126195. * @param toSerialize defines the mesh to serialize
  126196. * @param withParents defines if parents must be serialized as well
  126197. * @param withChildren defines if children must be serialized as well
  126198. * @returns a JSON compatible object
  126199. */
  126200. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  126201. }
  126202. }
  126203. declare module BABYLON {
  126204. /**
  126205. * Class used to host texture specific utilities
  126206. */
  126207. export class TextureTools {
  126208. /**
  126209. * Uses the GPU to create a copy texture rescaled at a given size
  126210. * @param texture Texture to copy from
  126211. * @param width defines the desired width
  126212. * @param height defines the desired height
  126213. * @param useBilinearMode defines if bilinear mode has to be used
  126214. * @return the generated texture
  126215. */
  126216. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  126217. }
  126218. }
  126219. declare module BABYLON {
  126220. /**
  126221. * This represents the different options available for the video capture.
  126222. */
  126223. export interface VideoRecorderOptions {
  126224. /** Defines the mime type of the video. */
  126225. mimeType: string;
  126226. /** Defines the FPS the video should be recorded at. */
  126227. fps: number;
  126228. /** Defines the chunk size for the recording data. */
  126229. recordChunckSize: number;
  126230. /** The audio tracks to attach to the recording. */
  126231. audioTracks?: MediaStreamTrack[];
  126232. }
  126233. /**
  126234. * This can help with recording videos from BabylonJS.
  126235. * This is based on the available WebRTC functionalities of the browser.
  126236. *
  126237. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  126238. */
  126239. export class VideoRecorder {
  126240. private static readonly _defaultOptions;
  126241. /**
  126242. * Returns whether or not the VideoRecorder is available in your browser.
  126243. * @param engine Defines the Babylon Engine.
  126244. * @returns true if supported otherwise false.
  126245. */
  126246. static IsSupported(engine: Engine): boolean;
  126247. private readonly _options;
  126248. private _canvas;
  126249. private _mediaRecorder;
  126250. private _recordedChunks;
  126251. private _fileName;
  126252. private _resolve;
  126253. private _reject;
  126254. /**
  126255. * True when a recording is already in progress.
  126256. */
  126257. readonly isRecording: boolean;
  126258. /**
  126259. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  126260. * @param engine Defines the BabylonJS Engine you wish to record.
  126261. * @param options Defines options that can be used to customize the capture.
  126262. */
  126263. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  126264. /**
  126265. * Stops the current recording before the default capture timeout passed in the startRecording function.
  126266. */
  126267. stopRecording(): void;
  126268. /**
  126269. * Starts recording the canvas for a max duration specified in parameters.
  126270. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  126271. * If null no automatic download will start and you can rely on the promise to get the data back.
  126272. * @param maxDuration Defines the maximum recording time in seconds.
  126273. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  126274. * @return A promise callback at the end of the recording with the video data in Blob.
  126275. */
  126276. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  126277. /**
  126278. * Releases internal resources used during the recording.
  126279. */
  126280. dispose(): void;
  126281. private _handleDataAvailable;
  126282. private _handleError;
  126283. private _handleStop;
  126284. }
  126285. }
  126286. declare module BABYLON {
  126287. /**
  126288. * Class containing a set of static utilities functions for screenshots
  126289. */
  126290. export class ScreenshotTools {
  126291. /**
  126292. * Captures a screenshot of the current rendering
  126293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126294. * @param engine defines the rendering engine
  126295. * @param camera defines the source camera
  126296. * @param size This parameter can be set to a single number or to an object with the
  126297. * following (optional) properties: precision, width, height. If a single number is passed,
  126298. * it will be used for both width and height. If an object is passed, the screenshot size
  126299. * will be derived from the parameters. The precision property is a multiplier allowing
  126300. * rendering at a higher or lower resolution
  126301. * @param successCallback defines the callback receives a single parameter which contains the
  126302. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126303. * src parameter of an <img> to display it
  126304. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126305. * Check your browser for supported MIME types
  126306. */
  126307. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  126308. /**
  126309. * Captures a screenshot of the current rendering
  126310. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126311. * @param engine defines the rendering engine
  126312. * @param camera defines the source camera
  126313. * @param size This parameter can be set to a single number or to an object with the
  126314. * following (optional) properties: precision, width, height. If a single number is passed,
  126315. * it will be used for both width and height. If an object is passed, the screenshot size
  126316. * will be derived from the parameters. The precision property is a multiplier allowing
  126317. * rendering at a higher or lower resolution
  126318. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126319. * Check your browser for supported MIME types
  126320. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126321. * to the src parameter of an <img> to display it
  126322. */
  126323. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  126324. /**
  126325. * Generates an image screenshot from the specified camera.
  126326. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126327. * @param engine The engine to use for rendering
  126328. * @param camera The camera to use for rendering
  126329. * @param size This parameter can be set to a single number or to an object with the
  126330. * following (optional) properties: precision, width, height. If a single number is passed,
  126331. * it will be used for both width and height. If an object is passed, the screenshot size
  126332. * will be derived from the parameters. The precision property is a multiplier allowing
  126333. * rendering at a higher or lower resolution
  126334. * @param successCallback The callback receives a single parameter which contains the
  126335. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126336. * src parameter of an <img> to display it
  126337. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126338. * Check your browser for supported MIME types
  126339. * @param samples Texture samples (default: 1)
  126340. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126341. * @param fileName A name for for the downloaded file.
  126342. */
  126343. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  126344. /**
  126345. * Generates an image screenshot from the specified camera.
  126346. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126347. * @param engine The engine to use for rendering
  126348. * @param camera The camera to use for rendering
  126349. * @param size This parameter can be set to a single number or to an object with the
  126350. * following (optional) properties: precision, width, height. If a single number is passed,
  126351. * it will be used for both width and height. If an object is passed, the screenshot size
  126352. * will be derived from the parameters. The precision property is a multiplier allowing
  126353. * rendering at a higher or lower resolution
  126354. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126355. * Check your browser for supported MIME types
  126356. * @param samples Texture samples (default: 1)
  126357. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126358. * @param fileName A name for for the downloaded file.
  126359. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126360. * to the src parameter of an <img> to display it
  126361. */
  126362. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  126363. /**
  126364. * Gets height and width for screenshot size
  126365. * @private
  126366. */
  126367. private static _getScreenshotSize;
  126368. }
  126369. }
  126370. declare module BABYLON {
  126371. /**
  126372. * A cursor which tracks a point on a path
  126373. */
  126374. export class PathCursor {
  126375. private path;
  126376. /**
  126377. * Stores path cursor callbacks for when an onchange event is triggered
  126378. */
  126379. private _onchange;
  126380. /**
  126381. * The value of the path cursor
  126382. */
  126383. value: number;
  126384. /**
  126385. * The animation array of the path cursor
  126386. */
  126387. animations: Animation[];
  126388. /**
  126389. * Initializes the path cursor
  126390. * @param path The path to track
  126391. */
  126392. constructor(path: Path2);
  126393. /**
  126394. * Gets the cursor point on the path
  126395. * @returns A point on the path cursor at the cursor location
  126396. */
  126397. getPoint(): Vector3;
  126398. /**
  126399. * Moves the cursor ahead by the step amount
  126400. * @param step The amount to move the cursor forward
  126401. * @returns This path cursor
  126402. */
  126403. moveAhead(step?: number): PathCursor;
  126404. /**
  126405. * Moves the cursor behind by the step amount
  126406. * @param step The amount to move the cursor back
  126407. * @returns This path cursor
  126408. */
  126409. moveBack(step?: number): PathCursor;
  126410. /**
  126411. * Moves the cursor by the step amount
  126412. * If the step amount is greater than one, an exception is thrown
  126413. * @param step The amount to move the cursor
  126414. * @returns This path cursor
  126415. */
  126416. move(step: number): PathCursor;
  126417. /**
  126418. * Ensures that the value is limited between zero and one
  126419. * @returns This path cursor
  126420. */
  126421. private ensureLimits;
  126422. /**
  126423. * Runs onchange callbacks on change (used by the animation engine)
  126424. * @returns This path cursor
  126425. */
  126426. private raiseOnChange;
  126427. /**
  126428. * Executes a function on change
  126429. * @param f A path cursor onchange callback
  126430. * @returns This path cursor
  126431. */
  126432. onchange(f: (cursor: PathCursor) => void): PathCursor;
  126433. }
  126434. }
  126435. declare module BABYLON {
  126436. /** @hidden */
  126437. export var blurPixelShader: {
  126438. name: string;
  126439. shader: string;
  126440. };
  126441. }
  126442. declare module BABYLON {
  126443. /** @hidden */
  126444. export var pointCloudVertexDeclaration: {
  126445. name: string;
  126446. shader: string;
  126447. };
  126448. }
  126449. // Mixins
  126450. interface Window {
  126451. mozIndexedDB: IDBFactory;
  126452. webkitIndexedDB: IDBFactory;
  126453. msIndexedDB: IDBFactory;
  126454. webkitURL: typeof URL;
  126455. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  126456. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  126457. WebGLRenderingContext: WebGLRenderingContext;
  126458. MSGesture: MSGesture;
  126459. CANNON: any;
  126460. AudioContext: AudioContext;
  126461. webkitAudioContext: AudioContext;
  126462. PointerEvent: any;
  126463. Math: Math;
  126464. Uint8Array: Uint8ArrayConstructor;
  126465. Float32Array: Float32ArrayConstructor;
  126466. mozURL: typeof URL;
  126467. msURL: typeof URL;
  126468. VRFrameData: any; // WebVR, from specs 1.1
  126469. DracoDecoderModule: any;
  126470. setImmediate(handler: (...args: any[]) => void): number;
  126471. }
  126472. interface HTMLCanvasElement {
  126473. requestPointerLock(): void;
  126474. msRequestPointerLock?(): void;
  126475. mozRequestPointerLock?(): void;
  126476. webkitRequestPointerLock?(): void;
  126477. /** Track wether a record is in progress */
  126478. isRecording: boolean;
  126479. /** Capture Stream method defined by some browsers */
  126480. captureStream(fps?: number): MediaStream;
  126481. }
  126482. interface CanvasRenderingContext2D {
  126483. msImageSmoothingEnabled: boolean;
  126484. }
  126485. interface MouseEvent {
  126486. mozMovementX: number;
  126487. mozMovementY: number;
  126488. webkitMovementX: number;
  126489. webkitMovementY: number;
  126490. msMovementX: number;
  126491. msMovementY: number;
  126492. }
  126493. interface Navigator {
  126494. mozGetVRDevices: (any: any) => any;
  126495. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126496. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126497. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126498. webkitGetGamepads(): Gamepad[];
  126499. msGetGamepads(): Gamepad[];
  126500. webkitGamepads(): Gamepad[];
  126501. }
  126502. interface HTMLVideoElement {
  126503. mozSrcObject: any;
  126504. }
  126505. interface Math {
  126506. fround(x: number): number;
  126507. imul(a: number, b: number): number;
  126508. }
  126509. interface WebGLRenderingContext {
  126510. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  126511. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  126512. vertexAttribDivisor(index: number, divisor: number): void;
  126513. createVertexArray(): any;
  126514. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  126515. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  126516. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  126517. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  126518. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  126519. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  126520. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  126521. // Queries
  126522. createQuery(): WebGLQuery;
  126523. deleteQuery(query: WebGLQuery): void;
  126524. beginQuery(target: number, query: WebGLQuery): void;
  126525. endQuery(target: number): void;
  126526. getQueryParameter(query: WebGLQuery, pname: number): any;
  126527. getQuery(target: number, pname: number): any;
  126528. MAX_SAMPLES: number;
  126529. RGBA8: number;
  126530. READ_FRAMEBUFFER: number;
  126531. DRAW_FRAMEBUFFER: number;
  126532. UNIFORM_BUFFER: number;
  126533. HALF_FLOAT_OES: number;
  126534. RGBA16F: number;
  126535. RGBA32F: number;
  126536. R32F: number;
  126537. RG32F: number;
  126538. RGB32F: number;
  126539. R16F: number;
  126540. RG16F: number;
  126541. RGB16F: number;
  126542. RED: number;
  126543. RG: number;
  126544. R8: number;
  126545. RG8: number;
  126546. UNSIGNED_INT_24_8: number;
  126547. DEPTH24_STENCIL8: number;
  126548. /* Multiple Render Targets */
  126549. drawBuffers(buffers: number[]): void;
  126550. readBuffer(src: number): void;
  126551. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  126552. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  126553. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  126554. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  126555. // Occlusion Query
  126556. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  126557. ANY_SAMPLES_PASSED: number;
  126558. QUERY_RESULT_AVAILABLE: number;
  126559. QUERY_RESULT: number;
  126560. }
  126561. interface WebGLProgram {
  126562. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  126563. }
  126564. interface EXT_disjoint_timer_query {
  126565. QUERY_COUNTER_BITS_EXT: number;
  126566. TIME_ELAPSED_EXT: number;
  126567. TIMESTAMP_EXT: number;
  126568. GPU_DISJOINT_EXT: number;
  126569. QUERY_RESULT_EXT: number;
  126570. QUERY_RESULT_AVAILABLE_EXT: number;
  126571. queryCounterEXT(query: WebGLQuery, target: number): void;
  126572. createQueryEXT(): WebGLQuery;
  126573. beginQueryEXT(target: number, query: WebGLQuery): void;
  126574. endQueryEXT(target: number): void;
  126575. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  126576. deleteQueryEXT(query: WebGLQuery): void;
  126577. }
  126578. interface WebGLUniformLocation {
  126579. _currentState: any;
  126580. }
  126581. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  126582. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  126583. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  126584. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126585. interface WebGLRenderingContext {
  126586. readonly RASTERIZER_DISCARD: number;
  126587. readonly DEPTH_COMPONENT24: number;
  126588. readonly TEXTURE_3D: number;
  126589. readonly TEXTURE_2D_ARRAY: number;
  126590. readonly TEXTURE_COMPARE_FUNC: number;
  126591. readonly TEXTURE_COMPARE_MODE: number;
  126592. readonly COMPARE_REF_TO_TEXTURE: number;
  126593. readonly TEXTURE_WRAP_R: number;
  126594. readonly HALF_FLOAT: number;
  126595. readonly RGB8: number;
  126596. readonly RED_INTEGER: number;
  126597. readonly RG_INTEGER: number;
  126598. readonly RGB_INTEGER: number;
  126599. readonly RGBA_INTEGER: number;
  126600. readonly R8_SNORM: number;
  126601. readonly RG8_SNORM: number;
  126602. readonly RGB8_SNORM: number;
  126603. readonly RGBA8_SNORM: number;
  126604. readonly R8I: number;
  126605. readonly RG8I: number;
  126606. readonly RGB8I: number;
  126607. readonly RGBA8I: number;
  126608. readonly R8UI: number;
  126609. readonly RG8UI: number;
  126610. readonly RGB8UI: number;
  126611. readonly RGBA8UI: number;
  126612. readonly R16I: number;
  126613. readonly RG16I: number;
  126614. readonly RGB16I: number;
  126615. readonly RGBA16I: number;
  126616. readonly R16UI: number;
  126617. readonly RG16UI: number;
  126618. readonly RGB16UI: number;
  126619. readonly RGBA16UI: number;
  126620. readonly R32I: number;
  126621. readonly RG32I: number;
  126622. readonly RGB32I: number;
  126623. readonly RGBA32I: number;
  126624. readonly R32UI: number;
  126625. readonly RG32UI: number;
  126626. readonly RGB32UI: number;
  126627. readonly RGBA32UI: number;
  126628. readonly RGB10_A2UI: number;
  126629. readonly R11F_G11F_B10F: number;
  126630. readonly RGB9_E5: number;
  126631. readonly RGB10_A2: number;
  126632. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  126633. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  126634. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  126635. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126636. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  126637. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  126638. 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;
  126639. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  126640. readonly TRANSFORM_FEEDBACK: number;
  126641. readonly INTERLEAVED_ATTRIBS: number;
  126642. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  126643. createTransformFeedback(): WebGLTransformFeedback;
  126644. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  126645. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  126646. beginTransformFeedback(primitiveMode: number): void;
  126647. endTransformFeedback(): void;
  126648. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  126649. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126650. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126651. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126652. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  126653. }
  126654. interface ImageBitmap {
  126655. readonly width: number;
  126656. readonly height: number;
  126657. close(): void;
  126658. }
  126659. interface WebGLQuery extends WebGLObject {
  126660. }
  126661. declare var WebGLQuery: {
  126662. prototype: WebGLQuery;
  126663. new(): WebGLQuery;
  126664. };
  126665. interface WebGLSampler extends WebGLObject {
  126666. }
  126667. declare var WebGLSampler: {
  126668. prototype: WebGLSampler;
  126669. new(): WebGLSampler;
  126670. };
  126671. interface WebGLSync extends WebGLObject {
  126672. }
  126673. declare var WebGLSync: {
  126674. prototype: WebGLSync;
  126675. new(): WebGLSync;
  126676. };
  126677. interface WebGLTransformFeedback extends WebGLObject {
  126678. }
  126679. declare var WebGLTransformFeedback: {
  126680. prototype: WebGLTransformFeedback;
  126681. new(): WebGLTransformFeedback;
  126682. };
  126683. interface WebGLVertexArrayObject extends WebGLObject {
  126684. }
  126685. declare var WebGLVertexArrayObject: {
  126686. prototype: WebGLVertexArrayObject;
  126687. new(): WebGLVertexArrayObject;
  126688. };
  126689. // Type definitions for WebVR API
  126690. // Project: https://w3c.github.io/webvr/
  126691. // Definitions by: six a <https://github.com/lostfictions>
  126692. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126693. interface VRDisplay extends EventTarget {
  126694. /**
  126695. * Dictionary of capabilities describing the VRDisplay.
  126696. */
  126697. readonly capabilities: VRDisplayCapabilities;
  126698. /**
  126699. * z-depth defining the far plane of the eye view frustum
  126700. * enables mapping of values in the render target depth
  126701. * attachment to scene coordinates. Initially set to 10000.0.
  126702. */
  126703. depthFar: number;
  126704. /**
  126705. * z-depth defining the near plane of the eye view frustum
  126706. * enables mapping of values in the render target depth
  126707. * attachment to scene coordinates. Initially set to 0.01.
  126708. */
  126709. depthNear: number;
  126710. /**
  126711. * An identifier for this distinct VRDisplay. Used as an
  126712. * association point in the Gamepad API.
  126713. */
  126714. readonly displayId: number;
  126715. /**
  126716. * A display name, a user-readable name identifying it.
  126717. */
  126718. readonly displayName: string;
  126719. readonly isConnected: boolean;
  126720. readonly isPresenting: boolean;
  126721. /**
  126722. * If this VRDisplay supports room-scale experiences, the optional
  126723. * stage attribute contains details on the room-scale parameters.
  126724. */
  126725. readonly stageParameters: VRStageParameters | null;
  126726. /**
  126727. * Passing the value returned by `requestAnimationFrame` to
  126728. * `cancelAnimationFrame` will unregister the callback.
  126729. * @param handle Define the hanle of the request to cancel
  126730. */
  126731. cancelAnimationFrame(handle: number): void;
  126732. /**
  126733. * Stops presenting to the VRDisplay.
  126734. * @returns a promise to know when it stopped
  126735. */
  126736. exitPresent(): Promise<void>;
  126737. /**
  126738. * Return the current VREyeParameters for the given eye.
  126739. * @param whichEye Define the eye we want the parameter for
  126740. * @returns the eye parameters
  126741. */
  126742. getEyeParameters(whichEye: string): VREyeParameters;
  126743. /**
  126744. * Populates the passed VRFrameData with the information required to render
  126745. * the current frame.
  126746. * @param frameData Define the data structure to populate
  126747. * @returns true if ok otherwise false
  126748. */
  126749. getFrameData(frameData: VRFrameData): boolean;
  126750. /**
  126751. * Get the layers currently being presented.
  126752. * @returns the list of VR layers
  126753. */
  126754. getLayers(): VRLayer[];
  126755. /**
  126756. * Return a VRPose containing the future predicted pose of the VRDisplay
  126757. * when the current frame will be presented. The value returned will not
  126758. * change until JavaScript has returned control to the browser.
  126759. *
  126760. * The VRPose will contain the position, orientation, velocity,
  126761. * and acceleration of each of these properties.
  126762. * @returns the pose object
  126763. */
  126764. getPose(): VRPose;
  126765. /**
  126766. * Return the current instantaneous pose of the VRDisplay, with no
  126767. * prediction applied.
  126768. * @returns the current instantaneous pose
  126769. */
  126770. getImmediatePose(): VRPose;
  126771. /**
  126772. * The callback passed to `requestAnimationFrame` will be called
  126773. * any time a new frame should be rendered. When the VRDisplay is
  126774. * presenting the callback will be called at the native refresh
  126775. * rate of the HMD. When not presenting this function acts
  126776. * identically to how window.requestAnimationFrame acts. Content should
  126777. * make no assumptions of frame rate or vsync behavior as the HMD runs
  126778. * asynchronously from other displays and at differing refresh rates.
  126779. * @param callback Define the eaction to run next frame
  126780. * @returns the request handle it
  126781. */
  126782. requestAnimationFrame(callback: FrameRequestCallback): number;
  126783. /**
  126784. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  126785. * Repeat calls while already presenting will update the VRLayers being displayed.
  126786. * @param layers Define the list of layer to present
  126787. * @returns a promise to know when the request has been fulfilled
  126788. */
  126789. requestPresent(layers: VRLayer[]): Promise<void>;
  126790. /**
  126791. * Reset the pose for this display, treating its current position and
  126792. * orientation as the "origin/zero" values. VRPose.position,
  126793. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  126794. * updated when calling resetPose(). This should be called in only
  126795. * sitting-space experiences.
  126796. */
  126797. resetPose(): void;
  126798. /**
  126799. * The VRLayer provided to the VRDisplay will be captured and presented
  126800. * in the HMD. Calling this function has the same effect on the source
  126801. * canvas as any other operation that uses its source image, and canvases
  126802. * created without preserveDrawingBuffer set to true will be cleared.
  126803. * @param pose Define the pose to submit
  126804. */
  126805. submitFrame(pose?: VRPose): void;
  126806. }
  126807. declare var VRDisplay: {
  126808. prototype: VRDisplay;
  126809. new(): VRDisplay;
  126810. };
  126811. interface VRLayer {
  126812. leftBounds?: number[] | Float32Array | null;
  126813. rightBounds?: number[] | Float32Array | null;
  126814. source?: HTMLCanvasElement | null;
  126815. }
  126816. interface VRDisplayCapabilities {
  126817. readonly canPresent: boolean;
  126818. readonly hasExternalDisplay: boolean;
  126819. readonly hasOrientation: boolean;
  126820. readonly hasPosition: boolean;
  126821. readonly maxLayers: number;
  126822. }
  126823. interface VREyeParameters {
  126824. /** @deprecated */
  126825. readonly fieldOfView: VRFieldOfView;
  126826. readonly offset: Float32Array;
  126827. readonly renderHeight: number;
  126828. readonly renderWidth: number;
  126829. }
  126830. interface VRFieldOfView {
  126831. readonly downDegrees: number;
  126832. readonly leftDegrees: number;
  126833. readonly rightDegrees: number;
  126834. readonly upDegrees: number;
  126835. }
  126836. interface VRFrameData {
  126837. readonly leftProjectionMatrix: Float32Array;
  126838. readonly leftViewMatrix: Float32Array;
  126839. readonly pose: VRPose;
  126840. readonly rightProjectionMatrix: Float32Array;
  126841. readonly rightViewMatrix: Float32Array;
  126842. readonly timestamp: number;
  126843. }
  126844. interface VRPose {
  126845. readonly angularAcceleration: Float32Array | null;
  126846. readonly angularVelocity: Float32Array | null;
  126847. readonly linearAcceleration: Float32Array | null;
  126848. readonly linearVelocity: Float32Array | null;
  126849. readonly orientation: Float32Array | null;
  126850. readonly position: Float32Array | null;
  126851. readonly timestamp: number;
  126852. }
  126853. interface VRStageParameters {
  126854. sittingToStandingTransform?: Float32Array;
  126855. sizeX?: number;
  126856. sizeY?: number;
  126857. }
  126858. interface Navigator {
  126859. getVRDisplays(): Promise<VRDisplay[]>;
  126860. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  126861. }
  126862. interface Window {
  126863. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  126864. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  126865. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  126866. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126867. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126868. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  126869. }
  126870. interface Gamepad {
  126871. readonly displayId: number;
  126872. }
  126873. type XRSessionMode =
  126874. | "inline"
  126875. | "immersive-vr"
  126876. | "immersive-ar";
  126877. type XRReferenceSpaceType =
  126878. | "viewer"
  126879. | "local"
  126880. | "local-floor"
  126881. | "bounded-floor"
  126882. | "unbounded";
  126883. type XREnvironmentBlendMode =
  126884. | "opaque"
  126885. | "additive"
  126886. | "alpha-blend";
  126887. type XRVisibilityState =
  126888. | "visible"
  126889. | "visible-blurred"
  126890. | "hidden";
  126891. type XRHandedness =
  126892. | "none"
  126893. | "left"
  126894. | "right";
  126895. type XRTargetRayMode =
  126896. | "gaze"
  126897. | "tracked-pointer"
  126898. | "screen";
  126899. type XREye =
  126900. | "none"
  126901. | "left"
  126902. | "right";
  126903. interface XRSpace extends EventTarget {
  126904. }
  126905. interface XRRenderState {
  126906. depthNear?: number;
  126907. depthFar?: number;
  126908. inlineVerticalFieldOfView?: number;
  126909. baseLayer?: XRWebGLLayer;
  126910. }
  126911. interface XRInputSource {
  126912. handedness: XRHandedness;
  126913. targetRayMode: XRTargetRayMode;
  126914. targetRaySpace: XRSpace;
  126915. gripSpace: XRSpace | undefined;
  126916. gamepad: Gamepad | undefined;
  126917. profiles: Array<string>;
  126918. }
  126919. interface XRSession {
  126920. addEventListener: Function;
  126921. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126922. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  126923. requestAnimationFrame: Function;
  126924. end(): Promise<void>;
  126925. renderState: XRRenderState;
  126926. inputSources: Array<XRInputSource>;
  126927. }
  126928. interface XRReferenceSpace extends XRSpace {
  126929. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  126930. onreset: any;
  126931. }
  126932. interface XRFrame {
  126933. session: XRSession;
  126934. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  126935. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  126936. }
  126937. interface XRViewerPose extends XRPose {
  126938. views: Array<XRView>;
  126939. }
  126940. interface XRPose {
  126941. transform: XRRigidTransform;
  126942. emulatedPosition: boolean;
  126943. }
  126944. declare var XRWebGLLayer: {
  126945. prototype: XRWebGLLayer;
  126946. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  126947. };
  126948. interface XRWebGLLayer {
  126949. framebuffer: WebGLFramebuffer;
  126950. framebufferWidth: number;
  126951. framebufferHeight: number;
  126952. getViewport: Function;
  126953. }
  126954. interface XRRigidTransform {
  126955. position: DOMPointReadOnly;
  126956. orientation: DOMPointReadOnly;
  126957. matrix: Float32Array;
  126958. inverse: XRRigidTransform;
  126959. }
  126960. interface XRView {
  126961. eye: XREye;
  126962. projectionMatrix: Float32Array;
  126963. transform: XRRigidTransform;
  126964. }
  126965. interface XRInputSourceChangeEvent {
  126966. session: XRSession;
  126967. removed: Array<XRInputSource>;
  126968. added: Array<XRInputSource>;
  126969. }